Real-time visualization of the memory of a C program during debugging in VSCode, using vscode-debug-visualizer and GDB's Python API.
-
Install graphviz.
sudo apt install graphviz
-
In VSCode, install vscode-debug-visualizer.
Ctrl-P / ext install hediet.debug-visualizer
-
Clone this repository, open it in VSCode and start debugging (
F5
).If the debugger doesn't start, make sure that
gdb
,make
and VSCode's ms-vscode.cpptools are installed. -
Select
F1 / Debug Visualizer : New View
and write"memory"
(including the quotes) in the visualization window that opens. -
A visualization of both the stack and the heap will appear, and it will update as you step through the code (
F10
,F11
, etc). -
Modify
examples/examples.c
to try your own code.
Tested in Ubuntu 20.04 and Windows 10 under WSL. macOS is not supported (it could be adapted, but Apple makes it particularly painful to use GDB in macOS anyway).
- Build
visualize-c-memory.so
(by runningmake
insrc
). - Load the
.so
and the python module in GDB by adding the following to yourlaunch.json
:See .vscode/launch.json for an example."environment": [ {"name":"LD_PRELOAD", "value":"${workspaceFolder}/<path-to>/visualize-c-memory.so"}, ], "setupCommands": [ { "text": "source ${workspaceFolder}/<path-to>/visualize-c-memory.py" } ],