0

I have a structure that wraps a std::map, whcih gdb knows how to pretty-print.
I want to write a custom pretty-printer (with python), that delegates to the inner std:::map and maybe shows the count of existing entries in the map (and hoping that python does not have to traverse the tree for that).

EDIT:
my current wrapper prints ingdb as MyMap<unsigned long, std::__cxx11::basic_string<...>> = {std::map with 2 elements = {[0] = "", [5] = "55555"}}
There is on indirection in there that I would like to remove to:
MyMap<...> with 2 elements = {[0] = "", [5] = "55555"}
the ... is just me snipping the generic parameter

The display hint im using currently is also "array" and not "map", since I was not able to properly delegate it. The current delegation looks like this:

def children(self):
    return [("", self.val['inner'])] # val is the gdb.Value of inner
Ben Müker
  • 31
  • 5
  • If you return the inner map as `children`, it should be pretty-printed. – ssbssa Jan 25 '22 at 16:39
  • for that to work i have to wrap it into an array with a tuple like so: `return [("inner", self.val['inner'])]`, which undos the unwrapping... – Ben Müker Jan 25 '22 at 16:54
  • I don't know what you mean. A small example with current output, and how you want it to look like would help. – ssbssa Jan 25 '22 at 20:15

0 Answers0