Skip to main content

remote pdb which connects to developer

Project description

pdbme - remote active debugger based on rpdb

This is active fork of https://github.com/tamentis/rpdb.

Rpdb is a wrapper around pdb that re-routes stdin and stdout to a socket handler.

Pdbme is Rpdb, which is active. Which means, that while Rpdb open port and waits until you connect to this port, Pdbme connects to your port.

So, in other words, you open pdbme-cli tool, ask your app "pdb me please" and your app will pdb you :).

Why active?

Rpdb opens debugger pon port (default 4444), but it has many drawbacks. Eg - it cannot be used in mutlithreaded or multiprocessing application. Even in non-parallel app, port can be occupied a little while after closing it and app will break trying to open it again.

Calling your terminal sounds way better way. It's useful when you want to debug app which can break simultaneously more than once in a time, and passive mode will refuse to open port 4444 again.

Solution to the problem is:

# default host is 127.0.0.1 and default port is 4444
import pdbme; pdbme.set_trace()

or, in more complex case, eg. when it's running in other host, in your docker, or sth like that

import pdbme
pdbme.set_trace(host='192.168.1.120', port=12345)

You should have pdbme-cli running on other side of your communication.

pdbme-cli

pdbme-cli is a simple tool, using tmux, tcpwrapper and socat to accept incoming connections and spawn tmux session for each incoming breakpoint.

Installation in CPython (standard Python)

pip install pdbme (not yet on PyPi)

or

pip install git+https://github.com/mahomahomaho/pdbme

Trigger rpdb with signal

set_trace() can be triggered at any time by using the TRAP signal handler. This allows you to debug a running process independantly of a specific failure or breakpoint::

import pdbme
pdbme.handle_trap()

# As with set_trace, you can optionally specify addr and port
rpdb.handle_trap(host="0.0.0.0", port=4441)

Calling handle_trap will overwrite the existing handler for SIGTRAP if one has already been defined in your application.

Author(s)

Łukasz Mach maho@pagema.net - http://pagema.net/

based on work of rpdb author: Bertrand Janin b@janin.com - http://tamentis.com/

and rpdbs contributors: (chronological, latest first):

0.0.1 (2019-06-14)

  • New functionality, new package name, new versioning....
  • dropped some rpdb functionality,

0.1.6 (2015-01-05)

  • Give access to attributes of stdin and stdout (by @fuxpavel).
  • Add rpdb.post_mortem(), similar to pdb.post_mortem() (by @CamDavidsonPilon).

0.1.5 (2014-10-16)

  • Write addr/port to stderr instead of stdout (thanks to @onlynone).
  • Allow for dynamic host port (thanks to @onlynone).
  • Make q/quit do proper cleanup (@kenmanheimer)
  • Benignly disregard repeated rpdb.set_trace() to same port as currently active session (@kenmanheimer)
  • Extend backwards compatibility down to Python 2.5 (@kenmanheimer)

0.1.4 (2014-04-28)

  • Expose the addr, port arguments to the set_trace method (thanks to @niedbalski).

0.1.3 (2013-08-02)

  • Remove a try/finally that seemed to shift the trace location (thanks to k4ml@github).

0.1.2 (2012-01-26)

  • Catch IOError raised by print in initialization, it may not work in some environments (e.g. mod_wsgi). (Menno Smits)

0.1.1 (2010-05-09)

Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdbme-0.0.1.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

pdbme-0.0.1-py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page