blob: 26f47885e4022ebf2b140e4a2184246fa1455e1d [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.
Reid Spencer42e86fb2007-04-15 22:37:04 +00003// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | llc --disable-fp-elim -o %t.s -f
Chris Lattner3efa1a72008-03-10 06:52:10 +00004// RUN: %compile_c %t.s -o %t.o
Reid Spencer42e86fb2007-04-15 22:37:04 +00005// RUN: %link %t.o -o %t.exe
6// RUN: echo {break DeepStack::deepest\nrun 17\nwhere\n} > %t.in
7// RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \
8// RUN: grep {#0 DeepStack::deepest.*(this=.*,.*x=33)}
9// RUN: gdb -q -batch -n -x %t.in %t.exe | \
10// RUN: grep {#7 0x.* in main.*(argc=\[12\],.*argv=.*)}
Chris Lattner6169f852007-05-05 20:50:35 +000011
Anton Korobeynikov29c8c372008-03-09 22:24:03 +000012// Only works on ppc, x86 and x86_64. Should generalize?
Bill Wendling82c19ae2008-12-18 22:13:31 +000013// XFAIL: alpha|ia64|arm
14
15// FIXME: Un-XFAIL this test when debug stuff is working again.
16// XFAIL: *
Reid Spencer65917882006-11-07 07:58:02 +000017
Reid Spencerea303382006-11-07 07:31:37 +000018#include <stdlib.h>
19
20class DeepStack {
21 int seedVal;
22public:
23 DeepStack(int seed) : seedVal(seed) {}
24
25 int shallowest( int x ) { return shallower(x + 1); }
26 int shallower ( int x ) { return shallow(x + 2); }
27 int shallow ( int x ) { return deep(x + 3); }
28 int deep ( int x ) { return deeper(x + 4); }
29 int deeper ( int x ) { return deepest(x + 6); }
30 int deepest ( int x ) { return x + 7; }
31
32 int runit() { return shallowest(seedVal); }
33};
34
35int main ( int argc, char** argv) {
36
37 DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) );
38 return DS9.runit();
39}