1

My C++ application is giving me some strange output but it runs to completion, I'd like to examine the stack trace but since it isn't segfaulting it is harder to pinpoint where it is. I've tried setting break points on exit, _exit, and abort, but when I call the stack I get something like this

#0  0x00002aaaab1a7620 in exit () from /lib64/libc.so.6
#1  0x000000000041f19e in main ()

This is probably because my application has a perl front end wrapped with sig, is there another way to generate a stack upon completion?

liquid
  • 111
  • 1
  • 12
  • Your call stack simply means no one called `exit()` until `0x0411f19e` in `main()`. If you question the curiously-omitted "strange output" perhaps you should interactively debug the process. – WhozCraig Feb 11 '14 at 15:41
  • 1
    What strange output? Maybe knowing this would suggest an appropriate place to place a breakpoint. – ikegami Feb 11 '14 at 17:49
  • Possible duplicate of [GDB - how to find out from where program exited](https://stackoverflow.com/questions/6376869/gdb-how-to-find-out-from-where-program-exited) – Ciro Santilli OurBigBook.com Sep 08 '17 at 09:50

2 Answers2

2

That's what the stack trace should look like. main calls exit at the end and you print the stack trace inside exit. You cannot find where something happens with a stack trace. Once you find where something happens, you can get the stack trace there and find out how the execution got there.

Whatever output you're looking for happened before exit and that function has already returned by the time you get the stack trace. So, you need to put your break point before the output happens. Then you can go over the code line by line to find out which line does the output.

eerorika
  • 232,697
  • 12
  • 197
  • 326
1

did you build it in debug?

  • add a breakpoint with "b function_name"
  • press c to continue
  • type bt to print the backtrace
Syl
  • 2,733
  • 2
  • 17
  • 20