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 | 6591788 | 2006-11-07 07:58:02 +0000 | [diff] [blame^] | 3 | // RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | llc -o Output/StackTrace.s -f |
| 4 | // RUN: gcc -g Output/StackTrace.s -o Output/StackTrace.exe -lstdc++ |
| 5 | // RUN: ( echo "break DeepStack::deepest"; echo "run 17" ; echo "where" ) > Output/StackTrace.gdbin |
| 6 | // RUN: gdb -q -batch -n -x Output/StackTrace.gdbin Output/StackTrace.exe | tee Output/StackTrace.out | grep '#0 DeepStack::deepest (this=.*,x=33)' |
| 7 | // RUN: gdb -q -batch -n -x Output/StackTrace.gdbin Output/StackTrace.exe | grep '#7 0x.* in main(argc=1, argv=.*)' |
| 8 | |
Reid Spencer | ea30338 | 2006-11-07 07:31:37 +0000 | [diff] [blame] | 9 | |
| 10 | #include <stdlib.h> |
| 11 | |
| 12 | class DeepStack { |
| 13 | int seedVal; |
| 14 | public: |
| 15 | DeepStack(int seed) : seedVal(seed) {} |
| 16 | |
| 17 | int shallowest( int x ) { return shallower(x + 1); } |
| 18 | int shallower ( int x ) { return shallow(x + 2); } |
| 19 | int shallow ( int x ) { return deep(x + 3); } |
| 20 | int deep ( int x ) { return deeper(x + 4); } |
| 21 | int deeper ( int x ) { return deepest(x + 6); } |
| 22 | int deepest ( int x ) { return x + 7; } |
| 23 | |
| 24 | int runit() { return shallowest(seedVal); } |
| 25 | }; |
| 26 | |
| 27 | int main ( int argc, char** argv) { |
| 28 | |
| 29 | DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) ); |
| 30 | return DS9.runit(); |
| 31 | } |