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); // thread step-out of malloc into function b. 29 if (!ptr) 30 return -1; 31 else 32 printf("ptr=%p\n", ptr); 33 return rc; // we should reach here after 3 step-over's. 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 B2 = b(2); 47 printf("b(2) returns %d\n", B2); 48 49 int A3 = a(3); 50 printf("a(3) returns %d\n", A3); 51 52 return 0; 53 } 54