Pretty-printing C++ variable values in the debugger

I'm using the GLM library for vector/matrix/etc math in C++. GLM represents vec3 (and friends) as a union to allow to allow for referring fields as (x, y, z), (r, g, b) etc. This is fine, however the gdb and CodeLLDB debuggers show the unions in an awkward manner, which makes debugging a pain. See the screenshot for an example of a vec3 being displayed as three separate unions which all have to be opened to see the value.

In Xcode, I can set up some debugger pretty printing commands to simply show a formatted string instead. Is there a way to do this with VS Code's GDB or CodeLLDB debuggers? I am on linux, but have this issue on macOS as well.

https://preview.redd.it/icntmye3be051.png?width=1924&format=png&auto=webp&s=d615998f16d42e26d525d666f16c4049906becd7

Posted May 22, 2020, 10:57 PM UTC

10

No comments yet

Nobody commented on this post, or the comments weren't captured.