blob: 15c88df0d15ee6ff8809cffbefbde1c20dbc6f8d [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +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.
Bill Wendling123374a2009-02-24 02:35:30 +00003// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \
4// RUN: llc --disable-fp-elim -o %t.s -f -fast -relocation-model=pic
Chris Lattner670f4512008-03-10 06:52:10 +00005// RUN: %compile_c %t.s -o %t.o
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006// RUN: %link %t.o -o %t.exe
7// RUN: echo {break DeepStack::deepest\nrun 17\nwhere\n} > %t.in
8// RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \
9// RUN: grep {#0 DeepStack::deepest.*(this=.*,.*x=33)}
10// RUN: gdb -q -batch -n -x %t.in %t.exe | \
11// RUN: grep {#7 0x.* in main.*(argc=\[12\],.*argv=.*)}
12
Anton Korobeynikov9b9e5ea2008-03-09 22:24:03 +000013// Only works on ppc, x86 and x86_64. Should generalize?
Duncan Sandsdcec0442009-01-22 15:07:15 +000014// XFAIL: alpha|ia64|arm
Dan Gohmanf17a25c2007-07-18 16:29:46 +000015
16#include <stdlib.h>
17
18class DeepStack {
19 int seedVal;
20public:
21 DeepStack(int seed) : seedVal(seed) {}
22
23 int shallowest( int x ) { return shallower(x + 1); }
24 int shallower ( int x ) { return shallow(x + 2); }
25 int shallow ( int x ) { return deep(x + 3); }
26 int deep ( int x ) { return deeper(x + 4); }
27 int deeper ( int x ) { return deepest(x + 6); }
28 int deepest ( int x ) { return x + 7; }
29
30 int runit() { return shallowest(seedVal); }
31};
32
33int main ( int argc, char** argv) {
34
35 DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) );
36 return DS9.runit();
37}