31 lines · c
1#include "attach.h"2#include <stdio.h>3#ifdef _MSC_VER4#include <windows.h>5#define sleep(x) Sleep((x) * 1000)6#else7#include <unistd.h>8#endif9 10int main(int argc, char const *argv[])11{12 lldb_enable_attach();13 14 printf("Hello world.\n"); // Set break point at this line.15 if (argc == 1)16 return 1;17 18 // Create the synchronization token.19 FILE *f;20 if (f = fopen(argv[1], "wx")) {21 fputs("\n", f);22 fflush(f);23 fclose(f);24 } else25 return 1;26 27 // Waiting to be attached by the debugger, otherwise.28 while (1)29 sleep(1); // Waiting to be attached...30}31