1 //===-- main.c --------------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include <stdio.h>
10
11 // This simple program is to test the lldb Python API SBTarget.
12 //
13 // When stopped on breakppint 1, and then 2, we can get the line entries using
14 // SBFrame API SBFrame.GetLineEntry(). We'll get the start addresses for the
15 // two line entries; with the start address (of SBAddress type), we can then
16 // resolve the symbol context using the SBTarget API
17 // SBTarget.ResolveSymbolContextForAddress().
18 //
19 // The two symbol context should point to the same symbol, i.e., 'a' function.
20
21 char my_global_var_of_char_type = 'X'; // Test SBTarget.FindGlobalVariables(...).
22
23 int a(int);
24 int b(int);
25 int c(int);
26
a(int val)27 int a(int val)
28 {
29 if (val <= 1) // Find the line number for breakpoint 1 here.
30 val = b(val);
31 else if (val >= 3)
32 val = c(val);
33
34 return val; // Find the line number for breakpoint 2 here.
35 }
36
b(int val)37 int b(int val)
38 {
39 return c(val);
40 }
41
c(int val)42 int c(int val)
43 {
44 return val + 3;
45 }
46
main(int argc,char const * argv[])47 int main (int argc, char const *argv[])
48 {
49 int A1 = a(1); // a(1) -> b(1) -> c(1)
50 printf("a(1) returns %d\n", A1);
51
52 int B2 = b(2); // b(2) -> c(2)
53 printf("b(2) returns %d\n", B2);
54
55 int A3 = a(3); // a(3) -> c(3)
56 printf("a(3) returns %d\n", A3);
57
58 return 0;
59 }
60