Re: RFA: fix PR 51649

2012-01-30 Thread Tom Tromey
 Tom == Tom Tromey tro...@redhat.com writes:

Tom Unless you have other tests to suggest, I am going to say that it has
Tom been sufficiently tested and check it in on Friday.

Jakub said on irc that he thought I had done sufficient testing.
So, I am checking this patch in now.

thanks,
Tom


Re: RFA: fix PR 51649

2012-01-25 Thread Tom Tromey
 Jakub == Jakub Jelinek ja...@redhat.com writes:

Jakub Well, even bad debugging experience problems would be very undesirable
Jakub if we generated wrong debug info and everybody compiled it into their
Jakub sources.  But pretty-printers stay on the side, it is just a matter of
Jakub updating the python scripts and there is no need to recompile already
Jakub compiled/linked programs/libraries.  So if properly tested, I think
Jakub this could go in.

I tested them against gdb 7.3, 7.4 and trunk; configured both ways (with
--enable-symvers=gnu-versioned-namespace and the other way).

I also hacked the test suite so I could try gdb 7.2 (normally this is
rejected) and this worked as well as could be expected (7.2 had some
formatting issues leading to test suite failures -- but really it still
worked ok).

This patch also adds some test cases.

Unless you have other tests to suggest, I am going to say that it has
been sufficiently tested and check it in on Friday.

thanks,
Tom


Re: RFA: fix PR 51649

2012-01-24 Thread Richard Guenther
On Mon, Jan 23, 2012 at 8:36 PM, Tom Tromey tro...@redhat.com wrote:
 This patch fixes some pretty-printer bugs pointed out in PR 51649.

 The bug in the PR is that the pretty-printers don't work if you build
 with --enable-symvers=gnu-versioned-namespace.

 This patch adds test cases for all the changes I made.

 I derived most of the information here from reading c++config, then
 going through the existing printers one-by-one to see how they are
 implemented in the various modes.

 Still missing are tests for parallel and profile modes.

 I wasn't sure whether we need a printer for the stuff in vstring.h.
 Anybody know?

 The old code referred to a __norm namespace.  I only found a single
 instance of this in the tree, which seemed to indicate it is a
 compatibility thing.  So, I ignored it.  (I think that if there is a
 problem here we should start with a test that shows it...)

 I built and tested this with --enable-symvers=gnu-versioned-namespace
 and with the default on x86-64 Fedora 15.

 I'm sufficiently out of the loop gcc-wise that I will need some advice
 as to whether this can go in immediately or whether it must wait for
 some other stage.

We're technically in regression-fixes-only mode.  We give target/language
maintainers some extra freedom though - while C++/libstdc++ are considered
release critical and thus should not regress at this point I'm less sure
about all the pretty-printing stuff - it can't possibly break anything
but debugging
experience.

Richard.

 Ok?

 Tom

 2012-01-23  Tom Tromey  tro...@redhat.com

        PR libstdc++/51649:
        * testsuite/libstdc++-prettyprinters/debug.cc: New file.
        * testsuite/lib/gdb-test.exp (regexp-test): New proc.
        (note-test): Update.
        (gdb-test): Handle regexp tests.  Add some logging.
        * testsuite/libstdc++-prettyprinters/simple.cc: Compile with -O0.
        (placeholder, use): Remove.
        (main): Add tests for deque, list, map, and set iterators.  Add
        tests for slist and slist iterator.
        * testsuite/libstdc++-prettyprinters/48362.cc (main): Handle __7
        namespace.
        * python/libstdcxx/v6/printers.py (StdListPrinter.children): Use
        the type's _Node typedef.
        (StdListIteratorPrinter.to_string): Change how node type is
        computed.
        (StdSlistPrinter.children): Use the type's _Node typedef.
        (StdSlistIteratorPrinter.to_string): Likewise.
        (StdRbtreeIteratorPrinter.to_string): Use the type's _Link_type
        typedef.
        (StdMapPrinter.children): Change how the node's type is computed.
        (StdSetPrinter.children): Likewise.
        (StdForwardListPrinter.children): Use the type's _Node typedef.
        (Printer.add_version): New method.
        (Printer.add_container): New method.
        (build_libstdcxx_dictionary): Handle __7 and __cxx1998
        namespaces.
        (find_type): New function.

 Index: python/libstdcxx/v6/printers.py
 ===
 --- python/libstdcxx/v6/printers.py     (revision 183449)
 +++ python/libstdcxx/v6/printers.py     (working copy)
 @@ -1,6 +1,6 @@
  # Pretty-printers for libstc++.

 -# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
 +# Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.

  # This program is free software; you can redistribute it and/or modify
  # it under the terms of the GNU General Public License as published by
 @@ -26,6 +26,25 @@
  except ImportError:
     _use_gdb_pp = False

 +# Starting with the type ORIG, search for the member type NAME.  This
 +# handles searching upward through superclasses.  This is needed to
 +# work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615.
 +def find_type(orig, name):
 +    typ = orig.strip_typedefs()
 +    while True:
 +        search = str(typ) + '::' + name
 +        try:
 +            return gdb.lookup_type(search)
 +        except RuntimeError:
 +            pass
 +        # The type was not found, so try the superclass.  We only need
 +        # to check the first superclass, so we don't bother with
 +        # anything fancier here.
 +        field = typ.fields()[0]
 +        if not field.is_base_class:
 +            raise ValueError, Cannot find type %s::%s % (str(orig), name)
 +        typ = field.type
 +
  class StdPointerPrinter:
     Print a smart pointer of some kind

 @@ -76,15 +95,8 @@
         self.val = val

     def children(self):
 -        itype = self.val.type.template_argument(0)
 -        # If the inferior program is compiled with -D_GLIBCXX_DEBUG
 -        # some of the internal implementation details change.
 -        if self.typename == std::list:
 -            nodetype = gdb.lookup_type('std::_List_node%s' % 
 itype).pointer()
 -        elif self.typename == std::__debug::list:
 -            nodetype = gdb.lookup_type('std::__norm::_List_node%s' % 
 itype).pointer()
 -        else:
 -            raise ValueError, 

