Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 |
Chris Lattner | 670f451 | 2008-03-10 06:52:10 +0000 | [diff] [blame^] | 4 | // RUN: %compile_c %t.s -o %t.o |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 | |
Anton Korobeynikov | 9b9e5ea | 2008-03-09 22:24:03 +0000 | [diff] [blame] | 12 | // Only works on ppc, x86 and x86_64. Should generalize? |
| 13 | // XFAIL: alpha|ia64|arm |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 14 | |
| 15 | #include <stdlib.h> |
| 16 | |
| 17 | class DeepStack { |
| 18 | int seedVal; |
| 19 | public: |
| 20 | DeepStack(int seed) : seedVal(seed) {} |
| 21 | |
| 22 | int shallowest( int x ) { return shallower(x + 1); } |
| 23 | int shallower ( int x ) { return shallow(x + 2); } |
| 24 | int shallow ( int x ) { return deep(x + 3); } |
| 25 | int deep ( int x ) { return deeper(x + 4); } |
| 26 | int deeper ( int x ) { return deepest(x + 6); } |
| 27 | int deepest ( int x ) { return x + 7; } |
| 28 | |
| 29 | int runit() { return shallowest(seedVal); } |
| 30 | }; |
| 31 | |
| 32 | int main ( int argc, char** argv) { |
| 33 | |
| 34 | DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) ); |
| 35 | return DS9.runit(); |
| 36 | } |