1 | #include "attach.h" |
2 | #include <stdio.h> |
3 | #ifdef _MSC_VER |
4 | #include <windows.h> |
5 | #define sleep(x) Sleep((x) * 1000) |
6 | #else |
7 | #include <unistd.h> |
8 | #endif |
9 | |
10 | int main(int argc, char const *argv[]) |
11 | { |
12 | lldb_enable_attach(); |
13 | |
14 | printf(format: "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(filename: argv[1], modes: "wx" )) { |
21 | fputs(s: "\n" , stream: f); |
22 | fflush(stream: f); |
23 | fclose(stream: f); |
24 | } else |
25 | return 1; |
26 | |
27 | // Waiting to be attached by the debugger, otherwise. |
28 | while (1) |
29 | sleep(seconds: 1); // Waiting to be attached... |
30 | } |
31 | |