1002e8696020f084ce9425ff833099e9346454f2dJohnny Chen//===-- main.c --------------------------------------------------*- C++ -*-===// 2002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// 3002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// The LLVM Compiler Infrastructure 4002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// 5002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// This file is distributed under the University of Illinois Open Source 6002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// License. See LICENSE.TXT for details. 7002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// 8002e8696020f084ce9425ff833099e9346454f2dJohnny Chen//===----------------------------------------------------------------------===// 9002e8696020f084ce9425ff833099e9346454f2dJohnny Chen#include <stdio.h> 10002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 11002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// This simple program is to test the lldb Python API SBSymbolContext. 12002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// When stopped on a frame, we can get the symbol context using the SBFrame API 13002e8696020f084ce9425ff833099e9346454f2dJohnny Chen// SBFrame.GetSymbolContext(). 14002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 15002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint a(int); 16002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint b(int); 17002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint c(int); 18002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 19002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint a(int val) 20002e8696020f084ce9425ff833099e9346454f2dJohnny Chen{ 21002e8696020f084ce9425ff833099e9346454f2dJohnny Chen if (val <= 1) 22002e8696020f084ce9425ff833099e9346454f2dJohnny Chen return b(val); 23002e8696020f084ce9425ff833099e9346454f2dJohnny Chen else if (val >= 3) 24002e8696020f084ce9425ff833099e9346454f2dJohnny Chen return c(val); 25002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 26002e8696020f084ce9425ff833099e9346454f2dJohnny Chen return val; 27002e8696020f084ce9425ff833099e9346454f2dJohnny Chen} 28002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 29002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint b(int val) 30002e8696020f084ce9425ff833099e9346454f2dJohnny Chen{ 31002e8696020f084ce9425ff833099e9346454f2dJohnny Chen return c(val); 32002e8696020f084ce9425ff833099e9346454f2dJohnny Chen} 33002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 34002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint c(int val) 35002e8696020f084ce9425ff833099e9346454f2dJohnny Chen{ 36002e8696020f084ce9425ff833099e9346454f2dJohnny Chen return val + 3; // Find the line number of function "c" here. 37002e8696020f084ce9425ff833099e9346454f2dJohnny Chen} 38002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 39002e8696020f084ce9425ff833099e9346454f2dJohnny Chenint main (int argc, char const *argv[]) 40002e8696020f084ce9425ff833099e9346454f2dJohnny Chen{ 41002e8696020f084ce9425ff833099e9346454f2dJohnny Chen int A1 = a(1); // a(1) -> b(1) -> c(1) 42002e8696020f084ce9425ff833099e9346454f2dJohnny Chen printf("a(1) returns %d\n", A1); 43002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 44002e8696020f084ce9425ff833099e9346454f2dJohnny Chen int B2 = b(2); // b(2) -> c(2) 45002e8696020f084ce9425ff833099e9346454f2dJohnny Chen printf("b(2) returns %d\n", B2); 46002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 47002e8696020f084ce9425ff833099e9346454f2dJohnny Chen int A3 = a(3); // a(3) -> c(3) 48002e8696020f084ce9425ff833099e9346454f2dJohnny Chen printf("a(3) returns %d\n", A3); 49002e8696020f084ce9425ff833099e9346454f2dJohnny Chen 50002e8696020f084ce9425ff833099e9346454f2dJohnny Chen return 0; 51002e8696020f084ce9425ff833099e9346454f2dJohnny Chen} 52