]>
git.saurik.com Git - apple/dyld.git/blob - testing/test-cases/dyld_process_info_unload.dtest/main.cpp
2 // BUILD: $CC target.c -o $BUILD_DIR/target.exe
3 // BUILD: $CC foo.c -o $BUILD_DIR/libfoo.dylib -dynamiclib -install_name $RUN_DIR/libfoo.dylib
4 // BUILD: $CXX main.cpp -o $BUILD_DIR/dyld_process_info_unload.exe -DRUN_DIR="$RUN_DIR"
5 // BUILD: $TASK_FOR_PID_ENABLE $BUILD_DIR/dyld_process_info_unload.exe
7 // RUN: $SUDO ./dyld_process_info_unload.exe $RUN_DIR/target.exe
16 #include <mach/mach.h>
17 #include <mach/machine.h>
18 #include <mach-o/dyld_process_info.h>
20 #include "test_support.h"
22 int main(int argc
, const char* argv
[], const char* envp
[], const char* apple
[]) {
24 process
.set_executable_path(RUN_DIR
"/target.exe");
25 process
.set_launch_suspended(true);
26 process
.set_launch_async(true);
27 const char* env
[] = { "TEST_OUTPUT=None", NULL
};
29 pid_t pid
= process
.launch();
31 if (task_for_pid(mach_task_self(), pid
, &task
) != KERN_SUCCESS
) {
32 FAIL("task_for_pid() failed");
35 dispatch_async(dispatch_get_main_queue(), ^{
37 for (int i
=0; i
< 100; ++i
) {
39 dyld_process_info info
= _dyld_process_info_create(task
, 0, &result
);
40 LOG("info=%p, result=%08X", info
, result
);
42 (void)kill(pid
, SIGCONT
);
44 //FIXME: Compact info will never fail, make this a FAIL()
46 // ideally the fail count would be zero. But the target is dlopen/dlclosing in a tight loop, so there may never be a stable set of images.
47 // The real bug driving this test case was _dyld_process_info_create() crashing when the the image list changed too fast.
48 // The important thing is to not crash. Getting NULL back is ok.
49 LOG("info=%p, result=%08X", info
, result
);
53 _dyld_process_info_release(info
);