Hi
This patch allows to run pretty printer tests in _GLIBCXX_DEBUG
mode. If accepted we could even integrate the pretty printers tests
within the check-debug target like it is done for the check target.
* 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.
Tested under Linux x86_64 normal and debug modes.
I only have 1 failure left in both normal and debug modes:
got: type =
std::unique_ptrstd::char_traits, std::allocator >>[]>>[99]>
FAIL: libstdc++-prettyprinters/80276.cc whatis p4
But I think it is because of the usage of the C++11 abi std::string.
Ok to commit ?
François
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 8f16b53c953..19d367295df 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1565,6 +1565,11 @@ def add_one_template_type_printer(obj, name, defargs):
"""
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
diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp b/libstdc++-v3/testsuite/lib/gdb-test.exp
index a6ae44b8283..bd35d478b7e 100644
--- a/libstdc++-v3/testsuite/lib/gdb-test.exp
+++ b/libstdc++-v3/testsuite/lib/gdb-test.exp
@@ -55,7 +55,7 @@ proc get_line_number {filename marker} {
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
@@ -64,14 +64,22 @@ proc note-test {var result} {
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.
@@ -136,13 +144,14 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
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"
@@ -151,7 +160,7 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
}
} 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)
@@ -179,9 +188,9 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
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 \
diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc
index fde652e1635..fd67aaf3b70 100644
--- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc
+++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc
@@ -41,10 +41,10 @@ main()
unique_ptr*>>[]> p2;