+2019-05-06 François Dumont <fdumont@gcc.gnu.org>
+
+ * python/libstdcxx/v6/printers.py (add_one_template_type_printer):
+ Add type printer for container types in std::__debug namespace.
+ * testsuite/lib/gdb-test.exp (whatis-regexp-test): New.
+ (gdb-tests): Use distinct parameters for the type of test and use of
+ regex.
+ (gdb-test): Check for regex test even if 'whatis' test.
+ * testsuite/libstdc++-prettyprinters/80276.cc: Adapt for _GLIBCXX_DEBUG
+ mode.
+ * testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise.
+ * testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
+ * testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
+ * testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
+ * testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
+ * testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
+ * testsuite/libstdc++-prettyprinters/whatis2.cc: Likewise.
+
2019-05-04 Jonathan Wakely <jwakely@redhat.com>
* include/std/system_error (error_category): Fix comment.
"""
printer = TemplateTypePrinter('std::'+name, defargs)
gdb.types.register_type_printer(obj, printer)
+
+ # Add type printer for same type in debug namespace:
+ printer = TemplateTypePrinter('std::__debug::'+name, defargs)
+ gdb.types.register_type_printer(obj, printer)
+
if _versioned_namespace:
# Add second type printer for same type in versioned namespace:
ns = 'std::' + _versioned_namespace
proc note-test {var result} {
global gdb_tests
- lappend gdb_tests $var $result 0
+ lappend gdb_tests $var $result print 0
}
# A test that uses a regular expression. This is like note-test, but
proc regexp-test {var result} {
global gdb_tests
- lappend gdb_tests $var $result 1
+ lappend gdb_tests $var $result print 1
}
# A test of 'whatis'. This tests a type rather than a variable.
proc whatis-test {var result} {
global gdb_tests
- lappend gdb_tests $var $result whatis
+ lappend gdb_tests $var $result whatis 0
+}
+
+# A test of 'whatis' that uses a regular expression. This tests a type rather
+# than a variable.
+proc whatis-regexp-test {var result} {
+ global gdb_tests
+
+ lappend gdb_tests $var $result whatis 1
}
# Utility for testing variable values using gdb, invoked via dg-final.
puts $fd "info share"
set count 0
- foreach {var result kind} $gdb_tests {
+ foreach {var result kind rexp} $gdb_tests {
incr count
set gdb_var($count) $var
set gdb_expected($count) $result
if {$kind == "whatis"} {
if {$do_whatis_tests} {
set gdb_is_type($count) 1
+ set gdb_is_regexp($count) $rexp
set gdb_command($count) "whatis $var"
} else {
unsupported "$testname"
}
} else {
set gdb_is_type($count) 0
- set gdb_is_regexp($count) $kind
+ set gdb_is_regexp($count) $rexp
set gdb_command($count) "print $var"
}
puts $fd $gdb_command($count)
if {$expect_out(1,string) != "type"} {
error "gdb failure"
}
- set match [expr {![string compare $first \
- $gdb_expected($test_counter)]}]
- } elseif {$gdb_is_regexp($test_counter)} {
+ }
+
+ if {$gdb_is_regexp($test_counter)} {
set match [regexp -- $gdb_expected($test_counter) $first]
} else {
set match [expr {![string compare $first \
unique_ptr<vector<unique_ptr<set<int>*>>[]> p2;
unique_ptr<set<unique_ptr<vector<int>*>>[10]> p3;
unique_ptr<vector<unique_ptr<list<std::string>[]>>[99]> p4;
- // { dg-final { whatis-test p1 "std::unique_ptr<std::vector<std::unique_ptr<std::vector<int>*>>>" } }
- // { dg-final { whatis-test p2 "std::unique_ptr<std::vector<std::unique_ptr<std::set<int>*>>\[\]>" } }
- // { dg-final { whatis-test p3 "std::unique_ptr<std::set<std::unique_ptr<std::vector<int>*>>\[10\]>" } }
- // { dg-final { whatis-test p4 "std::unique_ptr<std::vector<std::unique_ptr<std::list<std::string>\[\]>>\[99\]>" } }
+ // { dg-final { whatis-regexp-test p1 "std::unique_ptr<std::(__debug::)?vector<std::unique_ptr<std::(__debug::)?vector<int>\\*>>>" } }
+ // { dg-final { whatis-regexp-test p2 "std::unique_ptr<std::(__debug::)?vector<std::unique_ptr<std::(__debug::)?set<int>\\*>>\\\[\\\]>" } }
+ // { dg-final { whatis-regexp-test p3 "std::unique_ptr<std::(__debug::)?set<std::unique_ptr<std::(__debug::)?vector<int>\\*>>\\\[10\\\]>" } }
+ // { dg-final { whatis-regexp-test p4 "std::unique_ptr<std::(__debug::)?vector<std::unique_ptr<std::(__debug::)?list<std::string>\\\[\\\]>>\\\[99\\\]>" } }
placeholder(&p1); // Mark SPOT
placeholder(&p2);
main()
{
std::forward_list<int> efl;
-// { dg-final { note-test efl "empty std::forward_list" } }
+// { dg-final { regexp-test efl "empty std::(__debug::)?forward_list" } }
std::forward_list<int> &refl = efl;
-// { dg-final { note-test refl "empty std::forward_list" } }
+// { dg-final { regexp-test refl "empty std::(__debug::)?forward_list" } }
std::forward_list<int> fl;
fl.push_front(2);
fl.push_front(1);
-// { dg-final { note-test fl {std::forward_list = {[0] = 1, [1] = 2}} } }
+// { dg-final { regexp-test fl {std::(__debug::)?forward_list = {\[0\] = 1, \[1\] = 2}} } }
std::forward_list<int> &rfl = fl;
-// { dg-final { note-test rfl {std::forward_list = {[0] = 1, [1] = 2}} } }
+// { dg-final { regexp-test rfl {std::(__debug::)?forward_list = {\[0\] = 1, \[1\] = 2}} } }
std::unordered_map<int, std::string> eum;
-// { dg-final { note-test eum "std::unordered_map with 0 elements" } }
+// { dg-final { regexp-test eum "std::(__debug::)?unordered_map with 0 elements" } }
std::unordered_map<int, std::string> &reum = eum;
-// { dg-final { note-test reum "std::unordered_map with 0 elements" } }
+// { dg-final { regexp-test reum "std::(__debug::)?unordered_map with 0 elements" } }
std::unordered_multimap<int, std::string> eumm;
-// { dg-final { note-test eumm "std::unordered_multimap with 0 elements" } }
+// { dg-final { regexp-test eumm "std::(__debug::)?unordered_multimap with 0 elements" } }
std::unordered_multimap<int, std::string> &reumm = eumm;
-// { dg-final { note-test reumm "std::unordered_multimap with 0 elements" } }
+// { dg-final { regexp-test reumm "std::(__debug::)?unordered_multimap with 0 elements" } }
std::unordered_set<int> eus;
-// { dg-final { note-test eus "std::unordered_set with 0 elements" } }
+// { dg-final { regexp-test eus "std::(__debug::)?unordered_set with 0 elements" } }
std::unordered_set<int> &reus = eus;
-// { dg-final { note-test reus "std::unordered_set with 0 elements" } }
+// { dg-final { regexp-test reus "std::(__debug::)?unordered_set with 0 elements" } }
std::unordered_multiset<int> eums;
-// { dg-final { note-test eums "std::unordered_multiset with 0 elements" } }
+// { dg-final { regexp-test eums "std::(__debug::)?unordered_multiset with 0 elements" } }
std::unordered_multiset<int> &reums = eums;
-// { dg-final { note-test reums "std::unordered_multiset with 0 elements" } }
+// { dg-final { regexp-test reums "std::(__debug::)?unordered_multiset with 0 elements" } }
std::unordered_map<int, std::string> uom;
uom[5] = "three";
uom[3] = "seven";
-// { dg-final { note-test uom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } }
+// { dg-final { regexp-test uom {std::(__debug::)?unordered_map with 2 elements = {\[3\] = "seven", \[5\] = "three"}} } }
std::unordered_map<int, std::string> &ruom = uom;
-// { dg-final { note-test ruom {std::unordered_map with 2 elements = {[3] = "seven", [5] = "three"}} } }
+// { dg-final { regexp-test ruom {std::(__debug::)?unordered_map with 2 elements = {\[3\] = "seven", \[5\] = "three"}} } }
std::unordered_multimap<int, std::string> uomm;
uomm.insert(std::pair<int, std::string> (5, "three"));
uomm.insert(std::pair<int, std::string> (5, "seven"));
-// { dg-final { note-test uomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } }
+// { dg-final { regexp-test uomm {std::(__debug::)?unordered_multimap with 2 elements = {\[5\] = "seven", \[5\] = "three"}} } }
std::unordered_multimap<int, std::string> &ruomm = uomm;
-// { dg-final { note-test ruomm {std::unordered_multimap with 2 elements = {[5] = "seven", [5] = "three"}} } }
+// { dg-final { regexp-test ruomm {std::(__debug::)?unordered_multimap with 2 elements = {\[5\] = "seven", \[5\] = "three"}} } }
std::unordered_set<int> uos;
uos.insert(5);
-// { dg-final { note-test uos {std::unordered_set with 1 element = {[0] = 5}} } }
+// { dg-final { regexp-test uos {std::(__debug::)?unordered_set with 1 element = {\[0\] = 5}} } }
std::unordered_set<int> &ruos = uos;
-// { dg-final { note-test ruos {std::unordered_set with 1 element = {[0] = 5}} } }
+// { dg-final { regexp-test ruos {std::(__debug::)?unordered_set with 1 element = {\[0\] = 5}} } }
std::unordered_multiset<int> uoms;
uoms.insert(5);
-// { dg-final { note-test uoms {std::unordered_multiset with 1 element = {[0] = 5}} } }
+// { dg-final { regexp-test uoms {std::(__debug::)?unordered_multiset with 1 element = {\[0\] = 5}} } }
std::unordered_multiset<int> &ruoms = uoms;
-// { dg-final { note-test ruoms {std::unordered_multiset with 1 element = {[0] = 5}} } }
+// { dg-final { regexp-test ruoms {std::(__debug::)?unordered_multiset with 1 element = {\[0\] = 5}} } }
std::unique_ptr<datum> uptr (new datum);
uptr->s = "hi bob";
// { dg-final { note-test op {std::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::optional<std::map<int, double>> containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
+// { dg-final { regexp-test om {std::optional<std::(__debug::)?map<int, double>> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
optional<std::string> os{ "stringy" };
// { dg-final { note-test os {std::optional<std::string> = {[contained value] = "stringy"}} } }
any as2("stringiest");
// { dg-final { regexp-test as2 {std::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } }
any am = *om;
-// { dg-final { note-test am {std::any containing std::map with 3 elements = {[1] = 2, [3] = 4, [5] = 6}} } }
+// { dg-final { regexp-test am {std::any containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
struct local_type { int i = 99; };
any al = local_type{};
// { dg-final { note-test al {std::any containing local_type = {[contained value] = {i = 99}}} } }
// { 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}} } }
+// { dg-final { regexp-test om {std::experimental::optional<std::(__debug::)?map<int, double>> containing std::(__debug::)?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 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}} } }
+// { dg-final { regexp-test am {std::experimental::any containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } }
std::cout << "\n";
return 0; // Mark SPOT
// PR 65229
std::bitset<0> bs0;
-// { dg-final { note-test bs0 {std::bitset} } }
+// { dg-final { regexp-test bs0 {std::(__debug::)?bitset} } }
std::bitset<10> bs;
bs[0] = 1;
bs[5] = 1;
bs[7] = 1;
-// { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
+// { dg-final { regexp-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::deque with 2 elements = {"one", "two"}} } }
+// { dg-final { regexp-test deq {std::(__debug::)?deque with 2 elements = {"one", "two"}} } }
std::deque<int>::iterator deqiter0;
// { dg-final { note-test deqiter0 {non-dereferenceable iterator for std::deque} } }
std::list<std::string> lst;
lst.push_back("one");
lst.push_back("two");
-// { dg-final { note-test lst {std::list = {[0] = "one", [1] = "two"}} } }
+// { dg-final { regexp-test lst {std::(__debug::)?list = {\[0\] = "one", \[1\] = "two"}} } }
std::list<int>::iterator lstiter0;
// { dg-final { note-test lstiter0 {non-dereferenceable iterator for std::list} } }
std::map<std::string, int> mp;
mp["zardoz"] = 23;
-// { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
+// { dg-final { regexp-test mp {std::(__debug::)?map with 1 element = {\["zardoz"\] = 23}} } }
std::map<std::string, int>::iterator mpiter = mp.begin();
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
intset.insert(2);
intset.insert(3);
const std::set<int> const_intset = intset;
-// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
+// { dg-final { regexp-test const_intset {std::(__debug::)?set with 2 elements = {\[0\] = 2, \[1\] = 3}} } }
std::set<std::string> sp;
sp.insert("clownfish");
sp.insert("barrel");
-// { dg-final { note-test sp {std::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
+// { dg-final { regexp-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"} } }
v.push_back(1);
v.push_back(2);
v.erase(v.begin());
-// { dg-final { note-test v {std::vector of length 1, capacity 2 = {2}} } }
+// { dg-final { regexp-test v {std::(__debug::)?vector of length 1, capacity 2 = \\{2\\}} } }
std::vector<int>::iterator viter3 = v.begin();
// { dg-final { note-test viter3 {2} } }
bs[0] = 1;
bs[5] = 1;
bs[7] = 1;
-// { dg-final { note-test bs {std::bitset = {[0] = 1, [5] = 1, [7] = 1}} } }
+// { dg-final { regexp-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::deque with 2 elements = {"one", "two"}} } }
+// { dg-final { regexp-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::list = {[0] = "one", [1] = "two"}} } }
+// { dg-final { regexp-test lst {std::(__debug::)?list = {\[0\] = "one", \[1\] = "two"}} } }
std::list<std::string>::iterator lstiter = lst.begin();
tem = *lstiter;
std::map<std::string, int> mp;
mp["zardoz"] = 23;
-// { dg-final { note-test mp {std::map with 1 element = {["zardoz"] = 23}} } }
+// { dg-final { regexp-test mp {std::(__debug::)?map with 1 element = {\["zardoz"\] = 23}} } }
std::map<std::string, int>::iterator mpiter = mp.begin();
// { dg-final { note-test mpiter {{first = "zardoz", second = 23}} } }
// PR 67440
const std::set<int> const_intset = {2, 3};
-// { dg-final { note-test const_intset {std::set with 2 elements = {[0] = 2, [1] = 3}} } }
+// { dg-final { regexp-test const_intset {std::(__debug::)?set with 2 elements = {\[0\] = 2, \[1\] = 3}} } }
std::set<std::string> sp;
sp.insert("clownfish");
sp.insert("barrel");
-// { dg-final { note-test sp {std::set with 2 elements = {[0] = "barrel", [1] = "clownfish"}} } }
+// { dg-final { regexp-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"} } }
v.push_back(1);
v.push_back(2);
v.erase(v.begin());
-// { dg-final { note-test v {std::vector of length 1, capacity 2 = {2}} } }
+// { dg-final { regexp-test v {std::(__debug::)?vector of length 1, capacity 2 = \\{2\\}} } }
std::vector<int>::iterator viter3 = v.begin();
// { dg-final { note-test viter3 {2} } }
std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr;
holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder;
-// { dg-final { whatis-test seq1_holder "holder<std::vector<std::deque<std::unique_ptr<char>>> >" } }
+// { dg-final { whatis-regexp-test seq1_holder "holder<std::(__debug::)?vector<std::(__debug::)?deque<std::unique_ptr<char>>> >" } }
std::list<std::forward_list<std::unique_ptr<char>>> *seq2_ptr;
holder< std::list<std::forward_list<std::unique_ptr<char>>> > seq2_holder;
-// { dg-final { whatis-test seq2_holder "holder<std::list<std::forward_list<std::unique_ptr<char>>> >" } }
+// { dg-final { whatis-regexp-test seq2_holder "holder<std::(__debug::)?list<std::(__debug::)?forward_list<std::unique_ptr<char>>> >" } }
std::map<int, std::set<int>> *assoc1_ptr;
holder< std::map<int, std::set<int>> > assoc1_holder;
-// { dg-final { whatis-test assoc1_holder "holder<std::map<int, std::set<int>> >" } }
+// { dg-final { whatis-regexp-test assoc1_holder "holder<std::(__debug::)?map<int, std::(__debug::)?set<int>> >" } }
std::multimap<int, std::multiset<int>> *assoc2_ptr;
holder< std::multimap<int, std::multiset<int>> > assoc2_holder;
-// { dg-final { whatis-test assoc2_holder "holder<std::multimap<int, std::multiset<int>> >" } }
+// { dg-final { whatis-regexp-test assoc2_holder "holder<std::(__debug::)?multimap<int, std::(__debug::)?multiset<int>> >" } }
std::unordered_map<int, std::unordered_set<int>> *unord1_ptr;
holder< std::unordered_map<int, std::unordered_set<int>> > unord1_holder;
-// { dg-final { whatis-test unord1_holder "holder<std::unordered_map<int, std::unordered_set<int>> >" } }
+// { dg-final { whatis-regexp-test unord1_holder "holder<std::(__debug::)?unordered_map<int, std::(__debug::)?unordered_set<int>> >" } }
std::unordered_multimap<int, std::unordered_multiset<int>> *unord2_ptr;
holder< std::unordered_multimap<int, std::unordered_multiset<int>> > unord2_holder;
-// { dg-final { whatis-test unord2_holder "holder<std::unordered_multimap<int, std::unordered_multiset<int>> >" } }
+// { dg-final { whatis-regexp-test unord2_holder "holder<std::(__debug::)?unordered_multimap<int, std::(__debug::)?unordered_multiset<int>> >" } }
int
std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr;
holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder;
-// { dg-final { whatis-test seq1_holder "holder<std::vector<std::deque<std::unique_ptr<char>>> >" } }
+// { dg-final { whatis-regexp-test seq1_holder "holder<std::(__debug::)?vector<std::(__debug::)?deque<std::unique_ptr<char>>> >" } }
std::list<std::forward_list<std::unique_ptr<char>>> *seq2_ptr;
holder< std::list<std::forward_list<std::unique_ptr<char>>> > seq2_holder;
-// { dg-final { whatis-test seq2_holder "holder<std::list<std::forward_list<std::unique_ptr<char>>> >" } }
+// { dg-final { whatis-regexp-test seq2_holder "holder<std::(__debug::)?list<std::(__debug::)?forward_list<std::unique_ptr<char>>> >" } }
std::map<int, std::set<int>> *assoc1_ptr;
holder< std::map<int, std::set<int>> > assoc1_holder;
-// { dg-final { whatis-test assoc1_holder "holder<std::map<int, std::set<int>> >" } }
+// { dg-final { whatis-regexp-test assoc1_holder "holder<std::(__debug::)?map<int, std::(__debug::)?set<int>> >" } }
std::multimap<int, std::multiset<int>> *assoc2_ptr;
holder< std::multimap<int, std::multiset<int>> > assoc2_holder;
-// { dg-final { whatis-test assoc2_holder "holder<std::multimap<int, std::multiset<int>> >" } }
+// { dg-final { whatis-regexp-test assoc2_holder "holder<std::(__debug::)?multimap<int, std::(__debug::)?multiset<int>> >" } }
std::unordered_map<int, std::unordered_set<int>> *unord1_ptr;
holder< std::unordered_map<int, std::unordered_set<int>> > unord1_holder;
-// { dg-final { whatis-test unord1_holder "holder<std::unordered_map<int, std::unordered_set<int>> >" } }
+// { dg-final { whatis-regexp-test unord1_holder "holder<std::(__debug::)?unordered_map<int, std::(__debug::)?unordered_set<int>> >" } }
std::unordered_multimap<int, std::unordered_multiset<int>> *unord2_ptr;
holder< std::unordered_multimap<int, std::unordered_multiset<int>> > unord2_holder;
-// { dg-final { whatis-test unord2_holder "holder<std::unordered_multimap<int, std::unordered_multiset<int>> >" } }
+// { dg-final { whatis-regexp-test unord2_holder "holder<std::(__debug::)?unordered_multimap<int, std::(__debug::)?unordered_multiset<int>> >" } }
placeholder(&ios_ptr); // Mark SPOT