public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Add libstdc++ pretty printers for Library Fundamentals TS types
@ 2014-07-14 19:48 Jonathan Wakely
  2014-07-15 12:06 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2014-07-14 19:48 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: tromey, pmuldoon

[-- Attachment #1: Type: text/plain, Size: 2196 bytes --]

This is another patch for the python printers, so the diff is relative
to my patch from earlier today, but it's actually independent.

This adds printers for the types in the std::experimental namespace.

For 'any' and 'optional' the printer will say "no contained value"
when that's the case, otherwise it will display the contained value
using its own printer, so the output looks like one of:

No contained value:

  std::experimental::any [no contained value]

Contained value is a single object:

  std::experimental::any containing int = {[contained value] = 6}

Contained value contains other object:

  std::experimental::any containing std::map with 2 elements = {[1] = 2, [3] = 4}

I'd rather not have the [contained value] part in the second one, but
the design of the printers assumes that the children() method always
returns a 2-tuple with a label and a value, so I decided that
  [contained value] = x
looks better than some arbitrary index such as:
  [0] = x

Printing the contained value was quite tricky to do for any, where the
type is completely erased. I'm considering using a similar trick for
shared_ptr, so that the printer can show the owned pointer as well as
the pointer that will be returned by get(), since they are not always
the same.

I had to remove the assumption that libstdc++ printers always work on
templates, because std::experimental::any is not a template (this will
also be true for std::experimental::filesystem::path and other types
in the Filesystem TS which I'm currently implementing). The relevant
part of the patch is:

@@ -865,12 +1001,12 @@ class Printer(object):
         self.subprinters = []
         self.lookup = {}
         self.enabled = True
-        self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)<.*>$')
+        self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$')

     def add(self, name, function):
         # A small sanity check.
         # FIXME
-        if not self.compiled_rx.match(name + '<>'):
+        if not self.compiled_rx.match(name):
             raise ValueError('libstdc++ programming error: "%s" does not match' % name)
         printer = RxPrinter(name, function)
         self.subprinters.append(printer)

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 10679 bytes --]

commit 6a3842ae658fe9693a0989a9aa5ea7b42d01fe28
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jul 14 15:41:22 2014 +0100

    	* python/libstdcxx/v6/printers.py (SingleObjContainerPrinter): New
    	base class for experimental::any and experimental::optional printers.
    	(StdExpAnyPrinter, StdExpOptionalPrinter, StdExpStringViewPrinter):
    	New printers for Fundamentals TS types.
    	* testsuite/libstdc++-prettyprinters/libfundts.cc: New.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index ea34f22..994668d 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -836,6 +836,142 @@ class StdForwardListPrinter:
             return 'empty %s' % (self.typename)
         return '%s' % (self.typename)
 
