strace attaching to already running process

Egor Duda deo@logos-m.ru
Wed Aug 25 02:26:00 GMT 1999


Hi!

  I needed some debugging info from ever-running cygwin daemon, so i've
patched strace a bit to allow it to attach to already running process.
Suppling windows pid of process in a form

strace -o <file> -p <winpid>

will do the job. There's two drawbacks, however, both due to features
of DebugActiveProcess API. First -- when strace exits, debugee exits
too. And second -- '-f' option don't work. Working around second
limitation seems possible, but solution i see is quite ugly -- it
suppose that when debugee starts child processes through fork or
spawn, it'll pass DEBUG_PROCESS flag to CreateProcess, and redirect
all children's debug output to actual strace. But it will require that
debugee must stay alive as long as children are running, so, a bunch of
additional syncronization is needed. Anyway, stracing single running
process seems to work ok.

Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19
strace_by_pid.diff.gz



More information about the Cygwin-developers mailing list