Re: RFA: fix PR 51649

2012-01-24 Thread Jakub Jelinek
On Tue, Jan 24, 2012 at 11:29:12AM +0100, Richard Guenther wrote:
 We're technically in regression-fixes-only mode.  We give target/language
 maintainers some extra freedom though - while C++/libstdc++ are considered
 release critical and thus should not regress at this point I'm less sure
 about all the pretty-printing stuff - it can't possibly break anything
 but debugging experience.

Well, even bad debugging experience problems would be very undesirable
if we generated wrong debug info and everybody compiled it into their
sources.  But pretty-printers stay on the side, it is just a matter of
updating the python scripts and there is no need to recompile already
compiled/linked programs/libraries.  So if properly tested, I think
this could go in.

Jakub


RFA: fix PR 51649

2012-01-23 Thread Tom Tromey
This patch fixes some pretty-printer bugs pointed out in PR 51649.

The bug in the PR is that the pretty-printers don't work if you build
with --enable-symvers=gnu-versioned-namespace.

This patch adds test cases for all the changes I made.

I derived most of the information here from reading c++config, then
going through the existing printers one-by-one to see how they are
implemented in the various modes.

Still missing are tests for parallel and profile modes.

I wasn't sure whether we need a printer for the stuff in vstring.h.
Anybody know?

The old code referred to a __norm namespace.  I only found a single
instance of this in the tree, which seemed to indicate it is a
compatibility thing.  So, I ignored it.  (I think that if there is a
problem here we should start with a test that shows it...)

I built and tested this with --enable-symvers=gnu-versioned-namespace
and with the default on x86-64 Fedora 15.

I'm sufficiently out of the loop gcc-wise that I will need some advice
as to whether this can go in immediately or whether it must wait for
some other stage.

Ok?

Tom

2012-01-23  Tom Tromey  tro...@redhat.com

PR libstdc++/51649:
* testsuite/libstdc++-prettyprinters/debug.cc: New file.
* testsuite/lib/gdb-test.exp (regexp-test): New proc.
(note-test): Update.
(gdb-test): Handle regexp tests.  Add some logging.
* testsuite/libstdc++-prettyprinters/simple.cc: Compile with -O0.
(placeholder, use): Remove.
(main): Add tests for deque, list, map, and set iterators.  Add
tests for slist and slist iterator.
* testsuite/libstdc++-prettyprinters/48362.cc (main): Handle __7
namespace.
* python/libstdcxx/v6/printers.py (StdListPrinter.children): Use
the type's _Node typedef.
(StdListIteratorPrinter.to_string): Change how node type is
computed.
(StdSlistPrinter.children): Use the type's _Node typedef.
(StdSlistIteratorPrinter.to_string): Likewise.
(StdRbtreeIteratorPrinter.to_string): Use the type's _Link_type
typedef.
(StdMapPrinter.children): Change how the node's type is computed.
(StdSetPrinter.children): Likewise.
(StdForwardListPrinter.children): Use the type's _Node typedef.
(Printer.add_version): New method.
(Printer.add_container): New method.
(build_libstdcxx_dictionary): Handle __7 and __cxx1998
namespaces.
(find_type): New function.

Index: python/libstdcxx/v6/printers.py
===
--- python/libstdcxx/v6/printers.py (revision 183449)
+++ python/libstdcxx/v6/printers.py (working copy)
@@ -1,6 +1,6 @@
 # Pretty-printers for libstc++.
 
-# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,6 +26,25 @@
 except ImportError:
 _use_gdb_pp = False
 
+# Starting with the type ORIG, search for the member type NAME.  This
+# handles searching upward through superclasses.  This is needed to
+# work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615.
+def find_type(orig, name):
+typ = orig.strip_typedefs()
+while True:
+search = str(typ) + '::' + name
+try:
+return gdb.lookup_type(search)
+except RuntimeError:
+pass
+# The type was not found, so try the superclass.  We only need
+# to check the first superclass, so we don't bother with
+# anything fancier here.
+field = typ.fields()[0]
+if not field.is_base_class:
+raise ValueError, Cannot find type %s::%s % (str(orig), name)
+typ = field.type
+
 class StdPointerPrinter:
 Print a smart pointer of some kind
 
@@ -76,15 +95,8 @@
 self.val = val
 
 def children(self):
-itype = self.val.type.template_argument(0)
-# If the inferior program is compiled with -D_GLIBCXX_DEBUG
-# some of the internal implementation details change.
-if self.typename == std::list:
-nodetype = gdb.lookup_type('std::_List_node%s' % itype).pointer()
-elif self.typename == std::__debug::list:
-nodetype = gdb.lookup_type('std::__norm::_List_node%s' % 
itype).pointer()
-else:
-raise ValueError, Cannot cast list node for list printer.
+nodetype = find_type(self.val.type, '_Node')
+nodetype = nodetype.strip_typedefs().pointer()
 return self._iterator(nodetype, self.val['_M_impl']['_M_node'])
 
 def to_string(self):
@@ -100,15 +112,8 @@
 self.typename = typename
 
 def to_string(self):
-itype = self.val.type.template_argument(0)
-# If the inferior program is compiled with -D_GLIBCXX_DEBUG
-