+class SingleObjContainerPrinter(object):
+    "Base class for printers of containers of single objects"
+
+    def __init__ (self, val, viz):
+        self.contained_value = val
+        self.visualizer = viz
+
+    class _contained:
+        def __init__ (self, val):
+            self.val = val
+
+        def __iter__ (self):
+            return self
+
+        def next (self):
+            if self.val is None:
+                raise StopIteration
+            retval = self.val
+            self.val = None
+            return ('[contained value]', retval)
+
+    def children (self):
+        if self.contained_value:
+            if hasattr (self.visualizer, 'children'):
+                return self.visualizer.children ()
+            else:
+                return self._contained (self.contained_value)
+        return self._contained (None)
+
+    def display_hint (self):
+        # if contained value is a map we want to display in the same way
+        if hasattr (self.visualizer, 'children') and hasattr (self.visualizer, 'display_hint'):
+            return self.visualizer.display_hint ()
+        return None
+
+
+class StdExpAnyPrinter(SingleObjContainerPrinter):
+    "Print a std::experimental::any"
+
+    def __init__ (self, typename, val):
+        self.typename = 'std::experimental::any'
+        self.val = val
+        self.contained_type = None
+        contained_value = None
+        visualizer = None
+        mgr = self.val['_M_manager']
+        if mgr != 0:
+            func = gdb.block_for_pc(int(mgr.cast(gdb.lookup_type('intptr_t'))))
+            if not func:
+                raise ValueError("Invalid function pointer in std::experimental::any")
+            rx = r"""({0}::_Manager_\w+<.*>)::_S_manage\({0}::_Op, {0} const\*, {0}::_Arg\*\)""".format(typename)
+            m = re.match(rx, func.function.name)
+            if not m:
+                raise ValueError("Unknown manager function in std::experimental::any")
+
+            # FIXME need to expand 'std::string' so that gdb.lookup_type works
+            mgrname = re.sub("std::string(?!\w)", gdb.lookup_type('std::string').strip_typedefs().name, m.group(1))
+            mgrtype = gdb.lookup_type(mgrname)
+            self.contained_type = mgrtype.template_argument(0)
+            valptr = None
+            if '::_Manager_internal' in mgrname:
+                valptr = self.val['_M_storage']['_M_buffer'].address
+            elif '::_Manager_external' in mgrname:
+                valptr = self.val['_M_storage']['_M_ptr']
+            elif '::_Manager_alloc' in mgrname:
+                datatype = gdb.lookup_type(mgrname + '::_Data')
+                valptr = self.val['_M_storage']['_M_ptr'].cast(datatype.pointer())
+                valptr = valptr.dereference()['_M_data'].address
+            else:
+                raise ValueError("Unknown manager function in std::experimental::any")
+            contained_value = valptr.cast(self.contained_type.pointer()).dereference()
+            visualizer = gdb.default_visualizer(contained_value)
+        super(StdExpAnyPrinter, self).__init__ (contained_value, visualizer)
+
+    def to_string (self):
+        if self.contained_type is None:
+            return '%s [no contained value]' % self.typename
+        valtype = gdb.types.apply_type_recognizers(gdb.types.get_type_recognizers(),
+                                                   self.contained_type)
+        if not valtype:
+            valtype = self.contained_type.name or str(self.contained_type)
+        if self.contained_value is None:
+            return '%s containing %s with unknown value' % (self.typename, valtype)
+        desc = "%s containing " % self.typename
+        if hasattr (self.visualizer, 'children'):
+            return desc + self.visualizer.to_string ()
+        return desc + valtype
+
+class StdExpOptionalPrinter(SingleObjContainerPrinter):
+    "Print a std::experimental::optional"
+
+    def __init__ (self, typename, val):
+        valtype = val.type.template_argument(0)
+        valtype = gdb.types.apply_type_recognizers(gdb.types.get_type_recognizers(), valtype) or valtype
+        self.typename = "std::experimental::optional<%s>" % valtype
+        self.val = val
+        contained_value = val['_M_payload'] if self.val['_M_engaged'] else None
+        visualizer = gdb.default_visualizer (val['_M_payload'])
+        super (StdExpOptionalPrinter, self).__init__ (contained_value, visualizer)
+
+    class _contained:
+        def __init__ (self, val):
+            self.val = val
+
+        def __iter__ (self):
+            return self
+
+        def next (self):
+            if self.val is None:
+                raise StopIteration
+            retval = self.val
+            self.val = None
+            return ('[contained value]', retval)
+
+    def to_string (self):
+        if not self.contained_value:
+            return self.typename + " [no contained value]"
+        if hasattr (self.visualizer, 'children'):
+            return self.typename + " containing " + self.visualizer.to_string ()
+        return self.typename
+
+class StdExpStringViewPrinter:
+    "Print a std::experimental::basic_string_view"
+
+    def __init__ (self, typename, val):
+        self.val = val
+
+    def to_string (self):
+        ptr = self.val ['_M_str']
+        len = self.val ['_M_len']
+        if hasattr (ptr, "lazy_string"):
+            return ptr.lazy_string (length = len)
+        return ptr.string (length = len)
+
+    def display_hint (self):
+        return 'string'
 
 # A "regular expression" printer which conforms to the
 # "SubPrettyPrinter" protocol from gdb.printing.
@@ -865,12 +1001,12 @@ class Printer(object):
         self.subprinters = []
         self.lookup = {}
         self.enabled = True
-        self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)<.*>$')
+        self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$')
 
     def add(self, name, function):
         # A small sanity check.
         # FIXME
-        if not self.compiled_rx.match(name + '<>'):
+        if not self.compiled_rx.match(name):
             raise ValueError('libstdc++ programming error: "%s" does not match' % name)
         printer = RxPrinter(name, function)
         self.subprinters.append(printer)
@@ -1214,6 +1350,13 @@ def build_libstdcxx_dictionary ():
     libstdcxx_printer.add('std::__debug::forward_list',
                           StdForwardListPrinter)
 
