https://github.com/dcramer/pdbinject
A Python utility which uses GDB to inject a telnet-able PDB session into an existing process
https://github.com/dcramer/pdbinject
Last synced: 11 months ago
JSON representation
A Python utility which uses GDB to inject a telnet-able PDB session into an existing process
- Host: GitHub
- URL: https://github.com/dcramer/pdbinject
- Owner: dcramer
- Created: 2013-06-19T18:52:05.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2015-03-04T07:48:16.000Z (over 11 years ago)
- Last Synced: 2025-07-21T15:11:29.408Z (11 months ago)
- Language: Python
- Homepage:
- Size: 199 KB
- Stars: 57
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
Install
=======
You'll need GDB compiled with python support, and the ``pdbinject`` package:
::
easy_install pdbinject
OS X Notes
----------
The default GDB does not come compiled with Python support.
Homebrew fixes that:
::
brew install gdb
.. note:: There's more steps, I gave up on figuring out how to make it work.
Usage
=====
::
$ python example/loop.py &
Process running with PID 6319
$ sudo pdbinject 6319
Remote PDB has been configured on port 4444
nc 127.0.0.1 4444
$ nc 127.0.0.1 4444
--Return--
> /home/ubuntu/pdbinject/pdbinject/debugger.py(16)run()->None
-> debugger.set_trace()
Now have some fun:
::
from guppy import hpy
hp = hpy()
heap = hp.heap()
heap.get_rp()
To print the stacktrace across all the threads:
::
import sys, traceback
for thread_id, stack in sys._current_frames().iteritems(): print 'Thread id: %s\n%s' % (thread_id, ''.join(traceback.format_stack(stack)))