summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/testsuite/lib
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-16 18:17:25 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-16 18:17:25 +0000
commit0ed3336a547e85306b4424b97b9762dbe15db061 (patch)
treec77f1eede46fec5a355a7b3f04cf72736bb46a4c /libstdc++-v3/testsuite/lib
parentebf12ee0d18cf247956fa3f1e8a31de900ae55ee (diff)
downloadppe42-gcc-0ed3336a547e85306b4424b97b9762dbe15db061.tar.gz
ppe42-gcc-0ed3336a547e85306b4424b97b9762dbe15db061.zip
* testsuite/libstdc++-prettyprinters/whatis.cc: New file.
* testsuite/lib/gdb-test.exp (whatis-test): New proc. (gdb-test): Handle 'whatis' tests. (gdb_batch_check): New proc. (gdb_version_check): Rewrite to use gdb_batch_check. * python/libstdcxx/v6/printers.py: Import gdb.types. (FilteringTypePrinter): New class. (add_one_type_printer, register_type_printers): New functions. (register_libstdcxx_printers): Call register_type_printers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193573 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/lib')
-rw-r--r--libstdc++-v3/testsuite/lib/gdb-test.exp86
1 files changed, 62 insertions, 24 deletions
diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp b/libstdc++-v3/testsuite/lib/gdb-test.exp
index b9d4742d393..3434ef2a7ac 100644
--- a/libstdc++-v3/testsuite/lib/gdb-test.exp
+++ b/libstdc++-v3/testsuite/lib/gdb-test.exp
@@ -67,6 +67,13 @@ proc regexp-test {var result} {
lappend gdb_tests $var $result 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
+}
+
# Utility for testing variable values using gdb, invoked via dg-final.
# Tests all tests indicated by note-test and regexp-test.
#
@@ -84,6 +91,12 @@ proc gdb-test { marker {selector {}} } {
}
}
+ set do_whatis_tests [gdb_batch_check "python print gdb.type_printers" \
+ "\\\[\\\]"]
+ if {!$do_whatis_tests} {
+ send_log "skipping 'whatis' tests - gdb too old"
+ }
+
# This assumes that we are three frames down from dg-test, and that
# it still stores the filename of the testcase in a local variable "name".
# A cleaner solution would require a new DejaGnu release.
@@ -109,12 +122,25 @@ proc gdb-test { marker {selector {}} } {
puts $fd "run"
set count 0
- foreach {var result is_regexp} $gdb_tests {
- puts $fd "print $var"
+ foreach {var result kind} $gdb_tests {
incr count
set gdb_var($count) $var
set gdb_expected($count) $result
- set gdb_is_regexp($count) $is_regexp
+ if {$kind == "whatis"} {
+ if {$do_whatis_tests} {
+ set gdb_is_type($count) 1
+ set gdb_command($count) "whatis $var"
+ } else {
+ unsupported "$testname"
+ close $fd
+ return
+ }
+ } else {
+ set gdb_is_type($count) 0
+ set gdb_is_regexp($count) $kind
+ set gdb_command($count) "print $var"
+ }
+ puts $fd $gdb_command($count)
}
set gdb_tests {}
@@ -128,28 +154,36 @@ proc gdb-test { marker {selector {}} } {
return
}
+ set test_counter 0
remote_expect target [timeout_value] {
- -re {^\$([0-9]+) = ([^\n\r]*)[\n\r]+} {
+ -re {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} {
send_log "got: $expect_out(buffer)"
- set num $expect_out(1,string)
- set first $expect_out(2,string)
-
- if {$gdb_is_regexp($num)} {
- set match [regexp -- $gdb_expected($num) $first]
+ incr test_counter
+ set first $expect_out(3,string)
+
+ if {$gdb_is_type($test_counter)} {
+ 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)} {
+ set match [regexp -- $gdb_expected($test_counter) $first]
} else {
- set match [expr {![string compare $first $gdb_expected($num)]}]
+ set match [expr {![string compare $first \
+ $gdb_expected($test_counter)]}]
}
if {$match} {
- pass "$testname print $gdb_var($num)"
+ pass "$testname $gdb_command($test_counter)"
} else {
- fail "$testname print $gdb_var($num)"
+ fail "$testname $gdb_command($test_counter)"
verbose " got =>$first<="
- verbose "expected =>$gdb_expected($num)<="
+ verbose "expected =>$gdb_expected($test_counter)<="
}
- if {$num == $count} {
+ if {$test_counter == $count} {
remote_close target
return
} else {
@@ -180,16 +214,10 @@ proc gdb-test { marker {selector {}} } {
return
}
-# Check for a new-enough version of gdb. The pretty-printer tests
-# require gdb 7.3, but we don't want to test versions, so instead we
-# check for the python "lookup_global_symbol" method, which is in 7.3
-# but not earlier versions.
-# Return 1 if the version is ok, 0 otherwise.
-proc gdb_version_check {} {
- global gdb_version
-
+# Invoke gdb with a command and pattern-match the output.
+proc gdb_batch_check {command pattern} {
set gdb_name $::env(GUALITY_GDB_NAME)
- set cmd "$gdb_name -nw -nx -quiet -batch -ex \"python print gdb.lookup_global_symbol\""
+ set cmd "$gdb_name -nw -nx -quiet -batch -ex \"$command\""
send_log "Spawning: $cmd\n"
set res [remote_spawn target "$cmd"]
if { $res < 0 || $res == "" } {
@@ -197,7 +225,7 @@ proc gdb_version_check {} {
}
remote_expect target [timeout_value] {
- -re "<built-in function lookup_global_symbol>" {
+ -re $pattern {
return 1
}
@@ -215,3 +243,13 @@ proc gdb_version_check {} {
remote_close target
return 0
}
+
+# Check for a new-enough version of gdb. The pretty-printer tests
+# require gdb 7.3, but we don't want to test versions, so instead we
+# check for the python "lookup_global_symbol" method, which is in 7.3
+# but not earlier versions.
+# Return 1 if the version is ok, 0 otherwise.
+proc gdb_version_check {} {
+ return [gdb_batch_check "python print gdb.lookup_global_symbol" \
+ "<built-in function lookup_global_symbol>"]
+}
OpenPOWER on IntegriCloud