-# Copyright 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001
-# Free Software Foundation, Inc.
+# This testcase is part of GDB, the GNU debugger.
-# 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 2 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
-
-# Copyright (C) 1988, 1990, 1991, 1992, 1994, 1995
-# Free Software Foundation, Inc.
+# Copyright 1988-2013 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 2 of the License, or
+# 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 this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# bug-gdb@gnu.org
# This file was written by Rob Savoye. (rob@cygnus.com)
-if $tracelevel then {
- strace $tracelevel
- }
-
#
# test running programs
#
-set prms_id 0
-set bug_id 0
-set testfile "setvar"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
- gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
-}
+standard_testfile
# Create and source the file that provides information about the compiler
# used to compile the test case.
-if [get_compiler_info ${binfile}] {
- return -1;
+if [get_compiler_info] {
+ return -1
}
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load $binfile
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+ untested $testfile.exp
+ return -1
+}
#
# set it up at a breakpoint so we canplay with the variable values
#
-send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
+gdb_test_no_output "set print sevenbit-strings"
if ![runto_main] then {
perror "couldn't run to breakpoint"
# Determine expected output for unsigned long variables,
# the output varies with sizeof (unsigned long).
-set ulong_minus_1 4294967295
-set ulong_minus_456 4294966840
-send_gdb "print sizeof (unsigned long)\n"
-gdb_expect {
- -re ".\[0-9\]* = 4.*$gdb_prompt $" {}
+gdb_test_multiple "print sizeof (unsigned long)" "sizeof ulong" {
+ -re ".\[0-9\]* = 4.*$gdb_prompt $" {
+ set ulong_minus_1 4294967295
+ set ulong_minus_456 4294966840
+ }
-re ".\[0-9\]* = 8.*$gdb_prompt $" {
set ulong_minus_1 18446744073709551615
set ulong_minus_456 18446744073709551160
}
- -re ".*$gdb_prompt $" {
- fail "getting sizeof unsigned long"
- }
- default { fail "(timeout) getting sizeof unsigned long" }
-}
+}
proc test_set { args } {
global gdb_prompt
- set length [expr [llength $args] - 1];
- set message "[lindex $args $length]";
- set final [expr $length - 2];
- set count 1;
+ set length [expr [llength $args] - 1]
+ set message "[lindex $args $length]"
+ set final [expr $length - 2]
+ set count 1
# Set up the variables.
- for {set x 0;} {$x < $length} {incr x;} {
+ for {set x 0} {$x < $length} {incr x} {
if { "[lindex $args $x]" != "" } {
- set arg [lindex $args $x];
+ set arg [lindex $args $x]
if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } {
- set match [lindex $args [expr $x + 1]];
+ set match [lindex $args [expr $x + 1]]
if { $count == 1 } {
set mess "$message"
} else {
- set mess "$message (#$count)";
+ set mess "$message (#$count)"
}
- incr count;
- incr x;
+ incr count
+ incr x
} else {
- set mess "";
+ set mess ""
set match ""
}
verbose "doing $arg $match"
if [gdb_test "$arg" "$match" "$mess"] {
- fail "$message -- $match";
- return 1;
+ fail "$message -- $match"
+ return 1
}
}
}
- return 0;
+ return 0
}
#
# range of values that are common to both (0-127).
#
-test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.0\'" "set variable char=0"
+test_set "set variable v_char=0" "print v_char" ".\[0-9\]* = 0 \'.000\'" "set variable char=0"
test_set "set variable v_char=1" "print v_char" ".\[0-9\]* = 1 \'.001\'" "set variable char=1"
-test_set "set variable v_char=27" "print v_char" ".\[0-9\]* = 27 \'.e\'" "set variable char=27 (Esc)"
+test_set "set variable v_char=7" "print v_char" ".\[0-9\]* = 7 \'.a\'" "set variable char=7 (Bel)"
test_set "set variable v_char=32" "print v_char" ".\[0-9\]* = 32 \' \'" "set variable char=32 (SPC)"
test_set "set variable v_char=65" "print v_char" ".\[0-9\]* = 65 \'A\'" "set variable char=65 ('A')"
test_set "set variable v_char=97" "print v_char" ".\[0-9\]* = 97 \'a\'" "set variable char=97 ('a')"
#
# test "set variable" for type "signed char"
#
-test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.0\'" "set variable signed char=0"
+test_set "set variable v_char=0" "print v_signed_char" ".\[0-9\]* = 0 \'.000\'" "set variable signed char=0"
test_set "set variable v_signed_char=1" "print v_signed_char" ".\[0-9\]* = 1 \'.001\'" "set variable signed char=1"
-test_set "set variable v_signed_char=27" "print v_signed_char" ".\[0-9\]* = 27 \'.e\'" "set variable signed char=27 (Esc)"
+test_set "set variable v_signed_char=7" "print v_signed_char" ".\[0-9\]* = 7 \'.a\'" "set variable signed char=7 (Bel)"
test_set "set variable v_signed_char=32" "print v_signed_char" ".\[0-9\]* = 32 \' \'" "set variable signed char=32 (SPC)"
test_set "set variable v_signed_char=65" "print v_signed_char" ".\[0-9\]* = 65 \'A\'" "set variable signed char=65 ('A')"
test_set "set variable v_signed_char=97" "print v_signed_char" ".\[0-9\]* = 97 \'a\'" "set variable signed char=97 ('a')"
test_set "set variable v_signed_char=126" "print v_signed_char" ".\[0-9\]* = 126 \'~\'" "set variable signed char=126 ('~')"
test_set "set variable v_signed_char=127" "print v_signed_char" ".\[0-9\]* = 127 \'.177\'" "set variable signed char=127 (8-bit)"
-gdb_test "set variable v_signed_char=-1" ""
+gdb_test_no_output "set variable v_signed_char=-1"
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
"set variable signed char=-1 (-1)"
-gdb_test "set variable v_signed_char=0xFF" ""
+gdb_test_no_output "set variable v_signed_char=0xFF"
if {!$gcc_compiled} then { setup_xfail "mips-sgi-irix4*" }
gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
"set variable signed char=0xFF (0xFF)"
#
# test "set variable" for type "unsigned char"
#
-test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.0\'" "set variable unsigned char=0"
+test_set "set variable v_unsigned_char=0" "print v_unsigned_char" ".\[0-9\]* = 0 \'.000\'" "set variable unsigned char=0"
test_set "set variable v_unsigned_char=1" "print v_unsigned_char" ".\[0-9\]* = 1 \'.001\'" "set variable unsigned char=1"
-test_set "set variable v_unsigned_char=27" "print v_unsigned_char" ".\[0-9\]* = 27 \'.e\'" "set variable unsigned char=27 (Esc)"
+test_set "set variable v_unsigned_char=7" "print v_unsigned_char" ".\[0-9\]* = 7 \'.a\'" "set variable unsigned char=7 (Bel)"
test_set "set variable v_unsigned_char=32" "print v_unsigned_char" ".\[0-9\]* = 32 \' \'" "set variable unsigned char=32 (SPC)"
test_set "set variable v_unsigned_char=65" "print v_unsigned_char" ".\[0-9\]* = 65 \'A\'" "set variable unsigned char=65 ('A')"
test_set "set variable v_unsigned_char=97" "print v_unsigned_char" ".\[0-9\]* = 97 \'a\'" "set variable unsigned char=97 ('a')"
#
# test "set variable" for type "signed short *"
#
-gdb_test "set v_signed_short_pointer=v_signed_short_array" ""
-gdb_test "set variable *(v_signed_short_pointer)=123" ""
-gdb_test "set variable *(v_signed_short_pointer+1)=-456" ""
+gdb_test_no_output "set v_signed_short_pointer=v_signed_short_array"
+gdb_test_no_output "set variable *(v_signed_short_pointer)=123"
+gdb_test_no_output "set variable *(v_signed_short_pointer+1)=-456"
gdb_test "print v_signed_short_array" ".\[0-9\]* =.*\\{123,.*-456\\}" \
"set variable signed short pointer"
gdb_test "print *(v_signed_short_pointer+1)" ".\[0-9\]*.*=.*-456"
#
# test "set variable" for type "unsigned short *"
#
-gdb_test "set v_unsigned_short_pointer=v_unsigned_short_array" ""
-gdb_test "set variable *(v_unsigned_short_pointer)=123" ""
-gdb_test "set variable *(v_unsigned_short_pointer+1)=-456" ""
-# DTS 10060CLLbs - bad type info from cc
-if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
+gdb_test_no_output "set v_unsigned_short_pointer=v_unsigned_short_array"
+gdb_test_no_output "set variable *(v_unsigned_short_pointer)=123"
+gdb_test_no_output "set variable *(v_unsigned_short_pointer+1)=-456"
gdb_test "print v_unsigned_short_array" ".\[0-9\]* =.*\\{123,.*65080\\}" \
"set variable unsigned short pointer"
-# DTS 10060CLLbs - bad type info from cc
-if {$hp_cc_compiler} {setup_xfail hppa*-*-*11* 10060CLLbs}
gdb_test "print *(v_unsigned_short_pointer+1)" ".\[0-9\]* = 65080"
#
# test "set variable" for type "int *"
# We need to up this because this can be really slow on some boards.
# (malloc() is called as part of the test).
-set timeout 60;
+set prev_timeout $timeout
+set timeout 60
# Change the values
test_set "set variable v_struct1 = {32, 33, 34, 35, 36, 37}" \
v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\\}" \
"set print structure #3"
+#
+# test "set variable" for nested struct
+#
+test_set "set variable v_struct3 = {1, {'h', 1, 2, 3, 4.0, 5.0}, 37}" \
+ "print v_struct3" \
+ ".*.\[0-9\]* = \\{.*v_long_member = 1,.*t = \\{.*v_char_member = 104 \'h\',.*v_short_member = 1,.*v_int_member = 2,.*v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\\},.*v_char_member = 37 \'%\'\\}" \
+ "set print structure #4"
+
+set timeout $prev_timeout
+
# Test printing of enumeration bitfields.
# GNU C supports them, some other compilers don't.