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

source code of lldb/test/API/driver/batch_mode/main.c