| 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 | |
| 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 | |
| 22 | int b(int val) |
| 23 | { |
| 24 | return c(val); |
| 25 | } |
| 26 | |
| 27 | int c(int val) |
| 28 | { |
| 29 | return val + 3; // Find the line number of function "c" here. |
| 30 | } |
| 31 | |
| 32 | void spin_a_bit () { |
| 33 | for (unsigned int i = 0; i < 10; i++) { |
| 34 | printf(format: "Set a breakpoint here, with i = %d.\n" , i); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | int main (int argc, char const *argv[]) |
| 39 | { |
| 40 | int A1 = a(val: 1); // a(1) -> b(1) -> c(1) // Stop here at start of main |
| 41 | printf(format: "a(1) returns %d\n" , A1); |
| 42 | |
| 43 | int B2 = b(val: 2); // b(2) -> c(2) Find the call site of b(2). |
| 44 | printf(format: "b(2) returns %d\n" , B2); |
| 45 | |
| 46 | int A3 = a(val: 3); // a(3) -> c(3) Find the call site of a(3). |
| 47 | printf(format: "a(3) returns %d\n" , A3); |
| 48 | |
| 49 | int C1 = c(val: 5); // Find the call site of c in main. |
| 50 | printf (format: "c(5) returns %d\n" , C1); |
| 51 | |
| 52 | spin_a_bit(); |
| 53 | return 0; |
| 54 | } |
| 55 | |