GDB image watch
Setup
Some of the setup is specific to using these scripts in a docker container on MacOS. Running natively or in docker on Linux will be easier.
XQuartz
XQuartz allows display of windows from a linux container on MacOS.
-
Install XQuartz - an X.org X window system for MacOS. Logout and login required after install.
brew install xquartz
-
Change security settings
- Launch XQuartz.
- Under the XQuartz menu, select Preferences
- Go to the security tab and ensure "Allow connections from network clients" is checked.
-
Test. Run the following commands. You should see a Linux version of firefox running
- Note: some instructions say to
xhost + 127.0.0.1
. This is not recommended.
- Note: some instructions say to
xhost + $(hostname)
docker run -e DISPLAY=host.docker.internal:0 jess/firefox
- The
DISPLAY
environment variable can be set in the docker compose file with this at the same level asbuild
environment:
- DISPLAY=host.docker.internal:0
GDB Image watch
-
Install python dependencies in the container. We may add this to the docker image if it's found to be useful.
- pip:
apt install python3-pip
- The Tk backend works
apt install python3-tk
- Matplotlib:
python3 -m pip install matplotlib
- pip:
-
Checkout https://github.com/cuekoo/GDB-ImageWatch. cv_imshow.py is the entirety of the needed code.
-
.gdbinit files Contents of /root/.gdbinit (we should not be using root as the user, in which case, this would be /home//.gdbinit)
add-auto-load-safe-path <path-to-source>/.gdbinit
Example Local .gdbinit
source /path/to/cv_imshow.py
Usage
gdb bin/report
source /path/to/cv_imshow.py # if you did not set up .gdbinit
<set a breakpoint>
run
<hit breakpoint>
cv_imshow <image>
Reference
There's also OpenImageDebugger which looks to require some compiling and install.
https://medium.com/@mreichelt/how-to-show-x11-windows-within-docker-on-mac-50759f4b65cb
https://github.com/cuekoo/GDB-ImageWatch
https://gist.github.com/paul-krohn/e45f96181b1cf5e536325d1bdee6c949
https://gist.github.com/CMCDragonkai/4e9464d9f32f5893d837f3de2c43daa4
https://stackoverflow.com/questions/12933335/tkagg-backend-problems
https://news.ycombinator.com/item?id=13700512
https://interrupt.memfault.com/blog/automate-debugging-with-gdb-python-api