1

When my c++ app crashes I would like to generate stackdump and display dumped register values.

My app runs on Linux.

I would like my program to be able to generate stackdump and display dumped register values when it crashes and the next time the user run's it, it will ask them if it is ok to send these to me so I can track down the problem. I can handle the stacktrace info but I don't know how to generate these two things. Any ideas?

Advance thanks to all repliers

Thank you vlc

vlc
  • 185
  • 2
  • 3
  • 9
  • 1
    [Google's `stacktrace.cc`](http://code.google.com/p/google-perftools/source/browse/trunk/src/) made a big splash when it was introduced a few years ago; I'm not sure if it is still popular, but the header _does_ mention `libunwind`, which is available on my Ubuntu system in package `libunwind7` and `-dev`. – sarnold Apr 09 '11 at 08:14

1 Answers1

1

The answer in this question could be of some use in your case. But the code in the answer prints a stacktrace and registers up on SIGSEGV only. You might have to do some more work to meet your needs.

Community
  • 1
  • 1
vpit3833
  • 7,693
  • 2
  • 24
  • 25
  • Hi vpit, Thanks a lot for your response.You are absolutely right....but i need to print the dumped values of registers and stackdump. I too did printing stacktrace. So,How can i do that in my application without debugger usage. Any ideas??? – vlc Apr 10 '11 at 13:02
  • If the libsigsegv.so is built as mentioned and supplied to your users along with your app, they will see a stacktrace and register status up on SIGSEGV. Your app, while building has to pass `-rdynamic` to gcc. If you expect to crash on other signals besides a SIGSEGV, register a signal handler for those signals as well. There is no need for gdb. I used this code to catch just SIGSEGV because that was the most common exception my program would generate. – vpit3833 Apr 10 '11 at 19:11