Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kmaork/madbg
A fully-featured remote and preemptive debugger for python
https://github.com/kmaork/madbg
attach cli debugger debugger-library ipdb ipython-debugger pdb preemptive pty python python-library remote-debug remote-debugger terminal tty tty-features
Last synced: 2 days ago
JSON representation
A fully-featured remote and preemptive debugger for python
- Host: GitHub
- URL: https://github.com/kmaork/madbg
- Owner: kmaork
- License: mit
- Created: 2019-07-01T18:32:10.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-04T22:08:48.000Z (4 months ago)
- Last Synced: 2024-12-06T22:36:01.837Z (16 days ago)
- Topics: attach, cli, debugger, debugger-library, ipdb, ipython-debugger, pdb, preemptive, pty, python, python-library, remote-debug, remote-debugger, terminal, tty, tty-features
- Language: Python
- Homepage: https://pypi.org/project/madbg/
- Size: 164 KB
- Stars: 263
- Watchers: 5
- Forks: 8
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
# madbg
[![Tests (GitHub Actions)](https://github.com/kmaork/madbg/workflows/Tests/badge.svg)](https://github.com/kmaork/madbg)
[![PyPI Supported Python Versions](https://img.shields.io/pypi/pyversions/madbg.svg)](https://pypi.python.org/pypi/madbg/)
[![PyPI version](https://badge.fury.io/py/madbg.svg)](https://badge.fury.io/py/madbg)
[![GitHub license](https://img.shields.io/github/license/kmaork/madbg)](https://github.com/kmaork/madbg/blob/master/LICENSE.txt)A fully-featured remote debugger for python.
- Provides a full remote tty, allowing sending keyboard signals to the debugger,
tab completion, command history, line editing and more
- Runs the IPython debugger with all its capabilities
- Allows attaching to running programs preemptively (does not require gdb, unlike similar tools)
- Affects the debugged program [minimally](#possible-effects), although not yet recommended for use in production environments
- Provides TTY features even when debugged program is a deamon, or run outside a terminal## Installation
```
pip install madbg
```## Usage
Madbg provide both a python API and a CLI.### Attaching to a running process
```
madbg attach
```
Or
```python
import madbg
madbg.attach_to_process(pid)
```
> **Warning**
> - Attaching on linux could potentially deadlock the target process. Not recommneded for use in production environments yet.
> - `madbg` has to be installed in the target process' interpreter for `attach` to work.### Starting a debugger
#### Using the CLI
Run a python file with automatic post-mortem:
```
madbg run path_to_your_script.py
```
Run a python module similarly to `python -m`:
```
madbg run -m module.name
```
Start a script, starting the debugger from the first line:
```
madbg run --use-set-trace script.py
```#### Using the API
Start a debugger in the next line:
```python
madbg.set_trace()
```
Continue running the program until a client connects, then stop it and start a debugger:
```python
madbg.set_trace_on_connect()
```
After an exception has occurred, or in an exception context, start a debugger in the frame the exception was raised from:
```python
madbg.post_mortem()
```### Connecting to a debugger
#### Using the CLI
```
madbg connect
```#### Using the API
```python
madbg.connect_to_debugger()
```### Connection
All madbg API functions and CLI entry points allow using a custom IP and port (the default is `127.0.0.1:3513`), for example:```python
madbg.set_trace(ip='0.0.0.0', port=1337)
```
or
```
madbg connect 8.8.8.8 1337
```
## PlatformsMadbg supports linux with python>=3.8.
## Possible effects
What madbg does that might affect a debugged program:
- Changes the pgid and sid of the debugged process
- Changes the CTTY of the debugged process
- Affects child processes in unknown ways (Not tested yet)What madbg doesn't do:
- Writes or reads from stdio
- Feeds your cat