Johnny Chen | d5f66fc | 2010-12-23 01:12:19 +0000 | [diff] [blame] | 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 related to frames. |
| 12 | |
| 13 | int a(int, char); |
| 14 | int b(int, char); |
| 15 | int c(int, char); |
| 16 | |
| 17 | int a(int val, char ch) |
| 18 | { |
| 19 | int my_val = val; |
| 20 | char my_ch = ch; |
| 21 | printf("a(val=%d, ch='%c')\n", val, ch); |
| 22 | if (val <= 1) |
Johnny Chen | 7ad4ac4 | 2011-01-10 17:44:08 +0000 | [diff] [blame] | 23 | return b(val+1, ch+1); |
Johnny Chen | d5f66fc | 2010-12-23 01:12:19 +0000 | [diff] [blame] | 24 | else if (val >= 3) |
Johnny Chen | 7ad4ac4 | 2011-01-10 17:44:08 +0000 | [diff] [blame] | 25 | return c(val+1, ch+1); |
Johnny Chen | d5f66fc | 2010-12-23 01:12:19 +0000 | [diff] [blame] | 26 | |
| 27 | return val; |
| 28 | } |
| 29 | |
| 30 | int b(int val, char ch) |
| 31 | { |
| 32 | int my_val = val; |
| 33 | char my_ch = ch; |
| 34 | printf("b(val=%d, ch='%c')\n", val, ch); |
Johnny Chen | 7ad4ac4 | 2011-01-10 17:44:08 +0000 | [diff] [blame] | 35 | return c(val+1, ch+1); |
Johnny Chen | d5f66fc | 2010-12-23 01:12:19 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | int c(int val, char ch) |
| 39 | { |
| 40 | int my_val = val; |
| 41 | char my_ch = ch; |
| 42 | printf("c(val=%d, ch='%c')\n", val, ch); |
| 43 | return val + 3 + ch; |
| 44 | } |
| 45 | |
| 46 | int main (int argc, char const *argv[]) |
| 47 | { |
| 48 | int A1 = a(1, 'A'); // a(1, 'A') -> b(2, 'B') -> c(3, 'C') |
| 49 | printf("a(1, 'A') returns %d\n", A1); |
| 50 | |
| 51 | int B2 = b(2, 'B'); // b(2, 'B') -> c(3, 'C') |
| 52 | printf("b(2, 'B') returns %d\n", B2); |
| 53 | |
| 54 | int A3 = a(3, 'A'); // a(3, 'A') -> c(4, 'B') |
| 55 | printf("a(3, 'A') returns %d\n", A3); |
| 56 | |
| 57 | return 0; |
| 58 | } |