xref: /llvm-project/lldb/test/API/functionalities/breakpoint/serialize/main.c (revision fdea9a4ec9b0d9585b8fe8a612686d9f44f40ddc)
1 #include <stdio.h>
2 
3 // This simple program is to demonstrate the capability of the lldb command
4 // "breakpoint modify -i <count> breakpt-id" to set the number of times a
5 // breakpoint is skipped before stopping.  Ignore count can also be set upon
6 // breakpoint creation by 'breakpoint set ... -i <count>'.
7 
8 int a(int);
9 int b(int);
10 int c(int);
11 
a(int val)12 int a(int val)
13 {
14     if (val <= 1)
15         return b(val);
16     else if (val >= 3)
17         return c(val); // a(3) -> c(3) Find the call site of c(3).
18 
19     return val;
20 }
21 
b(int val)22 int b(int val)
23 {
24     return c(val);
25 }
26 
c(int val)27 int c(int val)
28 {
29     return val + 3; // Find the line number of function "c" here.
30 }
31 
main(int argc,char const * argv[])32 int main (int argc, char const *argv[])
33 {
34     int A1 = a(1);  // a(1) -> b(1) -> c(1)
35     printf("a(1) returns %d\n", A1);
36 
37     int B2 = b(2);  // b(2) -> c(2) Find the call site of b(2).
38     printf("b(2) returns %d\n", B2);
39 
40     int A3 = a(3);  // a(3) -> c(3) Find the call site of a(3).
41     printf("a(3) returns %d\n", A3);
42 
43     int C1 = c(5); // Find the call site of c in main.
44     printf ("c(5) returns %d\n", C1);
45     return 0;
46 }
47