include/
[external/binutils.git] / gdb / testsuite / gdb.mi / mi2-var-display.exp
index 0226186..17e208a 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
 # Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,7 @@ if [mi_gdb_start] {
 
 set testfile "var-cmd"
 set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/${testfile}
+set binfile ${objdir}/${subdir}/mi2-var-display
 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
     untested mi2-var-display.exp
     return -1
@@ -42,19 +42,12 @@ mi_gdb_load ${binfile}
 
 set line_dct_end [gdb_get_line_number "{int a = 0;}"]
 
-mi_gdb_test "200-break-insert $srcfile:$line_dct_end" \
-       "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"$line_dct_end\",times=\"0\"\}" \
-       "break-insert operation"
+mi_create_breakpoint "$srcfile:$line_dct_end" 1 keep do_children_tests ".*var-cmd.c" $line_dct_end $hex \
+    "break-insert operation"
 
 mi_run_cmd
-# The running part has been checked already by mi_run_cmd
-gdb_expect {
-    -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_children_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dct_end\"\}\r\n$mi_gdb_prompt$" {
-       pass "run to do_children_tests"
-    }
-    -re ".*$mi_gdb_prompt$" {fail "run to do_children_tests (2)"}
-    timeout {fail "run to do_children_tests (timeout 2)"}
-}
+mi_expect_stop "breakpoint-hit" "do_children_tests" "" ".*var-cmd.c" \
+       $line_dct_end { "" "disp=\"keep\"" } "run to main"
 
 #####       #####
 #               #
@@ -168,6 +161,49 @@ mi_gdb_test "-var-evaluate-expression foo" \
        "\\^done,value=\"3\"" \
        "eval variable foo"
 
+# Test: c_variable-6.19
+# Desc: check optional format parameter of var-evaluate-expression
+#       and check that current format is not changed
+mi_gdb_test "-var-evaluate-expression -f hex foo" \
+       "\\^done,value=\"0x3\"" \
+       "eval variable foo in hex"
+
+mi_gdb_test "-var-show-format foo" \
+       "\\^done,format=\"decimal\"" \
+       "show format variable foo after eval in hex"
+
+mi_gdb_test "-var-evaluate-expression -f octal foo" \
+       "\\^done,value=\"03\"" \
+       "eval variable foo in octal"
+
+mi_gdb_test "-var-show-format foo" \
+       "\\^done,format=\"decimal\"" \
+       "show format variable foo after eval in octal"
+
+mi_gdb_test "-var-evaluate-expression -f decimal foo" \
+       "\\^done,value=\"3\"" \
+       "eval variable foo in decimal"
+
+mi_gdb_test "-var-show-format foo" \
+       "\\^done,format=\"decimal\"" \
+       "show format variable foo after eval in decimal"
+
+mi_gdb_test "-var-evaluate-expression -f nat foo" \
+       "\\^done,value=\"0x3\"" \
+       "eval variable foo in natural"
+
+mi_gdb_test "-var-show-format foo" \
+       "\\^done,format=\"decimal\"" \
+       "show format variable foo after eval in natural"
+
+mi_gdb_test "-var-evaluate-expression -f bin foo" \
+       "\\^done,value=\"11\"" \
+       "eval variable foo in binary"
+
+mi_gdb_test "-var-show-format foo" \
+       "\\^done,format=\"decimal\"" \
+       "show format variable foo after eval in binary"
+
 mi_gdb_test "-var-delete foo" \
        "\\^done,ndeleted=\"1\"" \
        "delete var foo"
@@ -222,7 +258,7 @@ mi_gdb_test "-var-set-format weird.integer natural" \
        "set format variable weird.integer"
 
 mi_gdb_test "-var-set-format weird.character natural" \
-       "\\^done,format=\"natural\",value=\"0 '\\\\\\\\0'\"" \
+       "\\^done,format=\"natural\",value=\"0 '\\\\\\\\000'\"" \
        "set format variable weird.character"
 
 mi_gdb_test "-var-set-format weird.char_ptr natural" \
@@ -333,19 +369,12 @@ mi_gdb_test "-var-delete weird" \
 
 set line_dst_incr_a_2 [gdb_get_line_number "incr_a(2);"]
 
-mi_gdb_test "200-break-insert $line_dst_incr_a_2" \
-       "200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"$line_dst_incr_a_2\",times=\"0\"\}" \
-       "break-insert operation"
+mi_create_breakpoint "$line_dst_incr_a_2" 2 keep do_special_tests ".*var-cmd.c" $line_dst_incr_a_2 $hex \
+       "break-insert operation 2"
 
-send_gdb "-exec-continue\n"
-gdb_expect {
-    -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"2\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"do_special_tests\",args=\\\[\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_dst_incr_a_2\"\}\r\n$mi_gdb_prompt$" {
-       pass "continue to do_special_tests"
-    }
-    timeout {
-       fail "continue to do_special_tests (timeout)"
-    }
-}
+mi_execute_to "exec-continue" "breakpoint-hit" "do_special_tests" "" \
+    ".*var-cmd.c" $line_dst_incr_a_2 { "" "disp=\"keep\"" } \
+    "continue to do_special_tests"
 
 # Test: c_variable-7.10
 # Desc: create union u
@@ -528,7 +557,7 @@ mi_gdb_test "-var-info-num-children e" \
 # Test: c_variable-7.55
 # Desc: children of e
 mi_gdb_test "-var-list-children e" \
-       "\\^done,numchild=\"0\"" \
+       "\\^done,numchild=\"0\",has_more=\"0\"" \
        "get children of e"
 
 # Test: c_variable-7.60
@@ -570,7 +599,7 @@ mi_gdb_test "-var-info-num-children anone" \
 # Test: c_variable-7.75
 # Desc: children of anone
 mi_gdb_test "-var-list-children anone" \
-       "\\^done,numchild=\"0\"" \
+       "\\^done,numchild=\"0\",has_more=\"0\"" \
        "get children of anone"
 
 
@@ -586,26 +615,7 @@ gdb_expect {
     timeout { fail "print FP register (timeout)"}
 }
 
-set line_incr_a_b_a [gdb_get_line_number "b = a;"]
-
-mi_gdb_test "200-break-insert incr_a" \
-       "200\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"incr_a\",file=\".*var-cmd.c\",line=\"$line_incr_a_b_a\",times=\"0\"\}" \
-       "break-insert operation"
-send_gdb "-exec-continue\n"
-gdb_expect {
-    -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"2\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$line_incr_a_b_a\"\}\r\n$mi_gdb_prompt$" {
-       pass "continue to incr_a"
-    }
-    -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"breakpoint-hit\",bkptno=\"3\",thread-id=\"\[01\]\",frame=\{addr=\"$hex\",func=\"incr_a\",args=\\\[\{name=\"a\",value=\"\.*\"\}\\\],file=\".*var-cmd.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"([expr $line_incr_a_b_a - 2]|[expr $line_incr_a_b_a - 1]|$line_incr_a_b_a)\"\}\r\n$mi_gdb_prompt$" {
-       fail "continue to incr_a (compiler debug info incorrect)"
-    }
-    -re "\\^running\r\n${mi_gdb_prompt}.*\r\n$mi_gdb_prompt$" {
-       fail "continue to incr_a (unknown output)"
-    }
-    timeout {
-       fail "continue to incr_a (timeout)"
-    }
-}
+mi_continue_to "incr_a"
 
 # Test: c_variable-7.81
 # Desc: Create variables in different scopes