Commit 3efe2bf7 by Tom Tromey Committed by Tom Tromey

re PR libstdc++/51649 (pretty printers don't handle std::__7:: namespace)

	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.

From-SVN: r183732
parent e799d447
2012-01-30 Tom Tromey <tromey@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.
2012-01-27 Paolo Carlini <paolo.carlini@oracle.com> 2012-01-27 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/51795 PR libstdc++/51795
......
# Pretty-printers for libstc++. # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -26,6 +26,25 @@ try: ...@@ -26,6 +26,25 @@ try:
except ImportError: except ImportError:
_use_gdb_pp = False _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: class StdPointerPrinter:
"Print a smart pointer of some kind" "Print a smart pointer of some kind"
...@@ -76,15 +95,8 @@ class StdListPrinter: ...@@ -76,15 +95,8 @@ class StdListPrinter:
self.val = val self.val = val
def children(self): def children(self):
itype = self.val.type.template_argument(0) nodetype = find_type(self.val.type, '_Node')
# If the inferior program is compiled with -D_GLIBCXX_DEBUG nodetype = nodetype.strip_typedefs().pointer()
# 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."
return self._iterator(nodetype, self.val['_M_impl']['_M_node']) return self._iterator(nodetype, self.val['_M_impl']['_M_node'])
def to_string(self): def to_string(self):
...@@ -100,15 +112,8 @@ class StdListIteratorPrinter: ...@@ -100,15 +112,8 @@ class StdListIteratorPrinter:
self.typename = typename self.typename = typename
def to_string(self): def to_string(self):
itype = self.val.type.template_argument(0) nodetype = find_type(self.val.type, '_Node')
# If the inferior program is compiled with -D_GLIBCXX_DEBUG nodetype = nodetype.strip_typedefs().pointer()
# some of the internal implementation details change.
if self.typename == "std::_List_iterator" or self.typename == "std::_List_const_iterator":
nodetype = gdb.lookup_type('std::_List_node<%s>' % itype).pointer()
elif self.typename == "std::__norm::_List_iterator" or self.typename == "std::__norm::_List_const_iterator":
nodetype = gdb.lookup_type('std::__norm::_List_node<%s>' % itype).pointer()
else:
raise ValueError, "Cannot cast list node for list iterator printer."
return self.val['_M_node'].cast(nodetype).dereference()['_M_data'] return self.val['_M_node'].cast(nodetype).dereference()['_M_data']
class StdSlistPrinter: class StdSlistPrinter:
...@@ -136,8 +141,8 @@ class StdSlistPrinter: ...@@ -136,8 +141,8 @@ class StdSlistPrinter:
self.val = val self.val = val
def children(self): def children(self):
itype = self.val.type.template_argument(0) nodetype = find_type(self.val.type, '_Node')
nodetype = gdb.lookup_type('__gnu_cxx::_Slist_node<%s>' % itype).pointer() nodetype = nodetype.strip_typedefs().pointer()
return self._iterator(nodetype, self.val) return self._iterator(nodetype, self.val)
def to_string(self): def to_string(self):
...@@ -152,8 +157,8 @@ class StdSlistIteratorPrinter: ...@@ -152,8 +157,8 @@ class StdSlistIteratorPrinter:
self.val = val self.val = val
def to_string(self): def to_string(self):
itype = self.val.type.template_argument(0) nodetype = find_type(self.val.type, '_Node')
nodetype = gdb.lookup_type('__gnu_cxx::_Slist_node<%s>' % itype).pointer() nodetype = nodetype.strip_typedefs().pointer()
return self.val['_M_node'].cast(nodetype).dereference()['_M_data'] return self.val['_M_node'].cast(nodetype).dereference()['_M_data']
class StdVectorPrinter: class StdVectorPrinter:
...@@ -364,9 +369,8 @@ class StdRbtreeIteratorPrinter: ...@@ -364,9 +369,8 @@ class StdRbtreeIteratorPrinter:
self.val = val self.val = val
def to_string (self): def to_string (self):
valuetype = self.val.type.template_argument(0) typename = str(self.val.type.strip_typedefs()) + '::_Link_type'
nodetype = gdb.lookup_type('std::_Rb_tree_node < %s >' % valuetype) nodetype = gdb.lookup_type(typename).strip_typedefs()
nodetype = nodetype.pointer()
return self.val.cast(nodetype).dereference()['_M_value_field'] return self.val.cast(nodetype).dereference()['_M_value_field']
class StdDebugIteratorPrinter: class StdDebugIteratorPrinter:
...@@ -415,11 +419,10 @@ class StdMapPrinter: ...@@ -415,11 +419,10 @@ class StdMapPrinter:
len (RbtreeIterator (self.val))) len (RbtreeIterator (self.val)))
def children (self): def children (self):
keytype = self.val.type.template_argument(0).const() rep_type = find_type(self.val.type, '_Rep_type')
valuetype = self.val.type.template_argument(1) node = find_type(rep_type, '_Link_type')
nodetype = gdb.lookup_type('std::_Rb_tree_node< std::pair< %s, %s > >' % (keytype, valuetype)) node = node.strip_typedefs()
nodetype = nodetype.pointer() return self._iter (RbtreeIterator (self.val), node)
return self._iter (RbtreeIterator (self.val), nodetype)
def display_hint (self): def display_hint (self):
return 'map' return 'map'
...@@ -455,9 +458,10 @@ class StdSetPrinter: ...@@ -455,9 +458,10 @@ class StdSetPrinter:
len (RbtreeIterator (self.val))) len (RbtreeIterator (self.val)))
def children (self): def children (self):
keytype = self.val.type.template_argument(0) rep_type = find_type(self.val.type, '_Rep_type')
nodetype = gdb.lookup_type('std::_Rb_tree_node< %s >' % keytype).pointer() node = find_type(rep_type, '_Link_type')
return self._iter (RbtreeIterator (self.val), nodetype) node = node.strip_typedefs()
return self._iter (RbtreeIterator (self.val), node)
class StdBitsetPrinter: class StdBitsetPrinter:
"Print a std::bitset" "Print a std::bitset"
...@@ -713,15 +717,8 @@ class StdForwardListPrinter: ...@@ -713,15 +717,8 @@ class StdForwardListPrinter:
self.typename = typename self.typename = typename
def children(self): def children(self):
itype = self.val.type.template_argument(0) nodetype = find_type(self.val.type, '_Node')
# If the inferior program is compiled with -D_GLIBCXX_DEBUG nodetype = nodetype.strip_typedefs().pointer()
# some of the internal implementation details change.
if self.typename == "std::forward_list":
nodetype = gdb.lookup_type('std::_Fwd_list_node<%s>' % itype).pointer()
elif self.typename == "std::__debug::list":
nodetype = gdb.lookup_type('std::__norm::_Fwd_list_node<%s>' % itype).pointer()
else:
raise ValueError, "Cannot cast forward_list node for forward_list printer."
return self._iterator(nodetype, self.val['_M_impl']['_M_head']) return self._iterator(nodetype, self.val['_M_impl']['_M_head'])
def to_string(self): def to_string(self):
...@@ -764,6 +761,16 @@ class Printer(object): ...@@ -764,6 +761,16 @@ class Printer(object):
self.subprinters.append(printer) self.subprinters.append(printer)
self.lookup[name] = printer self.lookup[name] = printer
# Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION.
def add_version(self, base, name, function):
self.add(base + name, function)
self.add(base + '__7::' + name, function)
# Add a name using _GLIBCXX_BEGIN_NAMESPACE_CONTAINER.
def add_container(self, base, name, function):
self.add_version(base, name, function)
self.add_version(base + '__cxx1998::', name, function)
@staticmethod @staticmethod
def get_basic_type(type): def get_basic_type(type):
# If it points to a reference, get the reference. # If it points to a reference, get the reference.
...@@ -813,23 +820,29 @@ def build_libstdcxx_dictionary (): ...@@ -813,23 +820,29 @@ def build_libstdcxx_dictionary ():
libstdcxx_printer = Printer("libstdc++-v6") libstdcxx_printer = Printer("libstdc++-v6")
# For _GLIBCXX_BEGIN_NAMESPACE_VERSION.
vers = '(__7::)?'
# For _GLIBCXX_BEGIN_NAMESPACE_CONTAINER.
container = '(__cxx1998::' + vers + ')?'
# libstdc++ objects requiring pretty-printing. # libstdc++ objects requiring pretty-printing.
# In order from: # In order from:
# http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html # http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html
libstdcxx_printer.add('std::basic_string', StdStringPrinter) libstdcxx_printer.add_version('std::', 'basic_string', StdStringPrinter)
libstdcxx_printer.add('std::bitset', StdBitsetPrinter) libstdcxx_printer.add_container('std::', 'bitset', StdBitsetPrinter)
libstdcxx_printer.add('std::deque', StdDequePrinter) libstdcxx_printer.add_container('std::', 'deque', StdDequePrinter)
libstdcxx_printer.add('std::list', StdListPrinter) libstdcxx_printer.add_container('std::', 'list', StdListPrinter)
libstdcxx_printer.add('std::map', StdMapPrinter) libstdcxx_printer.add_container('std::', 'map', StdMapPrinter)
libstdcxx_printer.add('std::multimap', StdMapPrinter) libstdcxx_printer.add_container('std::', 'multimap', StdMapPrinter)
libstdcxx_printer.add('std::multiset', StdSetPrinter) libstdcxx_printer.add_container('std::', 'multiset', StdSetPrinter)
libstdcxx_printer.add('std::priority_queue', StdStackOrQueuePrinter) libstdcxx_printer.add_version('std::', 'priority_queue',
libstdcxx_printer.add('std::queue', StdStackOrQueuePrinter) StdStackOrQueuePrinter)
libstdcxx_printer.add('std::tuple', StdTuplePrinter) libstdcxx_printer.add_version('std::', 'queue', StdStackOrQueuePrinter)
libstdcxx_printer.add('std::set', StdSetPrinter) libstdcxx_printer.add_version('std::', 'tuple', StdTuplePrinter)
libstdcxx_printer.add('std::stack', StdStackOrQueuePrinter) libstdcxx_printer.add_container('std::', 'set', StdSetPrinter)
libstdcxx_printer.add('std::unique_ptr', UniquePointerPrinter) libstdcxx_printer.add_version('std::', 'stack', StdStackOrQueuePrinter)
libstdcxx_printer.add('std::vector', StdVectorPrinter) libstdcxx_printer.add_version('std::', 'unique_ptr', UniquePointerPrinter)
libstdcxx_printer.add_container('std::', 'vector', StdVectorPrinter)
# vector<bool> # vector<bool>
# Printer registrations for classes compiled with -D_GLIBCXX_DEBUG. # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.
...@@ -849,21 +862,28 @@ def build_libstdcxx_dictionary (): ...@@ -849,21 +862,28 @@ def build_libstdcxx_dictionary ():
# These are the TR1 and C++0x printers. # These are the TR1 and C++0x printers.
# For array - the default GDB pretty-printer seems reasonable. # For array - the default GDB pretty-printer seems reasonable.
libstdcxx_printer.add('std::shared_ptr', StdPointerPrinter) libstdcxx_printer.add_version('std::', 'shared_ptr', StdPointerPrinter)
libstdcxx_printer.add('std::weak_ptr', StdPointerPrinter) libstdcxx_printer.add_version('std::', 'weak_ptr', StdPointerPrinter)
libstdcxx_printer.add('std::unordered_map', Tr1UnorderedMapPrinter) libstdcxx_printer.add_container('std::', 'unordered_map',
libstdcxx_printer.add('std::unordered_set', Tr1UnorderedSetPrinter) Tr1UnorderedMapPrinter)
libstdcxx_printer.add('std::unordered_multimap', Tr1UnorderedMapPrinter) libstdcxx_printer.add_container('std::', 'unordered_set',
libstdcxx_printer.add('std::unordered_multiset', Tr1UnorderedSetPrinter) Tr1UnorderedSetPrinter)
libstdcxx_printer.add('std::forward_list', StdForwardListPrinter) libstdcxx_printer.add_container('std::', 'unordered_multimap',
libstdcxx_printer.add('std::tr1::shared_ptr', StdPointerPrinter)
libstdcxx_printer.add('std::tr1::weak_ptr', StdPointerPrinter)
libstdcxx_printer.add('std::tr1::unordered_map', Tr1UnorderedMapPrinter)
libstdcxx_printer.add('std::tr1::unordered_set', Tr1UnorderedSetPrinter)
libstdcxx_printer.add('std::tr1::unordered_multimap',
Tr1UnorderedMapPrinter) Tr1UnorderedMapPrinter)
libstdcxx_printer.add('std::tr1::unordered_multiset', libstdcxx_printer.add_container('std::', 'unordered_multiset',
Tr1UnorderedSetPrinter)
libstdcxx_printer.add_container('std::', 'forward_list',
StdForwardListPrinter)
libstdcxx_printer.add_version('std::tr1::', 'shared_ptr', StdPointerPrinter)
libstdcxx_printer.add_version('std::tr1::', 'weak_ptr', StdPointerPrinter)
libstdcxx_printer.add_version('std::tr1::', 'unordered_map',
Tr1UnorderedMapPrinter)
libstdcxx_printer.add_version('std::tr1::', 'unordered_set',
Tr1UnorderedSetPrinter)
libstdcxx_printer.add_version('std::tr1::', 'unordered_multimap',
Tr1UnorderedMapPrinter)
libstdcxx_printer.add_version('std::tr1::', 'unordered_multiset',
Tr1UnorderedSetPrinter) Tr1UnorderedSetPrinter)
# These are the C++0x printer registrations for -D_GLIBCXX_DEBUG cases. # These are the C++0x printer registrations for -D_GLIBCXX_DEBUG cases.
...@@ -882,24 +902,26 @@ def build_libstdcxx_dictionary (): ...@@ -882,24 +902,26 @@ def build_libstdcxx_dictionary ():
# Extensions. # Extensions.
libstdcxx_printer.add('__gnu_cxx::slist', StdSlistPrinter) libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter)
if True: if True:
# These shouldn't be necessary, if GDB "print *i" worked. # These shouldn't be necessary, if GDB "print *i" worked.
# But it often doesn't, so here they are. # But it often doesn't, so here they are.
libstdcxx_printer.add('std::_List_iterator', StdListIteratorPrinter) libstdcxx_printer.add_container('std::', '_List_iterator',
libstdcxx_printer.add('std::_List_const_iterator',
StdListIteratorPrinter) StdListIteratorPrinter)
libstdcxx_printer.add('std::_Rb_tree_iterator', libstdcxx_printer.add_container('std::', '_List_const_iterator',
StdListIteratorPrinter)
libstdcxx_printer.add_version('std::', '_Rb_tree_iterator',
StdRbtreeIteratorPrinter) StdRbtreeIteratorPrinter)
libstdcxx_printer.add('std::_Rb_tree_const_iterator', libstdcxx_printer.add_version('std::', '_Rb_tree_const_iterator',
StdRbtreeIteratorPrinter) StdRbtreeIteratorPrinter)
libstdcxx_printer.add('std::_Deque_iterator', StdDequeIteratorPrinter) libstdcxx_printer.add_container('std::', '_Deque_iterator',
libstdcxx_printer.add('std::_Deque_const_iterator', StdDequeIteratorPrinter)
libstdcxx_printer.add_container('std::', '_Deque_const_iterator',
StdDequeIteratorPrinter) StdDequeIteratorPrinter)
libstdcxx_printer.add('__gnu_cxx::__normal_iterator', libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator',
StdVectorIteratorPrinter) StdVectorIteratorPrinter)
libstdcxx_printer.add('__gnu_cxx::_Slist_iterator', libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator',
StdSlistIteratorPrinter) StdSlistIteratorPrinter)
# Debug (compiled with -D_GLIBCXX_DEBUG) printer # Debug (compiled with -D_GLIBCXX_DEBUG) printer
......
# Copyright (C) 2009, 2011 Free Software Foundation, Inc. # Copyright (C) 2009, 2011, 2012 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
...@@ -55,11 +55,20 @@ proc get_line_number {filename marker} { ...@@ -55,11 +55,20 @@ proc get_line_number {filename marker} {
proc note-test {var result} { proc note-test {var result} {
global gdb_tests global gdb_tests
lappend gdb_tests $var $result lappend gdb_tests $var $result 0
}
# A test that uses a regular expression. This is like note-test, but
# the result is a regular expression that is matched against the
# output.
proc regexp-test {var result} {
global gdb_tests
lappend gdb_tests $var $result 1
} }
# Utility for testing variable values using gdb, invoked via dg-final. # Utility for testing variable values using gdb, invoked via dg-final.
# Tests all tests indicated by note-test. # Tests all tests indicated by note-test and regexp-test.
# #
# Argument 0 is the marker on which to put a breakpoint # Argument 0 is the marker on which to put a breakpoint
# Argument 2 handles expected failures and the like # Argument 2 handles expected failures and the like
...@@ -100,11 +109,12 @@ proc gdb-test { marker {selector {}} } { ...@@ -100,11 +109,12 @@ proc gdb-test { marker {selector {}} } {
puts $fd "run" puts $fd "run"
set count 0 set count 0
foreach {var result} $gdb_tests { foreach {var result is_regexp} $gdb_tests {
puts $fd "print $var" puts $fd "print $var"
incr count incr count
set gdb_var($count) $var set gdb_var($count) $var
set gdb_expected($count) $result set gdb_expected($count) $result
set gdb_is_regexp($count) $is_regexp
} }
set gdb_tests {} set gdb_tests {}
...@@ -120,9 +130,18 @@ proc gdb-test { marker {selector {}} } { ...@@ -120,9 +130,18 @@ proc gdb-test { marker {selector {}} } {
remote_expect target [timeout_value] { remote_expect target [timeout_value] {
-re {^\$([0-9]+) = ([^\n\r]*)[\n\r]+} { -re {^\$([0-9]+) = ([^\n\r]*)[\n\r]+} {
send_log "got: $expect_out(buffer)"
set num $expect_out(1,string) set num $expect_out(1,string)
set first $expect_out(2,string) set first $expect_out(2,string)
if { ![string compare $first $gdb_expected($num)] } {
if {$gdb_is_regexp($num)} {
set match [regexp -- $gdb_expected($num) $first]
} else {
set match [expr {![string compare $first $gdb_expected($num)]}]
}
if {$match} {
pass "$testname print $gdb_var($num)" pass "$testname print $gdb_var($num)"
} else { } else {
fail "$testname print $gdb_var($num)" fail "$testname print $gdb_var($num)"
...@@ -145,7 +164,7 @@ proc gdb-test { marker {selector {}} } { ...@@ -145,7 +164,7 @@ proc gdb-test { marker {selector {}} } {
} }
-re {^[^$][^\n\r]*[\n\r]+} { -re {^[^$][^\n\r]*[\n\r]+} {
verbose "skipping: $expect_out(buffer)" send_log "skipping: $expect_out(buffer)"
exp_continue exp_continue
} }
......
// { dg-do run } // { dg-do run }
// { dg-options "-g -std=gnu++11 -O0" } // { dg-options "-g -std=gnu++11 -O0" }
// Copyright (C) 2011 Free Software Foundation, Inc. // Copyright (C) 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -25,10 +25,10 @@ int ...@@ -25,10 +25,10 @@ int
main() main()
{ {
std::tuple<> t1; std::tuple<> t1;
// { dg-final { note-test t1 {empty std::tuple} } } // { dg-final { regexp-test t1 {empty std::(__7::)?tuple} } }
std::tuple<std::string, int, std::tuple<>> t2{ "Johnny", 5, {} }; std::tuple<std::string, int, std::tuple<>> t2{ "Johnny", 5, {} };
// { dg-final { note-test t2 {std::tuple containing = {[1] = "Johnny", [2] = 5, [3] = {<std::tuple<>> = empty std::tuple, <No data fields>}}} } } // { dg-final { regexp-test t2 {std::(__7::)?tuple containing = {\[1\] = "Johnny", \[2\] = 5, \[3\] = {<std::(__7::)?tuple<>> = empty std::(__7::)?tuple, <No data fields>}}} } }
return 0; // Mark SPOT return 0; // Mark SPOT
} }
......
// { dg-do run }
// { dg-options "-g -O0" }
// Copyright (C) 2011, 2012 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/>.
#define _GLIBCXX_DEBUG
#include <string>
#include <deque>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <ext/slist>
int
main()
{
std::string tem;
std::string str = "zardoz";
// { dg-final { note-test str "\"zardoz\"" } }
std::bitset<10> bs;
bs[0] = 1;
bs[5] = 1;
bs[7] = 1;
// { dg-final { note-test bs {std::__debug::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
std::deque<std::string> deq;
deq.push_back("one");
deq.push_back("two");
// { dg-final { note-test deq {std::__debug::deque with 2 elements = {"one", "two"}} } }
std::deque<std::string>::iterator deqiter = deq.begin();
// { dg-final { note-test deqiter {"one"} } }
std::list<std::string> lst;
lst.push_back("one");
lst.push_back("two");
// { dg-final { note-test lst {std::__debug::list = {[0] = "one", [1] = "two"}} } }
std::list<std::string>::iterator lstiter = lst.begin();
tem = *lstiter;
// { dg-final { note-test lstiter {"one"}} }
std::list<std::string>::const_iterator lstciter = lst.begin();
tem = *lstciter;
// { dg-final { note-test lstciter {"one"}} }
std::map<std::string, int> mp;
mp["zardoz"] = 23;
// { dg-final { note-test mp {std::__debug::map with 1 elements = {["zardoz"] = 23}} } }
std::map<std::string, int>::iterator mpiter = mp.begin();
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
std::set<std::string> sp;
sp.insert("clownfish");
sp.insert("barrel");
// { dg-final { note-test sp {std::__debug::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
std::set<std::string>::const_iterator spciter = sp.begin();
// { dg-final { note-test spciter {"barrel"} } }
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);
// { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
__gnu_cxx::slist<int>::iterator slliter = sll.begin();
// { dg-final { note-test slliter {47} } }
return 0; // Mark SPOT
}
// { dg-final { gdb-test SPOT } }
// If you modify this, please update debug.cc as well.
// { dg-do run } // { dg-do run }
// { dg-options "-g" } // { dg-options "-g -O0" }
// Copyright (C) 2011 Free Software Foundation, Inc. // Copyright (C) 2011, 2012 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // 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 // software; you can redistribute it and/or modify it under the
...@@ -24,34 +26,13 @@ ...@@ -24,34 +26,13 @@
#include <iostream> #include <iostream>
#include <list> #include <list>
#include <map> #include <map>
#include <set>
template<class T> #include <ext/slist>
void
placeholder(const T &s)
{
std::cout << s;
}
template<class T, class S>
void
placeholder(const std::pair<T,S> &s)
{
std::cout << s.first;
}
template<class T>
void
use(const T &container)
{
for (typename T::const_iterator i = container.begin();
i != container.end();
++i)
placeholder(*i);
}
int int
main() main()
{ {
std::string tem;
std::string str = "zardoz"; std::string str = "zardoz";
// { dg-final { note-test str "\"zardoz\"" } } // { dg-final { note-test str "\"zardoz\"" } }
...@@ -66,22 +47,46 @@ main() ...@@ -66,22 +47,46 @@ main()
deq.push_back("two"); deq.push_back("two");
// { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } } // { dg-final { note-test deq {std::deque with 2 elements = {"one", "two"}} } }
std::deque<std::string>::iterator deqiter = deq.begin();
// { dg-final { note-test deqiter {"one"} } }
std::list<std::string> lst; std::list<std::string> lst;
lst.push_back("one"); lst.push_back("one");
lst.push_back("two"); lst.push_back("two");
// { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } } // { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } }
std::list<std::string>::iterator lstiter = lst.begin();
tem = *lstiter;
// { dg-final { note-test lstiter {"one"}} }
std::list<std::string>::const_iterator lstciter = lst.begin();
tem = *lstciter;
// { dg-final { note-test lstciter {"one"}} }
std::map<std::string, int> mp; std::map<std::string, int> mp;
mp["zardoz"] = 23; mp["zardoz"] = 23;
// { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } } // { dg-final { note-test mp {std::map with 1 elements = {["zardoz"] = 23}} } }
placeholder(str); // Mark SPOT std::map<std::string, int>::iterator mpiter = mp.begin();
std::cout << bs; // { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
use(deq);
use(lst); std::set<std::string> sp;
use(mp); sp.insert("clownfish");
sp.insert("barrel");
// { dg-final { note-test sp {std::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
std::set<std::string>::const_iterator spciter = sp.begin();
// { dg-final { note-test spciter {"barrel"} } }
__gnu_cxx::slist<int> sll;
sll.push_front(23);
sll.push_front(47);
// { dg-final { note-test sll {__gnu_cxx::slist = {[0] = 47, [1] = 23}} } }
__gnu_cxx::slist<int>::iterator slliter = sll.begin();
// { dg-final { note-test slliter {47} } }
return 0; return 0; // Mark SPOT
} }
// { dg-final { gdb-test SPOT } } // { dg-final { gdb-test SPOT } }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment