2010-06-01 Michael Snyder <msnyder@vmware.com>
[binutils-gdb.git] / gdb / testsuite / gdb.base / gdbvars.exp
index 9678df6bb6e2d6a880c37fe4bb09dc908994ca13..50842a35017be2f2159c94e4c79d2efe61a0092f 100644 (file)
@@ -1,21 +1,18 @@
-# Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1997, 2007, 2008, 2009, 2010
+# 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.  
-
-# Please email any bugs, comments, and/or additions to this file to:
-# bug-gdb@prep.ai.mit.edu
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This file was written by Fred Fish. (fnf@cygnus.com)
 
@@ -23,25 +20,32 @@ if $tracelevel then {
        strace $tracelevel
 }
 
-set prms_id 0
-set bug_id 0
+
+set testfile "gdbvars"
+set srcfile  ${testfile}.c
+set binfile  ${objdir}/${subdir}/${testfile}
+
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+    untested gdbvars.exp
+    return -1
+}
 
 proc test_convenience_variables {} {
     global gdb_prompt
 
-    gdb_test "set \$foo = 101" "" \
+    gdb_test_no_output "set \$foo = 101" \
        "Set a new convenience variable"
 
     gdb_test "print \$foo"             " = 101" \
        "Print contents of new convenience variable"
 
-    gdb_test "set \$foo = 301" "" \
+    gdb_test_no_output "set \$foo = 301" \
        "Set convenience variable to a new value"
 
     gdb_test "print \$foo"             " = 301" \
        "Print new contents of convenience variable"
 
-    gdb_test "set \$_ = 11"            "" \
+    gdb_test_no_output "set \$_ = 11" \
        "Set convenience variable \$_"
 
     gdb_test "print \$_"               " = 11" \
@@ -105,13 +109,23 @@ proc test_value_history {} {
        "Use value-history element in arithmetic expression"
 }
 
+proc test_with_program {} {
+    global hex
+    gdb_test_no_output "set \$prog_var = p" \
+       "Set a new convenience variable to a program variable"
+    gdb_test "print /x \$prog_var" " = $hex" \
+       "Print contents of new convenience variable of program variable"
+}
+
 # Start with a fresh gdb.
 
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
 
-send_gdb "set print sevenbit-strings\n" ; gdb_expect -re ".*$gdb_prompt $"
+gdb_test_no_output "set print sevenbit-strings"
 
 test_value_history
 test_convenience_variables
+test_with_program