Does any tool support that? On linux? Or does it mean one has to go back to command line gdb?
Edit: Hrmmpf: When I came back from posting this to qtcreator, it had it's mouse activated. So it seems only a matter of massaging it a little.
How do you debug the captured mouse game with a gdb GUI?
Re: How do you debug the captured mouse game with a gdb GUI?
It can be pretty annoying to have to play without mouse grabbing, especially if the bug doesn't occur quickly after starting. Luckily there is an alternative for GDB-based debuggers. GDB allows running python script functions when it breaks/stops the program, and can also call functions in the app while it's stopped. This is a script that has helped me:
Note that the script can be in any sub-directory of the specified safe path, so if you have all your projects in a common directory (e.g. $HOME/projects/openmw, $HOME/projects/somethingelse, $HOME/projects/anotherthing) you can just specify $HOME/projects as the safe path and GDB will allow the script to work for them all.
Code: Select all
#!/usr/bin/python
# release mouse when breaking into debugger for SDL2 programs
# put this next to the executable you wanna debug and name it
# <YourExecutableName>-gdb.py
# Make sure that it's in a subdir of an allowed GDB auto-loading safe-path,
# see https://sourceware.org/gdb/onlinedocs/gdb/Auto_002dloading-safe-path.html
# e.g. by executing in a terminal:
# $ echo "add-auto-load-safe-path /path/to/project" >> ~/.gdbinit
def release_mouse (event):
gdb.write("GDB/SDL2: Releasing mouse\n")
gdb.execute("call SDL_SetRelativeMouseMode(0)")
# TODO: if you use SDL_SetWindowGrab(), you may have to write
# function with no arguments to call it with your SDL_Window*
# handle and call this as well, like:
#gdb.execute("call DEBUG_UngrabMouse()")
# TODO: the following doesn't seem to work, maybe it does for you.
# either way, it needs xdotool installed.
#gdb.execute("exec xdotool key XF86Ungrab")
gdb.events.stop.connect(release_mouse)
gdb.write("GDB/SDL2: installed release mouse for SDL2\n")
Re: How do you debug the captured mouse game with a gdb GUI?
Nifty. If that script is confirmed working for others, maybe it could go on the Wiki as well?