diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/lib/gcc-gdb-test.exp | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/lib/gcc-gdb-test.exp')
-rw-r--r-- | gcc-4.9/gcc/testsuite/lib/gcc-gdb-test.exp | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/lib/gcc-gdb-test.exp b/gcc-4.9/gcc/testsuite/lib/gcc-gdb-test.exp new file mode 100644 index 000000000..d182d88fa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/lib/gcc-gdb-test.exp @@ -0,0 +1,98 @@ +# Copyright (C) 2009-2014 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 +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program 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 GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Utility for testing variable values using gdb, invoked via dg-final. +# Call pass if variable has the desired value, otherwise fail. +# +# Argument 0 is the line number on which to put a breakpoint +# Argument 1 is the name of the variable to be checked +# Argument 2 is the expected value of the variable +# Argument 3 handles expected failures and the like +proc gdb-test { args } { + if { ![isnative] || [is_remote target] } { return } + + if { [llength $args] >= 4 } { + switch [dg-process-target [lindex $args 3]] { + "S" { } + "N" { return } + "F" { setup_xfail "*-*-*" } + "P" { } + } + } + + # 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. + upvar 2 name testcase + upvar 2 prog prog + + set gdb_name $::env(GUALITY_GDB_NAME) + set testname "$testcase line [lindex $args 0] [lindex $args 1] == [lindex $args 2]" + set output_file "[file rootname [file tail $prog]].exe" + set cmd_file "[file rootname [file tail $prog]].gdb" + + set fd [open $cmd_file "w"] + puts $fd "break [lindex $args 0]" + puts $fd "run" + puts $fd "print [lindex $args 1]" + puts $fd "print [lindex $args 2]" + puts $fd "quit" + close $fd + + send_log "Spawning: $gdb_name -nx -nw -quiet -x $cmd_file ./$output_file\n" + set res [remote_spawn target "$gdb_name -nx -nw -quiet -x $cmd_file ./$output_file"] + if { $res < 0 || $res == "" } { + unsupported "$testname" + file delete $cmd_file + return + } + + remote_expect target [timeout_value] { + # Too old GDB + -re "Unhandled dwarf expression|Error in sourced command file" { + unsupported "$testname" + remote_close target + file delete $cmd_file + return + } + -re {[\n\r]\$1 = ([^\n\r]*)[\n\r]+\$2 = ([^\n\r]*)[\n\r]} { + set first $expect_out(1,string) + set second $expect_out(2,string) + if { $first == $second } { + pass "$testname" + } else { + # We need the -- to disambiguate $first from an option, + # as it may be negative. + send_log -- "$first != $second\n" + fail "$testname" + } + remote_close target + file delete $cmd_file + return + } + timeout { + unsupported "$testname" + remote_close target + file delete $cmd_file + return + } + } + + unsupported "$testname" + remote_close target + file delete $cmd_file + return +} |