1 | #include <stdio.h> |
2 | #include <stdlib.h> |
3 | |
4 | int a(int); |
5 | int b(int); |
6 | int c(int); |
7 | |
8 | int a(int val) |
9 | { |
10 | if (val <= 1) |
11 | return b(val); |
12 | else if (val >= 3) |
13 | return c(val); |
14 | |
15 | return val; |
16 | } |
17 | |
18 | int b(int val) |
19 | { |
20 | int rc = c(val); |
21 | void *ptr = malloc(size: 1024); |
22 | if (!ptr) // Set breakpoint here to test target stop-hook. |
23 | return -1; |
24 | else |
25 | printf(format: "ptr=%p\n" , ptr); // We should stop here after stepping. |
26 | return rc; // End of the line range for which stop-hook is to be run. |
27 | } |
28 | |
29 | int c(int val) |
30 | { |
31 | return val + 3; |
32 | } |
33 | |
34 | int main (int argc, char const *argv[]) |
35 | { |
36 | int A1 = a(val: 1); |
37 | printf(format: "a(1) returns %d\n" , A1); |
38 | |
39 | int C2 = c(val: 2); // Another breakpoint which is outside of the stop-hook range. |
40 | printf(format: "c(2) returns %d\n" , C2); |
41 | |
42 | int A3 = a(val: 3); |
43 | printf(format: "a(3) returns %d\n" , A3); |
44 | |
45 | return 0; |
46 | } |
47 | |