Pregunta

I'm ptracing a multithreaded application and 9 out of 10 times, the breakpointhandling works just fine, but sometimes i get a SIGCHLD event instead of SIGTRAP.

This is the sequence:

  • application is running, main thread hits INT3
  • debugger's waitpid returns SIGTRAP
  • debugger SIGSTOPs all threads that are not already "t (tracing stop)", using tgkill
  • debugger runs ptrace(PTRACE_SINGLESTEP) on INT3'ed thread (after fixing RIP and 0xCC byte)
  • debugger waitpid's and expects SIGTRAP, but gets SIGCHLD instead

What am I supposed to do with this SIGCHILD? Ignoring it makes the debugger stuck forever in following waitpids. Injecting it back into the debugee with PTRACE_CONT screws with the initial PTRACE_SINGLESTEP.

It seems that it is happening only for main threads (PID==TID), not for childthreads (aka LWP).

I'm using UBUNTU 12.04 64bit in virtual box.

¿Fue útil?

Solución

Injecting SIGCHLD with PTRACE_SINGLESTEP (data param) back into debugee seems todo the trick.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top