How to get the main dump from a stopped program (linux)

I have a program that has been stopped on kill -STOP. I want to take a basic dump without starting it (the program must be stopped for the whole time, if it receives SIGCONT, it will die without a coredump). How can i get coredump?

Is it possible to keep the program in its current state after taking coredump? This is a very rare situation, and I cannot reproduce it, but I must analyze it.

thank

UPDATES: gcore does not work. Gdb (even root) cannot connect to a stopped process (waiting for ptrace PTRACE_ATTACH forever). Even dd cannot read from / proc / 99999 / mem with good offsets from / proc / 99999 / maps (error No such process).

If I try to connect gdb to process and send SIGCONT to stop the process, I got

path... linux-nat.c:####: internal-error: linux_nat_attach: Assertion `pid == GET_PID (inferior_ptid) && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

If I go to gdb and save the kernel, it will be corrupted. Msgstr "Error reading valid image of object file from memory."

+3
source share
2 answers

Join the current process with gdband run the command generate-core-file.

Or you can start gcoreand specify the process identifier as a parameter.

+6
source

Send the ABRT signal to the process while it is stopped, then restart it with CONT. It resets the core and is interrupted.

, - , /proc/ [pid]/mem, , .

0

Source: https://habr.com/ru/post/1789014/


All Articles