+    # Library Fundamentals TS components
+    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
+                                  'any', StdExpAnyPrinter)
+    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
+                                  'optional', StdExpOptionalPrinter)
+    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
+                                  'basic_string_view', StdExpStringViewPrinter)
 
     # Extensions.
     libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter)
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
new file mode 100644
index 0000000..54ed037
--- /dev/null
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
@@ -0,0 +1,61 @@
+// { dg-do run }
+// { dg-options "-g -O0 -std=gnu++14" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/any>
+#include <experimental/optional>
+#include <experimental/string_view>
+#include <string>
+#include <map>
+
+using std::experimental::any;
+using std::experimental::optional;
+using std::experimental::string_view;
+
+int
+main()
+{
+  string_view str = "string";
+// { dg-final { note-test str "\"string\"" } }
+
+  optional<int> o;
+// { dg-final { note-test o {std::experimental::optional<int> [no contained value]} } }
+  optional<int> oi{5};
+// { dg-final { note-test oi {std::experimental::optional<int> = {[contained value] = 5}} } }
+  optional<std::map<int, double>> om;
+  om = std::map<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
+// { dg-final { note-test om {std::experimental::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
+  optional<std::string> os{ "stringy" };
+// { dg-final { note-test os {std::experimental::optional<std::string> = {[contained value] = "stringy"}} } }
+
+  any a;
+// { dg-final { note-test a {std::experimental::any [no contained value]} } }
+  any ai(6);
+// { dg-final { note-test ai {std::experimental::any containing int = {[contained value] = 6}} } }
+  any as = *os;
+// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} } }
+  any ap("stringiest");
+// { dg-final { regexp-test ap {std::experimental::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
+  any am = *om;
+// { dg-final { note-test am {std::experimental::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
+
+  return 0;			// Mark SPOT
+}
+
+// { dg-final { gdb-test SPOT } }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Add libstdc++ pretty printers for Library Fundamentals TS types
  2014-07-14 19:48 [patch] Add libstdc++ pretty printers for Library Fundamentals TS types Jonathan Wakely
