Skip to main content

The Debug Adapter Protocol (DAP) implementation for the ipdb debugger.

Project description

ipdab

A Debug Adapter Protocol (DAP) for the Python pdb and ipdb debuggers. Debugpy is the reference implementation of a DAP for Python. The DAP allow your IDE to communicate with the debugger in a standardised way.

The good, old Python debuggers pdb and ipdb debugger were considered incompatible with the DAP as you control the debugger from the terminal, and not from your IDE. The aim of ipdab is to implement the DAP to these debuggers to the extent possible, and get create a debugging experience that some would consider to have the best of both world:

  • You control the debugger from the terminal
  • Your IDE is able to track the debugger, e.g., by indicating the current line with an arrow.

How it works

In addition to starting the pdb or ipdb debugger, ipdab starts server whenever you use set_trace. Any IDE that supports the DAP can connect to this server to track progress of the debugger, retrieve variable values, retrieve the stack trace etc.

Note that it's not possible to control the debugger from your IDE. This is a technical limitation of the pdb and ipdb debugger. They give control to the user every time you see a command prompt. At such a point, the DAP server cannot inject any commands as it doesn't control the terminal in which the debugger runs. Controlling the debugger should be done from the terminal itself.

Installation

pip install ipdab

Or, clone the repository and install with:

pip install -e .

Usage

Just like ipdb, use ipdab in the code you want to debug:

print("Hello, world!")
print("Starting ipdab...")

import ipdab

ipdab.set_trace()

print("This will be debugged.")

Now, connect your IDE to the DAP server started by ipdab.

Neovim

In Neovim, this could work by adding an extry entry to your dap.adapters and dap.configurations:

local dap = require "dap"

-- Custom DAP adapter for ipdb
dap.adapters.ipdb = {
  type = "server",
  host = "127.0.0.1",
  port = 9000,
}

-- Attach config — does not launch, just connects
dap.configurations.python = dap.configurations.python or {}
table.insert(dap.configurations.python, {
  name = "Attach to ipdb",
  type = "ipdb",
  request = "launch", -- <-- important to say launch here!
  program = "${file}",
  justMyCode = false,
  cwd = vim.fn.getcwd(),
})

Then, start your Python script any way you want, e,g., with python your_script.py or ipython -i your_script.py. When the execution hits the ipdab.set_trace() line, the DAP server will start and you can connect to it from Neovim with :lua require'dap'.continue().

VS Code

Should work similar to Neovim, not tested yet.

TODO

  • Test on slower hardware

    • It seems that dapuit is timing out
    • Try to start it with fewer windows
  • Cleanup the repo

  • Create a Neovim plugin

  • Write a blog post about debugging

  • Connect pdb backend in addition to ipdb backend

  • Fix compatiblity with ipython 9.1.0 and higher, entering the debugger seems to break

  • Check how ipdab works with module reloads

  • Consider post mortem support

Project details


Download files

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

Source Distribution

ipdab-25.8.4.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

ipdab-25.8.4-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file ipdab-25.8.4.tar.gz.

File metadata

  • Download URL: ipdab-25.8.4.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ipdab-25.8.4.tar.gz
Algorithm Hash digest
SHA256 f65c810f5c803698bcc18b559ecd9dfb21866a0fce9a2b4f9b253e2b03cd91a7
MD5 5d5003df1203729e01389de57bfc3de7
BLAKE2b-256 e28b211c30711e9188a75b007b2553adff41fd260ca47170d00d3e25c11e70b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipdab-25.8.4.tar.gz:

Publisher: python-publish.yml on mvds314/ipdab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ipdab-25.8.4-py3-none-any.whl.

File metadata

  • Download URL: ipdab-25.8.4-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ipdab-25.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9465f2b907b7594b270170f429f4d0f89344dd080b94de0b02e5223d1df8f647
MD5 2272cdb8dad3e4a1cade244644491086
BLAKE2b-256 d6c90876844e3e6aaad83962c3443d7b3d27d1c4920841fd75eb1fed6a132454

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipdab-25.8.4-py3-none-any.whl:

Publisher: python-publish.yml on mvds314/ipdab

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page