Checking Out CPython 3.14's remote debugging protocol

https://news.ycombinator.com/rss Hits: 6
Summary

From Python 3.14, python -m pdb -p pid lets you connect a pdb session to a running Python process. This post goes into a part of what makes this possible. The barrier to entry for writing general debugging tools for Python programs has always been quite low. Unlike many languages, you're rarely finding yourself working with weird internals. Instead, debugging tools can be built off of pretty straightforward knowledge of the language. This is powered by the languages treating things like exception tracebacks as first class objects, standard library modules like traceback, and of course the power of eval/exec. And thanks to this, tools like pdb can be provided out of the box, and easily customized by people without much (if any) understanding of the internals of the language. Some might comment that the existence of things like pdb have prevented Python programmers from "simply" learning how to use more universal debuggers like gdb/lldb. But I believe that loads of excellent REPL-based debugging experimentation happens because People can simply write tools like ipdb or pdb++ in Python. There's always been a bit of a catch, though. Generally these debugging tools require you first to edit your program source. You can easily stick a: import pdb pdb.set_trace() right in the middle of your program near a problematic spot, or even set up an exception handler beforehand to capture outright exceptions. But if you haven't done this work beforehand, you'll likely end up needing to edit your source code somehow, restart your program, and then go into it. There are tools that can work without restarting the program. Beyond language agnostic debugging tools, tools like pyspy can work on running processes. But they are often relying on tricks and needing to know very specific details about CPython to work. Python 3.14 offers some new functionality to standardize injecting some Python code to a running process. This should reduce the need for a lot of hacks. sys.remote_exec takes a...

First seen: 2025-07-23 13:54

Last seen: 2025-07-23 18:55