Rabinarayan Panigrahi
Rabinarayan Panigrahi

Reputation: 181

collect /proc/<pid> information of process during process crash in linux

I am trying to collect some proc file system info of a process during panic. is there any way like script or any program which help to collection those info and put some directory of system.

The reason why i asked is understand post analysis of process panic.

Upvotes: 1

Views: 109

Answers (1)

xhienne
xhienne

Reputation: 6144

Use gdb, it will stop at the moment your app crashes and you will get a prompt. You will then be able to:

  • examine the call stack, the variables, the memory,... It will be especially useful if you have access to the sources and if you added debugging information during compilation
  • start a shell in order to examine the content of /proc/<pid>

Typical example:

$ gdb -ex 'run arg1 arg2 ... argN' faulty_app
(...)
Program received signal SIGSEGV, Segmentation fault.
0x000055555555513d in faulty_func ()

(gdb) (... do some stuff like e.g. backtrace ...)

(gdb) p (int)getpid()
$2 = 2993764

(gdb) !bash

$ cd /proc/2993764
(... do some stuff ...)

$ exit
exit

(gdb) quit
A debugging session is active.

    Inferior 1 [process 2993764] will be killed.

Quit anyway? (y or n) y

Upvotes: 1

Related Questions