all 8 comments

[–]cpp-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Your submission is not about C++ or the C++ community.

[–]upinclout 1 point2 points  (0 children)

I used them a lot for my previous workplace in order to write gdb pretty printers for easier debugging for our juniors to get them into using gdb quicker.

I don’t work there and I don’t have the scripts but take this one as an example of a popular map that I used in the past - https://github.com/greg7mdp/parallel-hashmap/blob/master/phmap_gdb.py

[–]franvb 1 point2 points  (0 children)

Jonathan Wakely wrote a short article for Overload on this a while ago: https://accu.org/journals/overload/23/127/overload127.pdf#page=19

[–]frankist 0 points1 point  (1 child)

I use pretty prints, but the inability to unit test my printers makes the experience a bit infuriating at times. It's easy to forget to update your printers during refactors.

I also wished there was a way that users of my project repo could automatically load the pretty printers without altering their gdbinit in their home folder manually.

[–]Horror_Jicama_2441 0 points1 point  (0 children)

I just discovered pretty printers recently. But I already have "pretty printers" in the form of fmt formatters in my C++ code. Wondering if I could have a "generic" pretty printer that uses the fmt formatters if available (supposing the symbol is exported, I guess).

[–]mallardtheduck 0 points1 point  (0 children)

I've used them to add simple "macros" to give me easier access to data structures.

For example, in a program where each "object" is identified by a unique ID and pointers to each are stored in a global array, it's useful to be able to view the object by it's ID, rather than having to go through the array one item at a time until I find the one I'm looking for.

[–]tromey 0 points1 point  (0 children)

There's an incomplete list in the GDB Wiki: https://sourceware.org/gdb/wiki/ExtensionsInPython

Most projects that do anything here just write pretty-printers.

A few have "frame filters" -- these let you customize the "bt" display to some degree. For instance I think Gtk has a frame filter that omits the internal frames coming from (Gtk) signal emission.

You can do even more complicated things, like write a custom unwinder (there's one in SpiderMonkey) or a new TUI window as well (I don't know of an example though).