| 1 | #include <dlfcn.h> |
| 2 | #include <unistd.h> |
| 3 | #include <stdlib.h> |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | int setup_is_complete = 0; |
| 7 | |
| 8 | int main(int argc, const char** argv) |
| 9 | { |
| 10 | |
| 11 | void *handle = dlopen (file: "com.apple.sbd.xpc/com.apple.sbd" , RTLD_NOW); |
| 12 | if (handle) |
| 13 | { |
| 14 | if (dlsym(handle: handle, name: "foo" )) |
| 15 | { |
| 16 | system (command: "/bin/rm -rf com.apple.sbd.xpc com.apple.sbd.xpc.dSYM" ); |
| 17 | |
| 18 | FILE *fp = fopen (filename: argv[1], modes: "w" ); |
| 19 | fclose (stream: fp); |
| 20 | setup_is_complete = 1; |
| 21 | |
| 22 | // At this point we want lldb to attach to the process. If lldb attaches |
| 23 | // before we've removed the dlopen'ed bundle, lldb will find the bundle |
| 24 | // at its actual filepath and not have to do any tricky work, invalidating |
| 25 | // the test. |
| 26 | |
| 27 | for (int loop_limiter = 0; loop_limiter < 100; loop_limiter++) |
| 28 | sleep (seconds: 1); |
| 29 | } |
| 30 | } |
| 31 | return 0; |
| 32 | } |
| 33 | |