• Stars
    star
    491
  • Rank 89,050 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created about 8 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Web-based remote UI for Python's PDB debugger

Web-PDB

GitHub Action tests PyPI version

Web-PDB is a web-interface for Python's built-in PDB debugger. It allows to debug Python scripts remotely in a web-browser.

Features

  • Responsive design based on Bootstrap.
  • Python syntax highlighting with Prism ("Okaida" theme).
  • Supports all PDB features.
  • Standard input and output can be redirected to the web-console to interact with Python scripts remotely.
  • Current file box tracks current position in a file being executed. Red line numbers indicate breakpoints, if any.
  • Globals and Locals boxes show local and global variables in the current scope. Special variables that start and end with double underscores __ are excluded (you can always view them using PDB commands).
  • Command history that stores up to 10 last unique PDB commands (accessed by arrow UP/DOWN keys).
Web-PDB screenshot

Web-PDB console in Chrome browser

Usage

Install Web-PDB into your working Python environment:

pip install web-pdb

Insert the following line into your Python program at the point where you want to start debugging:

import web_pdb; web_pdb.set_trace()

The set_trace() call will suspend your program and open a web-UI at the default port 5555 (port value can be changed). Enter in your browser's address bar: http://<your Python machine hostname or IP>:5555, for example http://monty-python:5555, and you should see the web-UI like the one on the preceding screenshot. Now you can use all PDB commands and features. Additional Current file, Globals and Locals information boxes help you better track your program runtime state.

Note: it is strongly recommended to work with the Web-PDB web-UI only in one browser session. With more than one browser window accessing the web-UI it may display incorrect data in one or more browser sessions.

Subsequent set_trace() calls can be used as hardcoded breakpoints.

Web-PDB is compatible with the new breakpoint() function added in Python 3.7. Set environment variable PYTHONBREAKPOINT="web_pdb.set_trace" to launch Web-PDB with breakpoint().

Additionally, Web-PDB provides catch_post_mortem context manager that can catch unhandled exceptions raised within its scope and automatically start PDB post-mortem debugging session. For example:

import web_pdb

with web_pdb.catch_post_mortem():
    # Some error-prone code
    assert foo == bar, 'Oops!'

For more detailed info about the Web-PDB API read docstrings in the ./web_pdb/__init__.py file.

The inspect Command

Web-PDB provides inspect or i command that is not present in the original PDB. This command outputs the list of object's members along with their values. Syntax: inspect <object_name> or i <object_name>.

Special members with names enclosed in double underscores (__) are ignored.

Considerations for Multithreading and Multiprocessing Programs

Multithreading

Web-PDB maintains one debugger instance that traces only one thread. You should not call set_trace() from different threads to avoid race conditions. Each thread needs to be debugged separately one at a time.

Multiprocessing

Each process can have its own debugger instance provided you call set_trace with a different port value for each process. This way you can debug each process in a separate browser tab/window. To simplify this you can use set_trace(port=-1) to select a random port between 32768 and 65536.

Compatibility

  • Python: 3.6+
  • Browsers: Firefox, Chrome (all modern browsers should work)

License

MIT, see LICENSE.txt.

The debugger icon made by Freepik from www.flaticon.com is licensed by CC 3.0 BY.

More Repositories

1

django-tinymce4-lite

TinyMCE 4 editor widget for Django
JavaScript
126
star
2

plugin.video.example

Very simple video plugin for Kodi mediacenter
Python
97
star
3

kodi.web-pdb

Web-based remote Python debugger for Kodi addons
Python
84
star
4

kodi.yatp

Torrent streaming video plugin for Kodi mediacenter
Python
47
star
5

script.module.pyxbmct

A GUI micro-framework for Kodi meidacenter addons
Python
46
star
6

WsgiBoostServer

Python WSGI/HTTP server written in C++
C++
32
star
7

sphinx_tutorial

Tutorial for documenting your Python code with Sphinx
Python
26
star
8

kodi.six

Python
20
star
9

service.addic7ed

Subtitles addon for Kodi Mediacenter
Python
20
star
10

PyXBMCt

A simple GUI framework for Kodi addons
15
star
11

pyxbmct.demo

Python
9
star
12

kodi.tvmaze

TVmaze scraper for Kodi
Python
8
star
13

romans_blog

My Django-based blog CMS
Python
7
star
14

next-episode-kodi

Python
6
star
15

SDLXLIFFlocker

C#
6
star
16

kodi.tvmaze.scrobbler

TV show scrobbler for TVmaze
Python
5
star
17

django-modeltranslation-xliff

XLIFF Exchange extension for django-modeltranslation
Python
4
star
18

py-xliff-converter

Python
4
star
19

kodi_repo

A repository for my Kodi addons
4
star
20

kodistubs-generator

Smarty
4
star
21

kodi.external.library

External Kodi Videolibrary Client
Python
3
star
22

TinyMCE4.spoiler

A spoiler plugin for TinyMCE 4
JavaScript
3
star
23

kodi.remote-pdb

Remote debugger for Kodi Python addons
Python
3
star
24

asyncore-wsgi

Simple asynchronous WSGI/WebSocket server
Python
2
star
25

TinyMCE4-Codesample

Alternative codesample and preview plugins for TinyMCE 4
JavaScript
2
star
26

sphinx-pydocsgen

Python
1
star