Open JeremyRand opened 1 year ago
This is akin to the -k
flag in C strace.
One relatively easy way to implement this is to send SIGABRT to the traced program; it should generate a core dump, which can then be loaded into gdb where the stack and other state can be inspected. (IIRC sending the signal natively will result in a ptrace stop, which will need to be handled to actually deliver the signal). Core dumps will also need to have been enabled by the user (e.g. ulimit -c unlimited
)
This is of course fairly heavy-handed and not the best user experience.
Nice, I can implement both and make it configurable
Dumping the stack trace of the tracee when a leak is detected would be useful for debugging where the leak happened.
For bonus points, support dumping the stack trace of non-C languages too (e.g. I believe Python and Go have straightforward ways to dump a stack trace).