@ 2014-07-15 12:06 ` Jonathan Wakely
  2014-07-23 11:05   ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2014-07-15 12:06 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: tromey, pmuldoon

[-- Attachment #1: Type: text/plain, Size: 427 bytes --]

On 14/07/14 20:31 +0100, Jonathan Wakely wrote:
>This adds printers for the types in the std::experimental namespace.

I've committed this slightly improved patch, which removes the
duplicate _contained method from StdExpOptionalPrinter (it was meant
to be using the base class version) and fixes some conditions to
compare to None, so that integers, booleans and pointers with zero
values don't get interpreted as no value.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 10771 bytes --]

commit f29d6b5d809df660a989dd19b8afe68d08934d9f
Author: redi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jul 15 12:00:18 2014 +0000

    	* python/libstdcxx/v6/printers.py (SingleObjContainerPrinter): New
    	base class for experimental::any and experimental::optional printers.
    	(StdExpAnyPrinter, StdExpOptionalPrinter, StdExpStringViewPrinter):
    	New printers for Fundamentals TS types.
    	* testsuite/libstdc++-prettyprinters/libfundts.cc: New.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@212556 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index ea34f22..af41f1f 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -836,6 +836,126 @@ class StdForwardListPrinter:
             return 'empty %s' % (self.typename)
         return '%s' % (self.typename)
 
+class SingleObjContainerPrinter(object):
+    "Base class for printers of containers of single objects"
+
+    def __init__ (self, val, viz):
+        self.contained_value = val
+        self.visualizer = viz
+
+    def _recognize(self, type):
+        """Return TYPE as a string after applying type printers"""
+        return gdb.types.apply_type_recognizers(gdb.types.get_type_recognizers(),
+                                                type) or str(type)
+
+    class _contained:
+        def __init__ (self, val):
+            self.val = val
+
+        def __iter__ (self):
+            return self
+
+        def next (self):
+            if self.val is None:
+                raise StopIteration
+            retval = self.val
+            self.val = None
+            return ('[contained value]', retval)
+
+    def children (self):
+        if self.contained_value is None:
+            return self._contained (None)
+        if hasattr (self.visualizer, 'children'):
+            return self.visualizer.children ()
+        return self._contained (self.contained_value)
+
+    def display_hint (self):
+        # if contained value is a map we want to display in the same way
+        if hasattr (self.visualizer, 'children') and hasattr (self.visualizer, 'display_hint'):
+            return self.visualizer.display_hint ()
+        return None
+
+
+class StdExpAnyPrinter(SingleObjContainerPrinter):
+    "Print a std::experimental::any"
+
+    def __init__ (self, typename, val):
+        self.typename = 'std::experimental::any'
+        self.val = val
+        self.contained_type = None
+        contained_value = None
+        visualizer = None
+        mgr = self.val['_M_manager']
+        if mgr != 0:
+            func = gdb.block_for_pc(int(mgr.cast(gdb.lookup_type('intptr_t'))))
+            if not func:
+                raise ValueError("Invalid function pointer in std::experimental::any")
+            rx = r"""({0}::_Manager_\w+<.*>)::_S_manage\({0}::_Op, {0} const\*, {0}::_Arg\*\)""".format(typename)
+            m = re.match(rx, func.function.name)
+            if not m:
+                raise ValueError("Unknown manager function in std::experimental::any")
+
+            # FIXME need to expand 'std::string' so that gdb.lookup_type works
+            mgrname = re.sub("std::string(?!\w)", gdb.lookup_type('std::string').strip_typedefs().name, m.group(1))
+            mgrtype = gdb.lookup_type(mgrname)
+            self.contained_type = mgrtype.template_argument(0)
+            valptr = None
+            if '::_Manager_internal' in mgrname:
+                valptr = self.val['_M_storage']['_M_buffer'].address
+            elif '::_Manager_external' in mgrname:
+                valptr = self.val['_M_storage']['_M_ptr']
+            elif '::_Manager_alloc' in mgrname:
+                datatype = gdb.lookup_type(mgrname + '::_Data')
+                valptr = self.val['_M_storage']['_M_ptr'].cast(datatype.pointer())
+                valptr = valptr.dereference()['_M_data'].address
+            else:
+                raise ValueError("Unknown manager function in std::experimental::any")
+            contained_value = valptr.cast(self.contained_type.pointer()).dereference()
+            visualizer = gdb.default_visualizer(contained_value)
+        super(StdExpAnyPrinter, self).__init__ (contained_value, visualizer)
+
+    def to_string (self):
+        if self.contained_type is None:
+            return '%s [no contained value]' % self.typename
+        desc = "%s containing " % self.typename
+        if hasattr (self.visualizer, 'children'):
+            return desc + self.visualizer.to_string ()
+        valtype = self._recognize (self.contained_type)
+        return desc + valtype
+
+class StdExpOptionalPrinter(SingleObjContainerPrinter):
+    "Print a std::experimental::optional"
+
+    def __init__ (self, typename, val):
+        valtype = self._recognize (val.type.template_argument(0))
+        self.typename = "std::experimental::optional<%s>" % valtype
+        self.val = val
+        contained_value = val['_M_payload'] if self.val['_M_engaged'] else None
+        visualizer = gdb.default_visualizer (val['_M_payload'])
+        super (StdExpOptionalPrinter, self).__init__ (contained_value, visualizer)
+
+    def to_string (self):
+        if self.contained_value is None:
+            return self.typename + " [no contained value]"
+        if hasattr (self.visualizer, 'children'):
+            return self.typename + " containing " + self.visualizer.to_string ()
+        return self.typename
+
+class StdExpStringViewPrinter:
+    "Print a std::experimental::basic_string_view"
+
+    def __init__ (self, typename, val):
+        self.val = val
+
+    def to_string (self):
+        ptr = self.val['_M_str']
+        len = self.val['_M_len']
+        if hasattr (ptr, "lazy_string"):
+            return ptr.lazy_string (length = len)
+        return ptr.string (length = len)
+
+    def display_hint (self):
+        return 'string'
 
 # A "regular expression" printer which conforms to the
 # "SubPrettyPrinter" protocol from gdb.printing.
@@ -865,12 +985,12 @@ class Printer(object):
         self.subprinters = []
         self.lookup = {}
         self.enabled = True
-        self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)<.*>$')
+        self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$')
 
     def add(self, name, function):
         # A small sanity check.
         # FIXME
-        if not self.compiled_rx.match(name + '<>'):
+        if not self.compiled_rx.match(name):
             raise ValueError('libstdc++ programming error: "%s" does not match' % name)
         printer = RxPrinter(name, function)
         self.subprinters.append(printer)
@@ -1214,6 +1334,13 @@ def build_libstdcxx_dictionary ():
     libstdcxx_printer.add('std::__debug::forward_list',
                           StdForwardListPrinter)
 
+    # Library Fundamentals TS components
+    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
+                                  'any', StdExpAnyPrinter)
+    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
+                                  'optional', StdExpOptionalPrinter)
+    libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
+                                  'basic_string_view', StdExpStringViewPrinter)
 
     # Extensions.
     libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter)
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
new file mode 100644
index 0000000..e2f99a1
--- /dev/null
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc
@@ -0,0 +1,69 @@
+// { dg-do run }
+// { dg-options "-g -O0 -std=gnu++14" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <experimental/any>
+#include <experimental/optional>
+#include <experimental/string_view>
+#include <string>
+#include <map>
+
+using std::experimental::any;
+using std::experimental::optional;
+using std::experimental::string_view;
+
+int
+main()
+{
+  string_view str = "string";
+// { dg-final { note-test str "\"string\"" } }
+
+  optional<int> o;
+// { dg-final { note-test o {std::experimental::optional<int> [no contained value]} } }
+  optional<bool> ob{false};
+// { dg-final { note-test ob {std::experimental::optional<bool> = {[contained value] = false}} } }
+  optional<int> oi{5};
+// { dg-final { note-test oi {std::experimental::optional<int> = {[contained value] = 5}} } }
+  optional<void*> op{nullptr};
+// { dg-final { note-test op {std::experimental::optional<void *> = {[contained value] = 0x0}} } }
+  optional<std::map<int, double>> om;
+  om = std::map<int, double>{ {1, 2.}, {3, 4.}, {5, 6.} };
+// { dg-final { note-test om {std::experimental::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
+  optional<std::string> os{ "stringy" };
+// { dg-final { note-test os {std::experimental::optional<std::string> = {[contained value] = "stringy"}} } }
+
+  any a;
+// { dg-final { note-test a {std::experimental::any [no contained value]} } }
+  any ab(false);
+// { dg-final { note-test ab {std::experimental::any containing bool = {[contained value] = false}} } }
+  any ai(6);
+// { dg-final { note-test ai {std::experimental::any containing int = {[contained value] = 6}} } }
+  any ap = (void*)nullptr;
+// { dg-final { note-test ap {std::experimental::any containing void * = {[contained value] = 0x0}} } }
+  any as = *os;
+// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} } }
+  any as2("stringiest");
+// { dg-final { regexp-test as2 {std::experimental::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
+  any am = *om;
+// { dg-final { note-test am {std::experimental::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
+
+  return 0;			// Mark SPOT
+}
+
+// { dg-final { gdb-test SPOT } }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Add libstdc++ pretty printers for Library Fundamentals TS types
  2014-07-15 12:06 ` Jonathan Wakely
