blob: b79c0bf9934ac9cfb74a405843af870cb0319a89 [file] [log] [blame]
Reid Spencerea303382006-11-07 07:31:37 +00001// This is a regression test on debug info to make sure that we can get a
2// meaningful stack trace from a C++ program.
Dan Gohman8a3f6442009-12-05 00:02:37 +00003// RUN: %llvmgcc -S -O0 -g %s -o - | \
Dan Gohmanfea1dd02009-08-25 15:38:29 +00004// RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic
Chris Lattner3efa1a72008-03-10 06:52:10 +00005// RUN: %compile_c %t.s -o %t.o
Reid Spencer42e86fb2007-04-15 22:37:04 +00006// RUN: %link %t.o -o %t.exe
7// RUN: echo {break DeepStack::deepest\nrun 17\nwhere\n} > %t.in
Chris Lattner6d1041e2010-01-24 19:13:39 +00008// RN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \
9// RN: grep {#0 DeepStack::deepest.*(this=.*,.*x=33)}
10// RN: gdb -q -batch -n -x %t.in %t.exe | \
11// RN: grep {#7 0x.* in main.*(argc=\[12\],.*argv=.*)}
Chris Lattner6169f852007-05-05 20:50:35 +000012
Daniel Dunbaref80fe12009-08-07 20:50:58 +000013// Only works on ppc (but not apple-darwin9), x86 and x86_64. Should
14// generalize?
Chris Lattner6d1041e2010-01-24 19:13:39 +000015// XAIL: alpha,arm,powerpc-apple-darwin9
Reid Spencer65917882006-11-07 07:58:02 +000016
Reid Spencerea303382006-11-07 07:31:37 +000017#include <stdlib.h>
18
19class DeepStack {
20 int seedVal;
21public:
22 DeepStack(int seed) : seedVal(seed) {}
23
24 int shallowest( int x ) { return shallower(x + 1); }
25 int shallower ( int x ) { return shallow(x + 2); }
26 int shallow ( int x ) { return deep(x + 3); }
27 int deep ( int x ) { return deeper(x + 4); }
28 int deeper ( int x ) { return deepest(x + 6); }
29 int deepest ( int x ) { return x + 7; }
30
31 int runit() { return shallowest(seedVal); }
32};
33
34int main ( int argc, char** argv) {
35
36 DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) );
37 return DS9.runit();
38}