1 //===-- main.c --------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 #include <stdio.h>
9 
10 // This simple program is to test the lldb Python API related to frames.
11 
12 int a(int, char);
13 int b(int, char);
14 int c(int, char);
15 
16 int a(int val, char ch)
17 {
18     int my_val = val;
19     char my_ch = ch;
20     printf("a(val=%d, ch='%c')\n", val, ch);
21     if (val <= 1)
22         return b(val+1, ch+1);
23     else if (val >= 3)
24         return c(val+1, ch+1);
25 
26     return val;
27 }
28 
29 int b(int val, char ch)
30 {
31     int my_val = val;
32     char my_ch = ch;
33     printf("b(val=%d, ch='%c')\n", val, ch);
34     return c(val+1, ch+1);
35 }
36 
37 int c(int val, char ch)
38 {
39     int my_val = val;
40     char my_ch = ch;
41     printf("c(val=%d, ch='%c')\n", val, ch);
42     return val + 3 + ch;
43 }
44 
45 int main (int argc, char const *argv[])
46 {
47     int A1 = a(1, 'A');  // a(1, 'A') -> b(2, 'B') -> c(3, 'C')
48     printf("a(1, 'A') returns %d\n", A1);
49 
50     int B2 = b(2, 'B');  // b(2, 'B') -> c(3, 'C')
51     printf("b(2, 'B') returns %d\n", B2);
52 
53     int A3 = a(3, 'A');  // a(3, 'A') -> c(4, 'B')
54     printf("a(3, 'A') returns %d\n", A3);
55 
56     return 0;
57 }
58