gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / exprs.exp
index 1a6b472c80de4cf9376e9cd6261b8a0bf7f7cba0..fa3cdb449578313f7822e0e61980bfa2318226de 100644 (file)
@@ -1,5 +1,4 @@
-#   Copyright 1988, 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 2000,
-#   2001, 2003, 2007 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
 # You should have received a copy of the GNU General Public License
 # 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
-
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
-if $tracelevel {
-    strace $tracelevel
-}
-
 #
 # test running programs
 #
-set prms_id 0
-set bug_id 0
 
 set testfile "exprs"
 set srcfile ${testfile}.c
@@ -37,8 +27,8 @@ if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
      return -1
 }
 
-if [get_compiler_info ${binfile}] {
-    return -1;
+if [get_compiler_info] {
+    return -1
 }
 
 gdb_exit
@@ -61,7 +51,7 @@ proc test_expr { args } {
     }
     set last_ent [expr [llength $args] - 1];
     set testname [lindex $args $last_ent];
-    if [gdb_test [lindex $args 0] "" "$testname (setup)"] {
+    if [gdb_test [lindex $args 0] ".*" "$testname (setup)"] {
        gdb_suppress_tests;
     }
     for {set x 1} {$x < $last_ent} {set x [expr $x + 2]} {
@@ -230,8 +220,8 @@ test_expr "set variable v_unsigned_long = 0" "print (void*)v_unsigned_long" "\\$
 #     sizeof(long long) and sizeof(void*) are
 #     the same size so this test can not work.
 #
-send_gdb "print sizeof (long long) > sizeof (long)\n"
-gdb_expect {
+gdb_test_multiple "print sizeof (long long) > sizeof (long)" \
+    "sizeof long long > sizeof long" {
     -re "\\$\[0-9\]* = $true.*$gdb_prompt" {
        set ok 1
        pass "sizeof (long long) > sizeof (long) (true)"
@@ -240,10 +230,6 @@ gdb_expect {
        set ok 0
        pass "sizeof (long long) > sizeof (long) (false)"
     }
-    timeout {
-       set ok 0
-       fail "sizeof (long long) > sizeof (long) (timeout)"
-    }
 }
 if [expr ! $ok] { setup_xfail "*-*-*" }
 gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \
@@ -251,3 +237,39 @@ gdb_test "print (void*) ((long long) (unsigned long) -1 + 1)" \
 if [expr ! $ok] { setup_xfail "*-*-*" }
 gdb_test "print (void*) (~((long long)(unsigned long) -1) - 1)" \
        "warning: value truncated.*" "truncate (void*) 0xffffffff00000000 - 1"
+
+# String concatentation.
+test_expr "print \"x\" \"y\"" "\\$\[0-9\]* = \"xy\""
+test_expr "print \"x\" \"y\" \"z\"" "\\$\[0-9\]* = \"xyz\""
+
+# Enum formatting tests.
+test_expr "print red" "\\$\[0-9\]* = red"
+gdb_test "set output-radix 8" ".*"
+test_expr "print red" "\\$\[0-9\]* = red"
+test_expr "print/d red" "\\$\[0-9\]* = 0"
+gdb_test "set output-radix 10" ".*"
+
+# Pre-/post in-/decrement tests.
+gdb_test "set variable v_int = 1" ""
+gdb_test "print v_int++" "\\$\[0-9\]* = 1"
+gdb_test "print ++v_int" "\\$\[0-9\]* = 3"
+gdb_test "print v_int--" "\\$\[0-9\]* = 3"
+gdb_test "print --v_int" "\\$\[0-9\]* = 1"
+gdb_test "print v_int++ = 5" "Left operand of assignment is not an lvalue."
+gdb_test "print v_int-- = 5" "Left operand of assignment is not an lvalue."
+
+# initialized array
+gdb_test {print v_int_array_init} { = \{10, 20\}}
+gdb_test {print *v_int_array_init@1} { = \{10\}}
+gdb_test {print *v_int_array_init@2} { = \{10, 20\}}
+gdb_test {print v_int_array_init[0]@1} { = \{10\}}
+gdb_test {print v_int_array_init[0]@2} { = \{10, 20\}}
+gdb_test {print v_int_array_init[1]@1} { = \{20\}}
+
+# gdb's {} extension
+gdb_test_no_output "set variable v_short_array\[0\] = 42"
+gdb_test "print {short} v_short_array" "$decimal = 42"
+
+# Regression tests for cast to void.
+gdb_test "print (void) v_int_pointer" " = void"
+gdb_test "print & (void) v_char" "value not located in memory."
This page took 0.02602 seconds and 4 git commands to generate.