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

mail settings
Submitter Phil Muldoon
Date March 21, 2013, 10:23 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/229621/
State New
Headers show


Phil Muldoon - March 21, 2013, 10:23 a.m.
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.



2013-03-21  Phil Muldoon  <>

	PR gdb/15195

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

Tom Tromey - March 21, 2013, 2:20 p.m.
>>>>> "Phil" == Phil Muldoon <> writes:

Phil> 2013-03-21  Phil Muldoon  <>
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/ (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.



---	(revision 196862)
+++	(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)