While Python scripts can be loaded from files, it is nice to interactively explore the API or the debugged program. IPython would be perfect for the job, but starting it directly inside GDB doesn't work well. Fortunately, it's easy to launch an IPython kernel and connect with an external Jupyter console.
Launching the kernel from the gdb prompt:
(gdb) python >import IPython; IPython.embed_kernel() >end
Gives the following message:
To connect another client to this kernel, use: --existing kernel-12688.json
We can start Jupyter on a separate terminal and connect to this kernel:
$ jupyter console --existing kernel-12688.json In : gdb.newest_frame().name() Out: 'main'
Currently, only the console client can connect to existing kernels. Support in the Notebook or in Jupyter Lab is tackled in this Github issue. Even with the limited capabilities of the console client, it's a great way to explore the API and to tackle more complicated debugging problems that require automation to solve.