Reid Spencer | ea30338 | 2006-11-07 07:31:37 +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. |
Reid Spencer | 42e86fb | 2007-04-15 22:37:04 +0000 | [diff] [blame] | 3 | // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | llc --disable-fp-elim -o %t.s -f |
| 4 | // RUN: as %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=.*)} |
Jeff Cohen | 0036100 | 2007-04-04 22:07:44 +0000 | [diff] [blame] | 11 | // XFAIL: i[1-9]86|alpha|ia64|arm|x86_64 |
Reid Spencer | 6591788 | 2006-11-07 07:58:02 +0000 | [diff] [blame] | 12 | |
Reid Spencer | ea30338 | 2006-11-07 07:31:37 +0000 | [diff] [blame] | 13 | #include <stdlib.h> |
| 14 | |
| 15 | class DeepStack { |
| 16 | int seedVal; |
| 17 | public: |
| 18 | DeepStack(int seed) : seedVal(seed) {} |
| 19 | |
| 20 | int shallowest( int x ) { return shallower(x + 1); } |
| 21 | int shallower ( int x ) { return shallow(x + 2); } |
| 22 | int shallow ( int x ) { return deep(x + 3); } |
| 23 | int deep ( int x ) { return deeper(x + 4); } |
| 24 | int deeper ( int x ) { return deepest(x + 6); } |
| 25 | int deepest ( int x ) { return x + 7; } |
| 26 | |
| 27 | int runit() { return shallowest(seedVal); } |
| 28 | }; |
| 29 | |
| 30 | int main ( int argc, char** argv) { |
| 31 | |
| 32 | DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) ); |
| 33 | return DS9.runit(); |
| 34 | } |