Reputation: 85
I would like to know if there is a way we can get backtrace of a crashed process without depending on the core dump in FreeBSD or Linux.
Normally, to get a backtrace of a running process, we run bstack PID_OF_PROCESS
on FreeBSD and pstack PID_OF_PROCESS
on Linux.
But once the process gets crashed we need to depend on core file to get the backtrace, and we do not have the PID too if we want to execute bstack or pstack.
Is there a way like a kernel API or something to get the backtrace of crashed process, without doing a gdb on a core file?
Please let me know if I need to provide an extra info about the query.
Upvotes: 1
Views: 785
Reputation: 4509
You can run your application under gdb and make some macro which will do for example: "where" and "step" commands in the loop. After SIGSEGV this macro/script will stop and then you should be able to see the backtrace of your program. Of course it may take a lot of time to catch the problematic situation.
You can also modify your kernel to show the whole backtrace of user-space app, but it needs some knowledge of kernel API.
Maybe valgrind also could be used for such investigation?
Read man gcc about -fstack-protector also.
By the way - why don't you want to use core dump files?
Upvotes: 1