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

login
register
mail settings
Submitter Phil Muldoon
Date June 11, 2013, 8:45 a.m.
Message ID <51B6E3C5.3000209@redhat.com>
Download mbox | patch
Permalink /patch/250482/
State New
Headers show

Comments

Phil Muldoon - June 11, 2013, 8:45 a.m.
On 21/03/13 14:20, Tom Tromey wrote:
>>>>>> "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.

> Phil>      def to_string (self):
> 
> Why doesn't the 'children' method also need a fix?
> 
> Also, Phil and I discussed this on irc, and he is going to write a
> regression test.

Hi,

Attached is an updated patch correcting the issues that you pointed
out.

Cheers,

Phil


2013-06-11  Phil Muldoon  <pmuldoon@redhat.com>

	http://sourceware.org/bugzilla/show_bug.cgi?id=15195

	* python/libstdcxx/v6/printers.py (StdTuplePrinter.__init__):
	Acquire referenced value if tuple is a reference.
	* testsuite/libstdc++-prettyprinters/cxx11.cc (main): Add -O0
	flag. Add tuple and referenced tuple tests.

--
Tom Tromey - June 13, 2013, 1:49 p.m.
>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes:

Phil> Attached is an updated patch correcting the issues that you pointed
Phil> out.

The patch itself looks fine to me, but I don't think I can approve it.

Tom

Patch

Index: python/libstdcxx/v6/printers.py
===================================================================
--- python/libstdcxx/v6/printers.py	(revision 199642)
+++ python/libstdcxx/v6/printers.py	(working copy)
@@ -313,6 +313,9 @@ 
     def __init__ (self, typename, val):
         self.typename = typename
         self.val = val;
+        type = self.val.type
+        if type.code == gdb.TYPE_CODE_REF:
+           self.val = self.val.referenced_value()
 
     def children (self):
         return self._iterator (self.val)
Index: testsuite/libstdc++-prettyprinters/cxx11.cc
===================================================================
--- testsuite/libstdc++-prettyprinters/cxx11.cc	(revision 199706)
+++ testsuite/libstdc++-prettyprinters/cxx11.cc	(working copy)
@@ -1,5 +1,5 @@ 
 // { dg-do run }
-// { dg-options "-std=gnu++11 -g" }
+// { dg-options "-std=gnu++11 -g -O0" }
 
 // Copyright (C) 2011-2013 Free Software Foundation, Inc.
 //
@@ -25,6 +25,8 @@ 
 #include <memory>
 #include <iostream>
 
+typedef std::tuple<int, int> ExTuple;
+
 template<class T>
 void
 placeholder(const T &s)
@@ -100,6 +102,10 @@ 
   uptr->i = 23;
 // { dg-final { regexp-test uptr {std::unique_ptr.datum. containing 0x.*} } }
 
+  ExTuple tpl(6,7);
+// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } }  
+  ExTuple &rtpl = tpl;
+// { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } }   
   placeholder(""); // Mark SPOT
   use(efl);
   use(fl);