Karan Jit Singh
Karan Jit Singh

Reputation: 605

Dump process memory on exit linux

I want to dump a process' memory when it exits. All the solutions I've seen using gcore, gdb or even procdump for linux dump the core in the middle of the execution and not exactly when it terminates

Procdump for windows has a very elegant solution for this, i.e. -t will allow procdump to create a dump when the process exits.

I stumbled on to ulimit -c unlimited but this again will only generate dumps for non-graceful exits.

The process I want a dump for can be any process and not exactly my application.

Upvotes: 0

Views: 1516

Answers (1)

Jens Harms
Jens Harms

Reputation: 436

If you want to mimic this behavior with gdb:

Procdump for windows has a very elegant solution for this, i.e. -t will allow procdump to create a dump when the process exits.

First you create a file 'mycommand.txt':

b exit
r
generate-core-file ./core.1
q

Then you start your program with:

 gdb --command mycommand.txt yourprogram 

you will have a file called core.1 in your working directory. Check with:

gdb yourprogram core.1

Upvotes: 1

Related Questions