a cmake debugger like gdb. Needs cmake >=3.27
Project description
Cmakedbg
Cmakedbg is a command-line debugger for CMake that can be run to debug your CMake build steps.
Similar to gdb, you can
- launch your CMake build under cmakedbg
- set breakpoints
- step through the cmake steps line by line
- show the listing to see which CMake file you're in
- show the backtrace to see the CMake callstack
- inspect CMake variables
- pipe debugger command output to shell commands
- and hopefully more useful things in the future
This is useful for those of us that work mainly in the terminal and needed a gdb-like terminal tool to help debug complicated CMake builds.
How to install
- Clone this repository and cd into it
- Run
pip install .(make sure you set up your virtual environment first, or usepipx install .to install it without needing to set up a virtual environment). - Once installed,
cmakedbgcommand will be available on the command line.
How to use
usage: cmakedbg [-h] [-v] --cmd cmake [OPTIONS ...]
options:
-h, --help show this help message and exit
-v, --verbose increase output verbosity
--cmd cmake [OPTIONS ...]
cmake command with arguments to run debugger on
- If you run your cmake build with
cmake ..from the build directory, then to run your CMake run under cmakedbg, simply docmakedbg --cmd cmake ... This will open a REPL. - Set a breakpoint with
br /path/to/CMakeLists.txt:<lineno>where<lineno>should be replaced with the appropriate line number. runcommand will start Cmake. CMake will now run till it hits the breakpointnextandstepwill go to next line, and step into the function respectively, just like gdb.- Type
helpon the REPL to see what commands are available.
>>> help
CMake Debugger Commands:
=======================
Flow Control:
------------
breakpoint, break, br <file:line> Set a breakpoint at specified file and line number
run, r Start the CMake build execution
continue, c Continue execution until next breakpoint
next, n Step over - execute next line without entering functions
step, s Step into - execute next line, entering functions if present
Information:
------------
info breakpoints List all set breakpoints (aliases: info break, info b)
info variables Display all CMake variables in current scope (aliases: info vars, info locals)
get variable <name> Display value of specific CMake variable (alias: get var)
list Show source code around current line (aliases: listing, li, l)
stacktrace Display current call stack (aliases: st, backtrace, bt)
Other:
------
pipe <cmakedbg command> | <shell command> Pipe the output of a cmakedbg command to a shell
command e.g. pipe info vars | less
quit, q Exit the debugger
help, h Display this help message
Notes:
- Many commands require the CMake build to be running first (start with 'run')
- Commands can use either full names or their shorter aliases
- Empty input will repeat the last command
- Unknown commands will display an error message
Where this came from
CMake 3.27 onward, CMake has implemented the Debug Adapter Protocol. This allows for tools to hook into a running CMake process and step through the CMake configuration steps line by line like you would with a programming language debugger. There is a plugin for VSCode that leverages this to provide a editor integrated CMake GUI debugger through their CMake Tools extension. But there is a need for a plain CLI debugger that we can use from the terminal like GDB, which this fulfills.
TODOs:
- implement printing out individual variables
- launch cmake directly from debugger
- add log levels and print json sends and recvs only for higher log levels (with -v|--verbose flag)
- show listing at point
- implementing 'next' (step over) and 'step into'
- write help output
- write man page
- quit - with ctrl+d and with command 'quit'
- add tests
- add support for repeating last command when pressing "enter"
- change globals to a dataclass
- add types
- add support for an .rc file where you can set a breakpoint info that will be read by the cmakedbg on launch
- account for the fact in the main while loop, that there are cases when receiving the stackframe response that the number of frames in the list can be more than 1.j
- add ability to pipe output of cmakedbg command outputs to shell commands
- tests for pipe command, parse user output, other functions
- figure out how to make this installable as a command line utility
- publish to PyPI
- change how the list command works to be more aligned to gdb behavior
- refactor for readability, and add lots of tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cmakedbg-0.1.1.tar.gz.
File metadata
- Download URL: cmakedbg-0.1.1.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.8.0-60-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
acb4860893fce349ea6f07dce5d1321d96b5359c6d3ebc464729c65e5d59fbfa
|
|
| MD5 |
acc2f5133bfee0af20e8ec25ca75f6eb
|
|
| BLAKE2b-256 |
438b9a664c843697797fb128254c70b597f72b9716a857971b6417d03f45136d
|
File details
Details for the file cmakedbg-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cmakedbg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.3 Linux/6.8.0-60-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac59d535d9f3e032d2995247363fdbf46d6a4e927e7544a4dcbf5ca93a8945dd
|
|
| MD5 |
ca0c1720692215614af08dbd17f7129b
|
|
| BLAKE2b-256 |
e4a1847344f6f0259dedd8ba370a969be5cb24e2f8e1a2fd6d90fe672ca530bf
|