1 //===-- main.c --------------------------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 #include <stdio.h> 9 #include <stdlib.h> 10 11 int a(int); 12 int b(int); 13 int c(int); 14 15 int a(int val) 16 { 17 if (val <= 1) 18 return b(val); 19 else if (val >= 3) 20 return c(val); 21 22 return val; 23 } 24 25 int b(int val) 26 { 27 int rc = c(val); 28 void *ptr = malloc(1024); 29 if (!ptr) // Set breakpoint here to test target stop-hook. 30 return -1; 31 else 32 printf("ptr=%p\n", ptr); // We should stop here after stepping. 33 return rc; // End of the line range for which stop-hook is to be run. 34 } 35 36 int c(int val) 37 { 38 return val + 3; 39 } 40 41 int main (int argc, char const *argv[]) 42 { 43 int A1 = a(1); 44 printf("a(1) returns %d\n", A1); 45 46 int C2 = c(2); // Another breakpoint which is outside of the stop-hook range. 47 printf("c(2) returns %d\n", C2); 48 49 int A3 = a(3); 50 printf("a(3) returns %d\n", A3); 51 52 return 0; 53 } 54