1 | #include <stdio.h> |
2 | |
3 | // This simple program is to demonstrate the capability of the lldb command |
4 | // "breakpoint command add" to add a set of commands to a breakpoint to be |
5 | // executed when the breakpoint is hit. |
6 | // |
7 | // In particular, we want to break within c(), but only if the immediate caller |
8 | // is a(). |
9 | |
10 | int a(int); |
11 | int b(int); |
12 | int c(int); |
13 | |
14 | int a(int val) |
15 | { |
16 | if (val <= 1) |
17 | return b(val); |
18 | else if (val >= 3) |
19 | return c(val); // Find the line number where c's parent frame is a here. |
20 | |
21 | return val; |
22 | } |
23 | |
24 | int b(int val) |
25 | { |
26 | return c(val); |
27 | } |
28 | |
29 | int c(int val) |
30 | { |
31 | return val + 3; |
32 | } |
33 | |
34 | int main (int argc, char const *argv[]) |
35 | { |
36 | int A1 = a(val: 1); // a(1) -> b(1) -> c(1) |
37 | printf(format: "a(1) returns %d\n" , A1); |
38 | |
39 | int B2 = b(val: 2); // b(2) -> c(2) |
40 | printf(format: "b(2) returns %d\n" , B2); |
41 | |
42 | int A3 = a(val: 3); // a(3) -> c(3) |
43 | printf(format: "a(3) returns %d\n" , A3); |
44 | |
45 | return 0; |
46 | } |
47 | |