• Stars
    star
    1,094
  • Rank 42,362 (Top 0.9 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 5 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

A simple Python debugger and profiler that generates animated visualizations of program flow, useful for algorithm learning.

vardbg

Available on PyPI

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)

Specifying the name of the variable may appear to be redundant, but there are two reasons behind this: reliably parsing all code that defines variables is very hard (there are more possible methods than one might think β€” loops, unpacking, direct assignments, exec calls, etc.), and more than one variable can be declared on a line. For example, tuple unpacking and function arguments are common occurrences of multiple variables being added on a single line. Thus, specifying the variable name in references is mandatory to prevent ambiguity.

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.

More Repositories

1

ccextractor

CCExtractor - Official version maintained by the core team
C
675
star
2

rusty_ffmpeg

FFI bindings for FFmpeg inner libraries.
Rust
164
star
3

rutorrent-flutter

A ruTorrent-based client in Flutter
Dart
127
star
4

taskwarrior-flutter

This is the repo of mobile app of taskwarrior
Dart
109
star
5

Flood_Mobile

GSoC 21' @CCExtractor. A modern mobile UI for various torrent clients with a Node.js backend and Flutter frontend.
Dart
99
star
6

Rekognition

Free and Open Source alternative to Amazon's Rekognition service. CCExtractor Development | Poor Man's Rekognition
Python
96
star
7

ultimate_alarm_clock

Dart
66
star
8

beacon

Flutter application to share location with a group. (under development)
Dart
58
star
9

video2srt

Superfast online transcript generator with FFmpeg/wasm + whisper
Svelte
40
star
10

sample-platform

CCExtractor's Sample & CI platform. Developed during GSoC 2016
Python
24
star
11

ccextractorfluttergui

A cross platform GUI for CCExtractor
Dart
23
star
12

Subtitle-Resync

A tool to automatically generate in-sync subtitles of different versions of the same base media (such as with edits)
C++
23
star
13

Deluge-mobile-remote-client

Deluge Mobile Client developed during GSOC 2021 @CCEXTRACTOR || Note "Please do flutter clean before making any pull request"
Dart
18
star
14

cimico

A python debugger video creator (knightron0's original implementation)
Python
12
star
15

PyBud

A Python tool that generates video visualizations for source code debugging.
Python
10
star
16

beacon-backend

backend for the beacon app, gsoc 2021
JavaScript
8
star
17

ProjectNephos

Recording/processing/uploading system - CCExtractor+Red Hen.
Vue
7
star
18

TDebugger

A advanced python debugger with live tracing.
Python
7
star
19

ccextractor-codein-playground

This is a learning repository for Code-In students to send their first pull requests.
5
star
20

ccextractor-org-media

All media (banners, logos, etc) related to CCExtractor Development.
4
star
21

fastfingers

FastFingers App
C
3
star
22

AZTinyDebug

Python Debugger that creates shareable video logs of a program's execution.
Python
3
star
23

website

www.ccextractor.org
2
star
24

sample-platform-v2

TypeScript
1
star
25

CCExtractorWindowsGUI

Source code for the simple but functional Windows GUI for CCExtractor
C#
1
star
26

show_specific_dictionaries

TV show specific dictionaries, for spelling corrections
1
star
27

ccx_testsuite

A testing tool to keep CCExtractor consistent over coding changes. Developed during GSoC 2014
C#
1
star