Patchwork [v3] libstdc++/45403 support gdb 7.0 in std::string pretty printer

login
register
mail settings
Submitter Jonathan Wakely
Date Oct. 8, 2010, 11:31 a.m.
Message ID <AANLkTi=Bkn3gZMFSXKr8qfAczL31DBfC-x+3eHppiUdy@mail.gmail.com>
Download mbox | patch
Permalink /patch/67181/
State New
Headers show

Comments

Jonathan Wakely - Oct. 8, 2010, 11:31 a.m.
Tested with GNU gdb (GDB) Fedora (7.1-34.fc13)

Committed to trunk.

        PR libstdc++/45403
        * python/libstdcxx/v6/printers.py: Check for lazy_string support.
Jonathan Wakely - Oct. 8, 2010, 12:07 p.m.
On 8 October 2010 12:31, Jonathan Wakely wrote:
> Tested with GNU gdb (GDB) Fedora (7.1-34.fc13)

I've also committed this to the 4.5 branch after testing the change
with GDB 7.0 and 7.1-34.fc13

It's not a regression, but the change is only to the python pretty
printer and is safe.

Patch

Index: python/libstdcxx/v6/printers.py
===================================================================
--- python/libstdcxx/v6/printers.py     (revision 165162)
+++ python/libstdcxx/v6/printers.py     (working copy)
@@ -580,7 +580,9 @@  class StdStringPrinter:
         reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer ()
         header = ptr.cast(reptype) - 1
         len = header.dereference ()['_M_length']
-        return self.val['_M_dataplus']['_M_p'].lazy_string (length = len)
+        if hasattr(ptr, "lazy_string"):
+            return ptr.lazy_string (length = len)
+        return ptr.string (length = len)

     def display_hint (self):
         return 'string'