@ 2014-07-23 11:05   ` Jonathan Wakely
  2014-07-26 17:31     ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2014-07-23 11:05 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: tromey, pmuldoon

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On 15/07/14 13:03 +0100, Jonathan Wakely wrote:
>On 14/07/14 20:31 +0100, Jonathan Wakely wrote:
>>This adds printers for the types in the std::experimental namespace.

This should fix the test failures that Paolo and HJ are seeing, older
versions of GDB didn't have the gdb.Type.name attribute.

(I suppose I could have just put the full basic_string<char, ...> name
in explicitly instead of using lookup_type, but I'll just make this
fix for now.)

Committed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1114 bytes --]

commit 827e07f7e08bc993a284996f7772b04f82ee7fc9
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 23 11:40:02 2014 +0100

    	* python/libstdcxx/v6/printers.py (StdExpAnyPrinter): Convert type
    	to string instead of using gdb.Type.name attribute.

diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 625396b..15d7a88 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -899,7 +899,7 @@ class StdExpAnyPrinter(SingleObjContainerPrinter):
                 raise ValueError("Unknown manager function in std::experimental::any")
 
             # FIXME need to expand 'std::string' so that gdb.lookup_type works
-            mgrname = re.sub("std::string(?!\w)", gdb.lookup_type('std::string').strip_typedefs().name, m.group(1))
+            mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1))
             mgrtype = gdb.lookup_type(mgrname)
             self.contained_type = mgrtype.template_argument(0)
             valptr = None

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Add libstdc++ pretty printers for Library Fundamentals TS types
  2014-07-23 11:05   ` Jonathan Wakely
@ 2014-07-26 17:31     ` Paolo Carlini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Carlini @ 2014-07-26 17:31 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++, gcc-patches; +Cc: tromey, pmuldoon

Hi,

On 07/23/2014 12:45 PM, Jonathan Wakely wrote:
> On 15/07/14 13:03 +0100, Jonathan Wakely wrote:
>> On 14/07/14 20:31 +0100, Jonathan Wakely wrote:
>>> This adds printers for the types in the std::experimental namespace.
>
> This should fix the test failures that Paolo and HJ are seeing, older
> versions of GDB didn't have the gdb.Type.name attribute.
Confirmed fixed, by the way.

Thanks!
Paolo.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-26 17:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-14 19:48 [patch] Add libstdc++ pretty printers for Library Fundamentals TS types Jonathan Wakely
2014-07-15 12:06 ` Jonathan Wakely
2014-07-23 11:05   ` Jonathan Wakely
2014-07-26 17:31     ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).