Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use gdb to catch "exit" of a program

Tags:

gdb

I am debugging a rather complex project, I have its source code, currently I need to know the stack trace when daemon exits in certain case, but it is very time consuming to go through the whole code, I want to use gdb to help on this, but commands like "catch exit" won't work, it told me that "Catch of exit not yet implemented", so can anyone tell me how to use gdb to catch the exit event of a daemon? Thank you.

like image 823
wangshuaijie Avatar asked Jun 11 '12 10:06

wangshuaijie


2 Answers

(gdb) catch syscall 60
Catchpoint 3 (syscall 'exit' [60])
(gdb) catch syscall 231
Catchpoint 4 (syscall 'exit_group' [231])
like image 122
Flimm Avatar answered Nov 15 '22 09:11

Flimm


I think just setting breakpoints for exit, _exit, and abort should get you pretty far.

like image 20
acm Avatar answered Nov 15 '22 08:11

acm