Файли
openidea/fixtures/python-app/notebooks/debug.ipynb
T
LU XIANGRUIтаwildcatDownstairs f151498e07 feat(notebook): debug a cell with the kernel's own debugger (#6698)
Breakpoints can be set in notebook code cells, and Debug Cell (notebook toolbar, cell toolbar, Find Action) runs the cell under the kernel's debugger through the Jupyter debugger protocol: DAP requests go as debug_request on the control channel, replies and events come back as debug_reply/debug_event. This works for local ZeroMQ kernels and kernels on a Jupyter server alike.

The bridge dumps every code cell once the debugger starts, rewrites source paths between cell URIs and the kernel's compiled files, re-dumps edited cells before setBreakpoints, and sends disconnect (never terminate) when the session ends, so the kernel and its variables are kept. DebugManager::start_over attaches a session over an existing stream. Kernels without a debugger are refused at once with the reason, and Interrupt during a debug session disconnects first.

Closes #6681

Co-authored-by: wildcatDownstairs <[email protected]>
2026-11-29 14:02:26 +08:00

52 рядки
865 B
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "intro",
"metadata": {},
"source": [
"# Debug a cell\n",
"\n",
"Set a breakpoint in `double`, then choose **Debug Cell** on the last cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "helper",
"metadata": {},
"outputs": [],
"source": [
"def double(x):\n",
" y = x * 2\n",
" return y"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "loop",
"metadata": {},
"outputs": [],
"source": [
"total = 0\n",
"for n in range(3):\n",
" total += double(n)\n",
"print(total)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 5
}