gdb:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / setvar.exp
index 259700a65494a19c4edcf8e06b5efba1d77366b1..3c5251f4b87f8f8c115196900b3805c92aec1870 100644 (file)
@@ -1,64 +1,41 @@
-#   Copyright 1997, 1999, 2000 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, 1990-1997, 1999-2001, 2004, 2007-2012 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."
+     untested setvar.exp
+     return -1
 }
 
 # Create and source the file that provides information about the compiler
 # used to compile the test case.
-if [get_compiler_info ${binfile}] {
+if [get_compiler_info] {
     return -1;
 }
 
@@ -70,7 +47,7 @@ gdb_load $binfile
 #
 # 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"
@@ -80,20 +57,16 @@ if ![runto_main] then {
 # 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
@@ -104,7 +77,7 @@ proc test_set { args } {
     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];
            if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } {
@@ -139,7 +112,7 @@ proc test_set { args } {
 
 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')" 
@@ -148,19 +121,19 @@ test_set "set variable v_char=127" "print v_char" ".\[0-9\]* = 127 \'.177\'"
 #
 # test "set variable" for type "signed char"
 #    
-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_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)"
@@ -169,7 +142,7 @@ gdb_test "print v_signed_char" ".\[0-9\]* = -1 \'.377\'" \
 #
 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')" 
@@ -317,24 +290,20 @@ test_set "set v_short_pointer=v_short_array" "set variable *(v_short_pointer)=12
 #
 # 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 *"
@@ -395,7 +364,8 @@ v_long_member = 3,.*v_float_member = 4,.*v_double_member = 5.*\}" \
 
 # 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}" \
@@ -413,6 +383,16 @@ test_set "set variable v_struct1 = {'h', 1, 2, 3, 4.0, 5.0}" \
 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.
 
This page took 0.029971 seconds and 4 git commands to generate.