brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · d5f8ceb Raw
53 lines · c
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 API7// SBFrame.GetLineEntry().  We'll get the start address for the line entry8// with the SBAddress type, resolve the symbol context using the SBTarget API9// 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 function14// should point to the same address, and we also verify that.15 16int a(int);17int b(int);18int c(int);19 20int 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 30int b(int val)31{32    return c(val);33}34 35int c(int val)36{37    return val + 3;38}39 40int main (int argc, char const *argv[])41{42    int A1 = a(1);  // a(1) -> b(1) -> c(1)43    printf("a(1) returns %d\n", A1);44    45    int B2 = b(2);  // b(2) -> c(2)46    printf("b(2) returns %d\n", B2);47    48    int A3 = a(3);  // a(3) -> c(3)49    printf("a(3) returns %d\n", A3);50    51    return 0;52}53