Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/progbits/smldbg
A small, dependency free debugger.
https://github.com/progbits/smldbg
cpp debugger educational
Last synced: 28 days ago
JSON representation
A small, dependency free debugger.
- Host: GitHub
- URL: https://github.com/progbits/smldbg
- Owner: progbits
- License: unlicense
- Created: 2019-08-07T22:55:37.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-16T22:01:22.000Z (over 2 years ago)
- Last Synced: 2024-08-04T02:11:02.501Z (4 months ago)
- Topics: cpp, debugger, educational
- Language: C++
- Homepage:
- Size: 638 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - smldbg
README
# smldbg
A small, educational debugger with no dependencies.## Prerequisites
To build the project and run the tests, the following are required:
- A C++20 compliant compiler (tested with `clang++ 11.0.0` and `g++ 10.2.0`)
- CMake 3.12 or higher
- The [Google Test Framework](https://github.com/google/googletest)## Building the Project
```bash
git checkout [email protected]:progbits/smldbg
cd smldbg
mkdir build && cd build
cmake ..
make
```## Running the Debugger
To run the debugger, compile the following small example program with optimization disabled and debug symbols enabled (normally flags `-o0` and `-g` for most compilers).```cpp
#includevoid qux(int value) {
std::cout << "value: " << value << "\n";
}void baz(int value) {
qux(value + 3);
}void bar(int value) {
baz(value + 2);
}void foo(int value) {
bar(value + 1);
}int main() {
foo(1);
bar(3);
return 0;
}
```The following commands will step through the program, set breakpoints on both methods and source code locations and inspect the current program state.
```shell
start # Start debugging the executable
step 2 # Move the instruction pointer forwards 2 instructions
info registers # Print the current register values
bt # Print the backtrace of the current stack
break main.cpp:12 # Add a new breakpoint at line 12
cont # Run until the next breakpoint is hit
bt # Print the backtrace of the current stack
print value # Print the variable `value`
break qux # Set a breakpoint on the function `qux(...)`
cont # Run until the next breakpoint is hit
bt # Print the backtrace of the current stack
print value # Print the variable `value`
set value 99 # Set the variable `value` to 99
step # Move the instruction pointer forwards 1 instruction
finish # Run until the end of the current method
finish # Run until the end of the current method
bt # Print the backtrace of the current stack
finish # Run until the end of the current method
finish # Run until the end of the current method
delete # Delete all breakpoint
next # Run until the next line
step # Move the instruction pointer forwards 1 instruction
```![](resources/smldbg.gif)