Skip to main content

vardbg

PyPI version

A simple Python debugger and profiler that generates animated visualizations of program flow. It is meant to help with learning algorithms by allowing you to visualize what the algorithms are doing.

Python 3.6 or newer is required due to the use of f-strings.

This project was created during Google Code-in 2019 for CCExtractor Development.

Demo

Insertion Sort Demo

Features

  • Tracking the history of each variable and its contents
  • Tracking elements within containers (lists, sets, dicts, etc.)
  • Ignoring specific variables
  • Profiling the execution of each line
  • Summarizing all variables and execution times after execution
  • Passing arguments to debugged programs
  • Exporting execution history in JSON format and replaying (including program output)
  • Creating videos that show program flow, execution times, variables (with relationships), and output
  • Writing videos in MP4, GIF, and WebP formats

Installation

The latest tagged version can be obtained from PyPI:

pip install vardbg

Alternatively, one can clone this repository and run it directly after installing dependencies:

git clone https://github.com/CCExtractor/vardbg
cd vardbg
python3 -m venv venv
source venv/bin/activate
pip install poetry
poetry install .
./debug.py

It can also be installed from the repository:

pip install .

The above instructions assume the use of a virtual environment to avoid interfering with the system install of Python.

Usage

All of the debugger's subcommands and options are documented in the usage help, which is readily available on the command line.

For example, this command will debug the function quick_sort from the file sort.py with the arguments 9 3 5 1 and record the session to a JSON file named sort1.json:

vardbg run sort.py quick_sort -o qsort.json -a 9 -a 3 -a 5 -a 1

A video can then be generated from the above recording:

vardbg replay qsort.json -v sort_vis.mp4

It is possible to generate videos live while running the debugged program, but this is discouraged because the overhead of video creation inflates execution times greatly and thus ruins profiler results. However, if profiling is not important to you, it is a valid use case.

Configuration

The video generator has many options: resolution, speed, fonts, and sizes. These options can be modified using a TOML config file. The default config documents the available options, which can be customized in an minimal overlay config without having to duplicate the entire config. The config can then be used by passing the -c argument on the command line.

An example of a simple overlay is the config used to generate official demo videos for embedding in READMEs. This simple config increases the speed (FPS) slightly and adds an intro screen at the beginning of the video.

Behavior Control

Special comments can be added to lines of code that define variables to control how vardbg handles said variable:

  • # vardbg: ignore — do not display this variable or track its values
  • # vardbg: ref lst[i] — treat variable i as the index/key of an element in container lst (only shown in videos)

Contributing

Feel free to contribute to this project! You can add features, fix bugs, or make any other improvements you see fit. We just ask that you follow the code style guidelines to keep the code consistent and coherent. These guidelines can easily be enforced before pushing with the pre-commit framework, which can install Git pre-commit hooks with the pre-commit install command.

Once your contribution meets the guidelines, open a pull request to make things official.

Download files

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

Source Distribution

vardbg-0.11.6.tar.gz (570.4 kB view details)

Uploaded Source

Built Distribution

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

vardbg-0.11.6-py3-none-any.whl (575.1 kB view details)

Uploaded Python 3

File details

Details for the file vardbg-0.11.6.tar.gz.

File metadata

  • Download URL: vardbg-0.11.6.tar.gz
  • Upload date:
  • Size: 570.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.2 CPython/3.8.1 Linux/5.4.14-arch1-1

File hashes

Hashes for vardbg-0.11.6.tar.gz
Algorithm Hash digest
SHA256 771d5a4fa8fe8aae05255e6be5213acf7dd14a5d22df3c7a7e4b312381218c91
MD5 23c2bf49a33b7c1eb3c8d86c5e5f4822
BLAKE2b-256 5695130f7886559849876ac49bd917102008077405c3988f1182c4562a75bf59

See more details on using hashes here.

File details

Details for the file vardbg-0.11.6-py3-none-any.whl.

File metadata

  • Download URL: vardbg-0.11.6-py3-none-any.whl
  • Upload date:
  • Size: 575.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.2 CPython/3.8.1 Linux/5.4.14-arch1-1

File hashes

Hashes for vardbg-0.11.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4ac9464cd68367170ec93c6d3b018c880426e4e85ec1c064614bcaf92b086f26
MD5 1ba760cc6088073737c5254ed4bec82b
BLAKE2b-256 de30d0abad6503c2e4942d37b3d1c67d4119f12b827683d0d1f57dc2a4f33b98

See more details on using hashes here.

Release history Release notifications | RSS feed

0.11.7

2 files

This release

0.11.6 This release

2 files

0.11.5

2 files

0.11.4

2 files

0.11.3

2 files

0.11.2

2 files

0.10.1

2 files

0.9.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page