diff mbox

[python,libstdc++,printers] Fix gdb/15195

Message ID 514ADF9B.1090407@redhat.com
State New
Headers show

Commit Message

Phil Muldoon March 21, 2013, 10:23 a.m. UTC
This patch fixes a bug in the std::tuple printer where, if the value
was passed by reference, the printer was not correctly dereferencing the
value before printing.

Cheers,

Phil


2013-03-21  Phil Muldoon  <pmuldoon@redhat.com>

	PR gdb/15195

	* python/libstdcxx/v6/printers.py (StdTuplePrinter): Convert
	referenced value to actual if type is TYPE_CODE_REF.

--

Comments

Tom Tromey March 21, 2013, 2:20 p.m. UTC | #1
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> 2013-03-21  Phil Muldoon  <pmuldoon@redhat.com>
Phil> 	PR gdb/15195

I think this should use a full URL.
Otherwise it is going to attach the commit to some random GCC bug.

Phil> 	* python/libstdcxx/v6/printers.py (StdTuplePrinter): Convert
Phil> 	referenced value to actual if type is TYPE_CODE_REF.

This should reference the function, like "(StdTuplePrinter.to_string):"

Phil>      def to_string (self):

Why doesn't the 'children' method also need a fix?

If they both need the fix you might as well put the dereferencing into
the constructor.


Also, Phil and I discussed this on irc, and he is going to write a
regression test.

thanks,
Tom
diff mbox

Patch

Index: printers.py
===================================================================
--- printers.py	(revision 196862)
+++ printers.py	(working copy)
@@ -318,7 +318,12 @@ 
         return self._iterator (self.val)
 
     def to_string (self):
-        if len (self.val.type.fields ()) == 0:
+        type = self.val.type
+        if type.code == gdb.TYPE_CODE_REF:
+            self.val = self.val.referenced_value()
+            type = self.val.type
+
+        if len(type.fields ()) == 0:
             return 'empty %s' % (self.typename)
         return '%s containing' % (self.typename)