Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Corepoint: generate a core dump the enxt time you meet a given asm instruction (x64 implementation only) #17

Open
GoogleCodeExporter opened this issue Oct 8, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Hi,

We developed in Amadeus a small extension to Google Coredumper to allow to very 
basically mimic gdb's breakpoint on process running in production environment.

The idea is to put a corepoint at time T at a given assembly instruction 
address. Then at a time T + 1, when one thread of the process meets this 
corepoint then a core dump file is generated, with the exact stack frame the 
thread had when it met the corepoint. Corepoints are one-time use only, so you 
can sefely use them in loops.

This is done without performance penalty, except at time T when you put the 
corepoint, and at time T + 1 when you remove the corepoint and you generate the 
core file: we need to completely stop all the threads via ptrace calls.

The implementation is quite basic (x64 only): like gdb, a corepoint is nothing 
more than replacing the original instruction by an interruption 3. This in 
terms generate a SIGTRAP signal handled in the faulty thread (if this signal is 
not masked). Coredumper registers a SIGTRAP signal handler which:
 - stops all threads with ptrace
 - replaces the int3 instruction by the original one
 - moves the saved $rip register to go back one instruction earlier (sizeof(int3) = 1)
 - generates a FRAME struct from the signal handler saved registers
 - generates a core dump file
 - resumes all threads

I guess the same could also be done in x86 or ARM.

The whole git patch is attached. Note that it requires that you generate all 
autotools files with autoreconf --install to build properly.

Cheers,
Romain

Original issue reported on code.google.com by romain.g...@amadeus.com on 19 Mar 2015 at 11:15

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant