Few targets like the tiny little PIC16 have only 16-bit pointers.
[oota-llvm.git] / test / FrontendC++ / 2006-11-06-StackTrace.cpp
1 // This is a regression test on debug info to make sure that we can get a
2 // meaningful stack trace from a C++ program.
3 // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | llc --disable-fp-elim -o %t.s -f
4 // RUN: %compile_c %t.s -o %t.o
5 // 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=.*)}
11
12 // Only works on ppc, x86 and x86_64.  Should generalize?
13 // FIXME: Un-XFAIL this test for Linux when debug stuff is working again.
14 // XFAIL: alpha|ia64|arm|linux
15
16 #include <stdlib.h>
17
18 class DeepStack {
19   int seedVal;
20 public:
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
33 int main ( int argc, char** argv) {
34
35   DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) );
36   return DS9.runit();
37 }