How to pretty-print STL containers in GDB?

前端 未结 9 582
一整个雨季
一整个雨季 2020-11-30 20:45

I\'ve followed the instructions on the GDB wiki to install the python pretty-printers for viewing STL containers. My ~/.gdbinit now looks like this:

<         


        
9条回答
  •  情深已故
    2020-11-30 21:23

    I think you are using a non-GNU STL library, or possible a very old GCC libstdc++. The type of a normal STL string on my compiler is: std::basic_string, std::allocator >. Note that this is not std::basic_string.

    The Python code has this in it:

    reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer ()
    

    This look up a nested type ::Rep of whatever the base string type actually is. The error message inidicates that the string class of whatever strange library you're using doesn't actually have a ::Rep nested type.

提交回复
热议问题