1 // This is a test for complicated stack traces.
2 //
3 // - In deep-A.vgtest, the stack trace is larger than the asked-for depth
4 //   (12 vs. 8) so not all of the trace is shown.
5 // - In deep-B.vgtest, we have --alloc-fn=a6..a12, which means that get_XCon
6 //   needs to redo the IP getting, because 7 functions get removed from the
7 //   trace, which is more than the initial overestimate of 3.
8 // - In deep-C.vgtest, we have --alloc-fn=a3..a12, which means that get_XCon
9 //   ends up with an empty stack trace after removing all the alloc-fns.
10 //   It then redoes it.
11 // - In deep-D.vgtest, we have --alloc-fn=main..a12, which means we have a
12 //   stack trace with a single "(below main)" entry.
13 
14 #include <stdlib.h>
15 
a12(int n)16 void a12(int n) { malloc(n); }
a11(int n)17 void a11(int n) { a12(n); }
a10(int n)18 void a10(int n) { a11(n); }
a9(int n)19 void a9 (int n) { a10(n); }
a8(int n)20 void a8 (int n) { a9 (n); }
a7(int n)21 void a7 (int n) { a8 (n); }
a6(int n)22 void a6 (int n) { a7 (n); }
a5(int n)23 void a5 (int n) { a6 (n); }
a4(int n)24 void a4 (int n) { a5 (n); }
a3(int n)25 void a3 (int n) { a4 (n); }
a2(int n)26 void a2 (int n) { a3 (n); }
a1(int n)27 void a1 (int n) { a2 (n); }
28 
main(void)29 int main(void)
30 {
31    int i;
32 
33    // This one exceeds the default --depth.
34    for (i = 0; i < 10; i++)
35       a1(400);    // divisible by 16 -- no slop
36 
37    return 0;
38 }
39