-# Copyright 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
+# Free Software Foundation, Inc.
#
-# This Program Is Free software; you can redistribute it and/or modify
+# 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,
# 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/>.
# Test essential Machine interface (MI) operations
#
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
- gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
+ untested mi-var-display.exp
+ return -1
}
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
-set line_dct_close_brace [expr [gdb_get_line_number "snp2.long_ptr = &z3;"] + 1]
+set line_dct_end [gdb_get_line_number "{int a = 0;}"]
-mi_gdb_test "200-break-insert $line_dct_close_brace" \
- "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_children_tests\",file=\".*var-cmd.c\",line=\"$line_dct_close_brace\",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\",line=\"$line_dct_close_brace\"\}\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"
##### #####
# #
# Test: c_variable-6.1
# Desc: create variable bar
-mi_gdb_test "-var-create bar * bar" \
- "\\^done,name=\"bar\",numchild=\"0\",type=\"int\"" \
- "create local variable bar"
+mi_create_varobj bar bar "create local variable bar"
# Test: c_variable-6.2
# Desc: type of variable bar
# Test: c_variable-6.5
# Desc: change format of bar to hex
mi_gdb_test "-var-set-format bar hexadecimal" \
- "\\^done,format=\"hexadecimal\"" \
+ "\\^done,format=\"hexadecimal\",value=\"0x849\"" \
"set format variable bar"
# Test: c_variable-6.6
"assing to variable bar"
mi_gdb_test "-var-set-format bar decimal" \
- "\\^done,format=\"decimal\"" \
+ "\\^done,format=\"decimal\",value=\"3\"" \
"set format variable bar"
mi_gdb_test "-var-evaluate-expression bar" \
# Test: c_variable-6.11
# Desc: create variable foo
-mi_gdb_test "-var-create foo * foo" \
- "\\^done,name=\"foo\",numchild=\"1\",type=\"int \\*\"" \
- "create local variable foo"
+mi_create_varobj foo foo "create local variable foo"
# Test: c_variable-6.12
# Desc: type of variable foo
# Test: c_variable-6.15
# Desc: change format of var to octal
mi_gdb_test "-var-set-format foo octal" \
- "\\^done,format=\"octal\"" \
+ "\\^done,format=\"octal\",value=\"$octal\"" \
"set format variable foo"
mi_gdb_test "-var-show-format foo" \
"assing to variable foo"
mi_gdb_test "-var-set-format foo decimal" \
- "\\^done,format=\"decimal\"" \
+ "\\^done,format=\"decimal\",value=\"3\"" \
"set format variable foo"
# Test: c_variable-6.18
"\\^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"
# Test: c_variable-6.21
# Desc: create variable weird and children
-mi_gdb_test "-var-create weird * weird" \
- "\\^done,name=\"weird\",numchild=\"11\",type=\"weird_struct \\*\"" \
- "create local variable weird"
-
-mi_gdb_test "-var-list-children weird" \
- "\\^done,numchild=\"11\",children=\\\[child=\{name=\"weird.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"weird.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child={name=\"weird.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"weird.long_int\",exp=\"long_int\",numchild=\"0\",type=\"long int\"\},child=\{name=\"weird.int_ptr_ptr\",exp=\"int_ptr_ptr\",numchild=\"1\",type=\"int \\*\\*\"\},child=\{name=\"weird.long_array\",exp=\"long_array\",numchild=\"10\",type=\"long int \\\[10\\\]\"\},child=\{name=\"weird.func_ptr\",exp=\"func_ptr\",numchild=\"0\",type=\"void \\(\\*\\)\\((void|)\\)\"\},child=\{name=\"weird.func_ptr_struct\",exp=\"func_ptr_struct\",numchild=\"0\",type=\"struct _struct_decl \\(\\*\\)\\((int, char \\*, long int|)\\)\"\},child=\{name=\"weird.func_ptr_ptr\",exp=\"func_ptr_ptr\",numchild=\"0\",type=\"struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int|)\\)\"\},child=\{name=\"weird.u1\",exp=\"u1\",numchild=\"4\",type=\"union \{\\.\\.\\.\}\"\},child=\{name=\"weird.s2\",exp=\"s2\",numchild=\"4\",type=\"struct \{\\.\\.\\.\}\"\}\\\]" \
- "get children local variable weird"
+mi_create_varobj weird weird "create local variable weird"
+
+mi_list_varobj_children weird {
+ {weird.integer integer 0 int}
+ {weird.character character 0 char}
+ {weird.char_ptr char_ptr 1 "char \\*"}
+ {weird.long_int long_int 0 "long int"}
+ {weird.int_ptr_ptr int_ptr_ptr 1 "int \\*\\*"}
+ {weird.long_array long_array 10 "long int \\[10\\]"}
+ {weird.func_ptr func_ptr 0 "void \\(\\*\\)\\((void)?\\)"}
+ {weird.func_ptr_struct func_ptr_struct 0 \
+ "struct _struct_decl \\(\\*\\)(\\(int, char \\*, long int\\))?"}
+ {weird.func_ptr_ptr func_ptr_ptr 0 \
+ "struct _struct_decl \\*\\(\\*\\)\\((int, char \\*, long int)?\\)"}
+ {weird.u1 u1 4 "union \\{\\.\\.\\.\\}"}
+ {weird.s2 s2 4 "struct \\{\\.\\.\\.\\}"}
+} "get children local variable weird"
# Test: c_variable-6.23
# Desc: change format of weird.func_ptr and weird.func_ptr_ptr
mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
- "\\^done,format=\"hexadecimal\"" \
+ "\\^done,format=\"hexadecimal\",value=\"$hex\"" \
"set format variable weird.func_ptr"
mi_gdb_test "-var-show-format weird.func_ptr" \
"show format variable weird.func_ptr"
mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \
- "\\^done,format=\"hexadecimal\"" \
+ "\\^done,format=\"hexadecimal\",value=\"$hex\"" \
"set format variable weird.func_ptr_ptr"
mi_gdb_test "-var-show-format weird.func_ptr_ptr" \
# Test: c_variable-6.24
# Desc: format of weird and children
mi_gdb_test "-var-set-format weird natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"$hex\"" \
"set format variable weird"
mi_gdb_test "-var-set-format weird.integer natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"123\"" \
"set format variable weird.integer"
mi_gdb_test "-var-set-format weird.character natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"0 '\\\\\\\\0'\"" \
"set format variable weird.character"
mi_gdb_test "-var-set-format weird.char_ptr natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"$hex \\\\\"hello\\\\\"\"" \
"set format variable weird.char_ptr"
mi_gdb_test "-var-set-format weird.long_int natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"0\"" \
"set format variable weird.long_int"
mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"$hex\"" \
"set format variable weird.int_ptr_ptr"
mi_gdb_test "-var-set-format weird.long_array natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"\\\[10\\\]\"" \
"set format variable weird.long_array"
mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
- "\\^done,format=\"hexadecimal\"" \
+ "\\^done,format=\"hexadecimal\",value=\"$hex\"" \
"set format variable weird.func_ptr"
mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \
- "\\^done,format=\"hexadecimal\"" \
+ "\\^done,format=\"hexadecimal\",value=\"$hex\"" \
"set format variable weird.func_ptr_struct"
mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"0\"" \
"set format variable weird.func_ptr_ptr"
mi_gdb_test "-var-set-format weird.u1 natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"\{...\}\"" \
"set format variable weird.u1"
mi_gdb_test "-var-set-format weird.s2 natural" \
- "\\^done,format=\"natural\"" \
+ "\\^done,format=\"natural\",value=\"\{...\}\"" \
"set format variable weird.s2"
# Test: c_variable-6.25
# #
##### #####
-# Stop in "do_special_tests"
+# Stop at the end of "do_special_tests"
-set line_dst_a_1 [gdb_get_line_number "a = 1;"]
+set line_dst_incr_a_2 [gdb_get_line_number "incr_a(2);"]
-mi_gdb_test "200-break-insert do_special_tests" \
- "200\\^done,bkpt=\{number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_special_tests\",file=\".*var-cmd.c\",line=\"$line_dst_a_1\",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\",line=\"$line_dst_a_1\"\}\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
-mi_gdb_test "-var-create u * u" \
- "\\^done,name=\"u\",numchild=\"2\",type=\"union named_union\"" \
- "create local variable u"
+mi_create_varobj u u "create local variable u"
# Test: c_variable-7.11
# Desc: value of u
# Test: c_variable-7.15
# Desc: children of u
-mi_gdb_test "-var-list-children u" \
- "\\^done,numchild=\"2\",children=\\\[child=\{name=\"u.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"u.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\}\\\]" \
- "get children of u"
+mi_list_varobj_children u {
+ {u.integer integer 0 int}
+ {u.char_ptr char_ptr 1 {char \*}}
+} "get children of u"
# Test: c_variable-7.20
# Desc: create anonu
-mi_gdb_test "-var-create anonu * anonu" \
- "\\^done,name=\"anonu\",numchild=\"3\",type=\"union \{\\.\\.\\.\}\"" \
- "create local variable anonu"
+mi_create_varobj anonu anonu "create local variable anonu"
# Test: c_variable-7.21
# Desc: value of anonu
# Test: c_variable-7.25
# Desc: children of anonu
-mi_gdb_test "-var-list-children anonu" \
- "\\^done,numchild=\"3\",children=\\\[child=\{name=\"anonu.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anonu.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anonu.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\\\]" \
- "get children of anonu"
+mi_list_varobj_children "anonu" {
+ {anonu.a a 0 int}
+ {anonu.b b 0 char}
+ {anonu.c c 0 "long int"}
+} "get children of anonu"
# Test: c_variable-7.30
# Desc: create struct s
-mi_gdb_test "-var-create s * s" \
- "\\^done,name=\"s\",numchild=\"6\",type=\"struct _simple_struct\"" \
- "create local variable s"
+mi_create_varobj s s "create local variable s"
# Test: c_variable-7.31
# Test: c_variable-7.35
# Desc: children of s
-mi_gdb_test "-var-list-children s" \
- "\\^done,numchild=\"6\",children=\\\[child=\{name=\"s.integer\",exp=\"integer\",numchild=\"0\",type=\"int\"\},child=\{name=\"s.unsigned_integer\",exp=\"unsigned_integer\",numchild=\"0\",type=\"unsigned int\"\},child=\{name=\"s.character\",exp=\"character\",numchild=\"0\",type=\"char\"\},child=\{name=\"s.signed_character\",exp=\"signed_character\",numchild=\"0\",type=\"signed char\"\},child=\{name=\"s.char_ptr\",exp=\"char_ptr\",numchild=\"1\",type=\"char \\*\"\},child=\{name=\"s.array_of_10\",exp=\"array_of_10\",numchild=\"10\",type=\"int \\\[10\\\]\"\}\\\]" \
- "get children of s"
+mi_list_varobj_children s {
+ {s.integer integer 0 int}
+ {s.unsigned_integer unsigned_integer 0 "unsigned int"}
+ {s.character character 0 char}
+ {s.signed_character signed_character 0 "signed char"}
+ {s.char_ptr char_ptr 1 {char \*}}
+ {s.array_of_10 array_of_10 10 {int \[10\]}}
+} "get children of s"
#} {integer unsigned_integer character signed_character char_ptr array_of_10}
# Test: c_variable-7.40
# Desc: create anons
-mi_gdb_test "-var-create anons * anons" \
- "\\^done,name=\"anons\",numchild=\"3\",type=\"struct \{\\.\\.\\.\}\"" \
- "create local variable anons"
+mi_create_varobj anons anons "create local variable anons"
# Test: c_variable-7.41
# Desc: value of anons
# Test: c_variable-7.45
# Desc: children of anons
-mi_gdb_test "-var-list-children anons" \
- "\\^done,numchild=\"3\",children=\\\[child=\{name=\"anons.a\",exp=\"a\",numchild=\"0\",type=\"int\"\},child=\{name=\"anons.b\",exp=\"b\",numchild=\"0\",type=\"char\"\},child=\{name=\"anons.c\",exp=\"c\",numchild=\"0\",type=\"long int\"\}\\\]" \
- "get children of anons"
-
+mi_list_varobj_children anons {
+ {anons.a a 0 int}
+ {anons.b b 0 char}
+ {anons.c c 0 "long int"}
+} "get children of anons"
# Test: c_variable-7.50
# Desc: create enum e
-mi_gdb_test "-var-create e * e" \
- "\\^done,name=\"e\",numchild=\"0\",type=\"enum foo\"" \
- "create local variable e"
+mi_create_varobj e e "create local variable e"
setup_xfail "*-*-*"
# Test: c_variable-7.51
# Test: c_variable-7.60
# Desc: create anone
-mi_gdb_test "-var-create anone * anone" \
- "\\^done,name=\"anone\",numchild=\"0\",type=\"enum \{\\.\\.\\.\}\"" \
- "create local variable anone"
+mi_create_varobj anone anone "create local variable anone"
-setup_xfail "*-*-*"
# Test: c_variable-7.61
# Desc: value of anone
mi_gdb_test "-var-evaluate-expression anone" \
"\\^done,value=\"A\"" \
"eval variable anone"
-clear_xfail "*-*-*"
-
# Test: c_variable-7.70
# Desc: create anone
mi_gdb_test "-var-create anone * anone" \
- "&\"Duplicate variable object name\\\\n\".*\\^error,msg=\"Duplicate variable object name\"" \
+ "\\^error,msg=\"Duplicate variable object name\"" \
"create duplicate local variable anone"
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\",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\",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
mi_gdb_test "-var-create a1 * a" \
- "\\^done,name=\"a1\",numchild=\"0\",type=\"char\"" \
+ "\\^done,name=\"a1\",numchild=\"0\",value=\".*\",type=\"char\".*" \
"create local variable a1"
mi_gdb_test "-var-create a2 $fp a" \
- "\\^done,name=\"a2\",numchild=\"0\",type=\"int\"" \
+ "\\^done,name=\"a2\",numchild=\"0\",value=\".*\",type=\"int\".*" \
"create variable a2 in different scope"
#gdbtk_test c_variable-7.81 {create variables in different scopes} {