| 1 | #include "attach.h" |
|---|---|
| 2 | #include <stdio.h> |
| 3 | #include <string.h> |
| 4 | #include <unistd.h> |
| 5 | |
| 6 | int |
| 7 | main (int argc, char **argv) |
| 8 | { |
| 9 | lldb_enable_attach(); |
| 10 | |
| 11 | int do_crash = 0; |
| 12 | int do_wait = 0; |
| 13 | |
| 14 | int idx; |
| 15 | for (idx = 1; idx < argc; idx++) |
| 16 | { |
| 17 | if (strcmp(s1: argv[idx], s2: "CRASH") == 0) |
| 18 | do_crash = 1; |
| 19 | if (strcmp(s1: argv[idx], s2: "WAIT") == 0) |
| 20 | do_wait = 1; |
| 21 | } |
| 22 | printf(format: "PID: %d END\n", getpid()); |
| 23 | |
| 24 | if (do_wait) |
| 25 | { |
| 26 | int keep_waiting = 1; |
| 27 | while (keep_waiting) |
| 28 | { |
| 29 | printf (format: "Waiting\n"); |
| 30 | sleep(seconds: 1); // Stop here to unset keep_waiting |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | if (do_crash) |
| 35 | { |
| 36 | char *touch_me_not = (char *) 0; |
| 37 | printf (format: "About to crash.\n"); |
| 38 | touch_me_not[0] = 'a'; |
| 39 | } |
| 40 | printf (format: "Got there on time and it did not crash.\n"); |
| 41 | return 0; |
| 42 | } |
| 43 |
