1 | #include <stdio.h> |
2 | |
3 | // This simple program is to test the lldb Python APIs SBTarget, SBFrame, |
4 | // SBFunction, SBSymbol, and SBAddress. |
5 | // |
6 | // When stopped on breakpoint 1, we can get the line entry using SBFrame API |
7 | // SBFrame.GetLineEntry(). We'll get the start address for the line entry |
8 | // with the SBAddress type, resolve the symbol context using the SBTarget API |
9 | // SBTarget.ResolveSymbolContextForAddress() in order to get the SBSymbol. |
10 | // |
11 | // We then stop at breakpoint 2, get the SBFrame, and the SBFunction object. |
12 | // |
13 | // The address from calling GetStartAddress() on the symbol and the function |
14 | // should point to the same address, and we also verify that. |
15 | |
16 | int a(int); |
17 | int b(int); |
18 | int c(int); |
19 | |
20 | int a(int val) |
21 | { |
22 | if (val <= 1) // Find the line number for breakpoint 1 here. |
23 | val = b(val); |
24 | else if (val >= 3) |
25 | val = c(val); |
26 | |
27 | return val; // Find the line number for breakpoint 2 here. |
28 | } |
29 | |
30 | int b(int val) |
31 | { |
32 | return c(val); |
33 | } |
34 | |
35 | int c(int val) |
36 | { |
37 | return val + 3; |
38 | } |
39 | |
40 | int main (int argc, char const *argv[]) |
41 | { |
42 | int A1 = a(val: 1); // a(1) -> b(1) -> c(1) |
43 | printf(format: "a(1) returns %d\n" , A1); |
44 | |
45 | int B2 = b(val: 2); // b(2) -> c(2) |
46 | printf(format: "b(2) returns %d\n" , B2); |
47 | |
48 | int A3 = a(val: 3); // a(3) -> c(3) |
49 | printf(format: "a(3) returns %d\n" , A3); |
50 | |
51 | return 0; |
52 | } |
53 | |