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

  • 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.3.tar.gz (14.9 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.3-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ipdab-25.8.3.tar.gz
  • Upload date:
  • Size: 14.9 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.3.tar.gz
Algorithm Hash digest
SHA256 dc494e8ab4b2ae38dd6af633b105aa40e038100ba193e54de123a62e78a1f78e
MD5 d57e3e1d419019bfe3be58039e91f4ed
BLAKE2b-256 64d52100c59d7e85ef4e98c05607c8890881edfe56364c483cddb747c8d65511

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipdab-25.8.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: ipdab-25.8.3-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fe3f379115857bc14af90ee6d3b798d7499ad9fce5edb6208d2b0f70c18f21e2
MD5 72f07ef0e22f0e210c8b9dde634de9bf
BLAKE2b-256 3a8985b525204c397670df07dc1683fbd309b114b08adbff966d4ced206f48a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipdab-25.8.3-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