https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81584
Bug ID: 81584 Summary: Pretty Printer for string* doesn't work Product: gcc Version: 6.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: ghjghj530-bubu at yahoo dot de Target Milestone: --- GCC 6.3, GDB 7.10, building with: -D_GLIBCXX_USE_CXX11_ABI=1 Code: std::string fooVar = "hello world"; std::string* pFooVar = &fooVar; (gdb) p pFooVar p pFooVar $4 = Traceback (most recent call last): File "*\gdb-7.10/python\libstdcxx\v6\printers.py", line xx, in to_string reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer () gdb.error: No type named std::__cxx11::string *::_Rep. I changed the python script to this and it worked for me: def __init__(self, typename, val): self.val = val def to_string(self): # Make sure &string and string* works, too. type = self.val.type if type.code == gdb.TYPE_CODE_REF or type.code == gdb.TYPE_CODE_PTR: type = type.target () # Change to original printer to make string* work: Check for new/old string after dereferencing typeName = str(type) new_string = typeName.find("::__cxx11::basic_string") != -1 or typeName.find("::__cxx11::string") != -1 # Calculate the length of the string so that to_string returns the string according to length, # not according to first null encountered. ptr = self.val ['_M_dataplus']['_M_p'] if new_string: ...... ......