Home | History | Annotate | Download | only in radar_8638051
      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 demonstrate the capability of the lldb command
     12 // "breakpoint command add" to add a set of commands to a breakpoint to be
     13 // executed when the breakpoint is hit.
     14 //
     15 // In particular, we want to break within c(), but only if the immediate caller
     16 // is a().
     17 
     18 int a(int);
     19 int b(int);
     20 int c(int);
     21 
     22 int a(int val)
     23 {
     24     if (val <= 1)
     25         return b(val);
     26     else if (val >= 3)
     27         return c(val); // Find the line number where c's parent frame is a here.
     28 
     29     return val;
     30 }
     31 
     32 int b(int val)
     33 {
     34     return c(val);
     35 }
     36 
     37 int c(int val)
     38 {
     39     return val + 3;
     40 }
     41 
     42 int main (int argc, char const *argv[])
     43 {
     44     int A1 = a(1);  // a(1) -> b(1) -> c(1)
     45     printf("a(1) returns %d\n", A1);
     46 
     47     int B2 = b(2);  // b(2) -> c(2)
     48     printf("b(2) returns %d\n", B2);
     49 
     50     int A3 = a(3);  // a(3) -> c(3)
     51     printf("a(3) returns %d\n", A3);
     52 
     53     return 0;
     54 }
     55