[WAY OT] how to gdb a running process *non-intrusively*??

Gilboa Davara gilboad at gmail.com
Thu Apr 17 12:31:24 UTC 2008


On Thu, 2008-04-17 at 03:25 -0700, Robert P. J. Day wrote:
> sorry for the massively OT post but it's 3:30 am where i am, and i'd
> like to figure this out in the next hour or two.  how can i use "gdb"
> to debug a currently running process *non-intrusively* -- i.e.,
> without attaching to it which causes it to stop, even briefly?  i
> could have sworn there was a way to do that, but my memory is failing
> me at the moment.

AFAIK the only possible way of doing it is:

$ gdb /path/to/prog --pid=$(pgrep prog_name) --eval-command=cont

> 
>   assume i have a symbol-laden copy of the executable, and that all i
> want to do is, in real time, print variable contents as the process
> continues to run with no interference of the process itself.  thanks
> muchly.

... Here's the problem.
If you want gdb to actually do some work (evaluate something, etc),
you'll need to interrupt (Ctrl-C), and suspend the running process.

I don't believe I ever saw a debugger that was capable of passively
evaluating symbols on the fly without suspending the debugged process.
(Plus, an active process will most likely change stack frames making it
impossible to evaluate non-global symbols)

> 
> rday
> --

- Gilboa




More information about the fedora-list mailing list