2006-11-06-StackTrace.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 | \
  4. // RUN: llc --disable-fp-elim -o %t.s -f -O0 -relocation-model=pic
  5. // RUN: %compile_c %t.s -o %t.o
  6. // RUN: %link %t.o -o %t.exe
  7. // RUN: echo {break DeepStack::deepest\nrun 17\nwhere\n} > %t.in
  8. // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \
  9. // RUN: grep {#0 DeepStack::deepest.*(this=.*,.*x=33)}
  10. // RUN: gdb -q -batch -n -x %t.in %t.exe | \
  11. // RUN: grep {#7 0x.* in main.*(argc=\[12\],.*argv=.*)}
  12. // Only works on ppc, x86 and x86_64. Should generalize?
  13. // XFAIL: alpha|ia64|arm
  14. #include <stdlib.h>
  15. class DeepStack {
  16. int seedVal;
  17. public:
  18. DeepStack(int seed) : seedVal(seed) {}
  19. int shallowest( int x ) { return shallower(x + 1); }
  20. int shallower ( int x ) { return shallow(x + 2); }
  21. int shallow ( int x ) { return deep(x + 3); }
  22. int deep ( int x ) { return deeper(x + 4); }
  23. int deeper ( int x ) { return deepest(x + 6); }
  24. int deepest ( int x ) { return x + 7; }
  25. int runit() { return shallowest(seedVal); }
  26. };
  27. int main ( int argc, char** argv) {
  28. DeepStack DS9( (argc > 1 ? atoi(argv[1]) : 0) );
  29. return DS9.runit();
  30. }