-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a GDB pretty printer to aid in debugging #91280
Add a GDB pretty printer to aid in debugging #91280
Conversation
@@ -0,0 +1,109 @@ | |||
# Load this file to your GDB session to enable pretty-printing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add shebang (and make file executable with chmod +x
):
# Load this file to your GDB session to enable pretty-printing | |
#!/usr/bin/env python3 | |
# | |
# Load this file to your GDB session to enable pretty-printing |
Also, remember to format the file with black -l120 path/to/file.py
(it's what we use for other scripts in the repository). I also suggest running isort path/to/file.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
7fc39b9
to
b251efe
Compare
Your commit seems not to be linked to your GitHub account. See: Why are my commits linked to the wrong user? for more info. |
b251efe
to
00c70d1
Compare
The email in the commits had different capitalization than in my profile. They still appeared as linked to me, but regardless, I updated the capitalizations to match. Thanks for the heads up! |
My bad the icon was just scaled and invisible |
Thanks for the contribution, this is really great! I've spent countless time trying to print Strings and StringNames in gdb and figuring out where's a hint of what the actual human-readable string is. For your
Not sure why, and that's probably only applicable for Could you also squash the commits? See PR workflow for instructions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with command line gdb, works great!
Remember to open a PR to document this on https://github.com/godotengine/godot-docs/blob/master/contributing/development/configuring_an_ide/visual_studio_code.rst 🙂 |
Good point. Here: godotengine/godot-docs#9348 |
GDB supports custom pretty-printers implemented in Python. When debugging Godot, checking the values of Strings and StringNames in the debugger was very inconvenient as the data is fairly deep in the structure. This makes the values immediately visible. The custom pretty printer can be taken into use manually by calling `source misc/scripts/godot_gdb_pretty_print.py` in the GDB console. In VS code, it can be activated by default by adding the source command to the `setupCommands` of the configuration in launch.json. Like this: ```json // launch.json { "configurations": [ { "name": "C/C++: debug, "type": "cppdbg", ... "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true }, { "description": "Load custom pretty-printers for Godot types.", "text": "source ${workspaceRoot}/misc/scripts/godot_gdb_pretty_print.py" } ], "miDebuggerPath": "gdb" } ], "version": "2.0.0" } ``` Extended the pretty-printer python script to support Vectors. The printer needs to be uncomfortably aware of CowData implementation details, but I don't think there is any way around that.
00c70d1
to
829c33a
Compare
Thanks! And congrats for your first merged Godot contribution 🎉 |
The GDB debugger supports pretty-printing of a project's custom types using a python script.
This PR adds a GDB pretty-printer script that can pretty-print Godot's
String
,StringName
andVector
.This significantly increses the readability, especially of the two latter objects, as the payload is deep in them.
Before:
After:
You can enable the pretty printer by default in VS code by adding this to your configuration in launch.json:
Vector<StringName>
in VS code without this:Vector<StringName>
in VS code with this:GDB supports some ways of loading the pretty printer automatically, but all of the would require adding the source of
the script to the safe autoload path. If the user needs to do configuration anyway, best to let them specify the loading of pretty printing explicitly, instead of making them enable magic that does the loading implicitly.