Skip to main content

Remote debugging with pdb using reverse and direct connections

Project description

Reverse remote debugging with pdb

Allows remote debugging with pdb (Python built-in debugger) by reverse and direct connections to tools like netcat and socat.

Inspired by: https://pypi.org/project/rpdb/

Installation

pip install reverse_pdb

Usage:

Remote reverse debugging

  1. Given this snippet to be debug with pdb
def add_numbers(a, b):
    return a + b
result = add_numbers(3, 5)

breakpoint()

print("The sum is:", result)
  1. Add the following changes
from reverse_pdb import remote_pdb_reverse

def add_numbers(a, b):
    return a + b
result = add_numbers(3, 5)

rdb = remote_pdb_reverse("127.0.0.1", 4444)
rdb.set_trace()

print("The sum is:", result)
  1. Run a netcat listener
nc -vlp 4444
  1. Run your code and interact with pdb from the netcat session

Remote "direct" debugging

  1. Add these changes
from reverse_pdb import remote_pdb

def add_numbers(a, b):
    return a + b
result = add_numbers(3, 5)

rdb = remote_pdb("127.0.0.1", 4444)
rdb.set_trace()

print("The sum is:", result)
  1. Run a netcat client
nc -v localhost 4444
  1. Run your code and interact with pdb from the netcat session

Note:

In the above examples the loopback (127.0.0.1) is used for simplicity, however, any IP/hostname is also valid.

Uses cases

Remote debugging from:

  1. Behind a firewall/NAT
  2. Airflow tasks
  3. Sealed environments like AWS MWAA (AWS managed Airflow)

Author

Ulises ulises.odysseus22@gmail.com

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

reverse_pdb-0.0.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reverse_pdb-0.0.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file reverse_pdb-0.0.1.tar.gz.

File metadata

  • Download URL: reverse_pdb-0.0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for reverse_pdb-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9e629ce9594a84ebbd61a84403c1965684c738b671113535dd308904b116e486
MD5 742380aaa0a07626ec7981f51d30bc7c
BLAKE2b-256 088c761ac5604ad0aa74cda0ea48f13dc8085759e2f26258a6999bd85da99f50

See more details on using hashes here.

File details

Details for the file reverse_pdb-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: reverse_pdb-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.17

File hashes

Hashes for reverse_pdb-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 726a6eaf92b5eeb4c0ea26497b168d66c804f6b7302858c3595356cb0a3ce781
MD5 19701bf67d4c7572ffb1708857f5c40d
BLAKE2b-256 21187f738084d04525a3a9ecab989bced564c271f71989dc0312967423b3934c

See more details on using hashes here.

Supported by

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