Home | History | Annotate | Download | only in stop-hook
      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 #include <stdlib.h>
     11 
     12 int a(int);
     13 int b(int);
     14 int c(int);
     15 
     16 int a(int val)
     17 {
     18     if (val <= 1)
     19         return b(val);
     20     else if (val >= 3)
     21         return c(val);
     22 
     23     return val;
     24 }
     25 
     26 int b(int val)
     27 {
     28     int rc = c(val);
     29     void *ptr = malloc(1024);
     30     if (!ptr)  // Set breakpoint here to test target stop-hook.
     31         return -1;
     32     else
     33         printf("ptr=%p\n", ptr); // We should stop here after stepping.
     34     return rc; // End of the line range for which stop-hook is to be run.
     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);
     45     printf("a(1) returns %d\n", A1);
     46 
     47     int C2 = c(2); // Another breakpoint which is outside of the stop-hook range.
     48     printf("c(2) returns %d\n", C2);
     49 
     50     int A3 = a(3);
     51     printf("a(3) returns %d\n", A3);
     52 
     53     return 0;
     54 }
     55