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
- 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)
- 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)
- Run a netcat listener
nc -vlp 4444
- Run your code and interact with pdb from the netcat session
Remote "direct" debugging
- 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)
- Run a netcat client
nc -v localhost 4444
- 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:
- Behind a firewall/NAT
- Airflow tasks
- Sealed environments like AWS MWAA (AWS managed Airflow)
Author
Ulises ulises.odysseus22@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e629ce9594a84ebbd61a84403c1965684c738b671113535dd308904b116e486
|
|
| MD5 |
742380aaa0a07626ec7981f51d30bc7c
|
|
| BLAKE2b-256 |
088c761ac5604ad0aa74cda0ea48f13dc8085759e2f26258a6999bd85da99f50
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
726a6eaf92b5eeb4c0ea26497b168d66c804f6b7302858c3595356cb0a3ce781
|
|
| MD5 |
19701bf67d4c7572ffb1708857f5c40d
|
|
| BLAKE2b-256 |
21187f738084d04525a3a9ecab989bced564c271f71989dc0312967423b3934c
|