brintos

brintos / llvm-project-archived public Read only

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