-# Copyright 1999, 2000, 2001, 2002, 2004, 2005, 2007, 2008, 2009
-# Free Software Foundation, Inc.
+# Copyright 1999-2020 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
continue
}
-set testfile "var-cmd"
-set srcfile ${testfile}.c
-set binfile ${objdir}/${subdir}/mi-var-cmd
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
- untested mi-var-cmd.exp
+standard_testfile var-cmd.c
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
+ untested "failed to compile"
return -1
}
mi_create_varobj "global_simple" "global_simple" "create global variable"
+# PR mi/15863
+# Attempt to update the varobj before running the inferior.
+mi_gdb_test "-var-update *" \
+ "\\^done,changelist=\\\[\\\]" \
+ "update varobj before running inferior"
+
# Test: c_variable-1.2
# Desc: Create non-existent variable
mi_gdb_test "112-var-create bogus_unknown_variable * bogus_unknown_variable" \
- "112\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
+ "112\\^error,msg=\"-var-create: unable to create variable object\"" \
"create non-existent variable"
# Test: c_variable-1.3
# Desc: Create out of scope variable
mi_gdb_test "113-var-create argc * argc" \
- "113\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
+ "113\\^error,msg=\"-var-create: unable to create variable object\"" \
"create out of scope variable"
-mi_runto do_locals_tests
+with_test_prefix "first run" {
+ mi_runto do_locals_tests
+}
set line_dlt_first_real [gdb_get_line_number "linteger = 1234;"]
mi_create_varobj_checked lpcharacter lpcharacter {char \*} "create local variable lpcharacter"
-mi_create_varobj_checked llong llong "long int" "create local variable llong"
+mi_create_varobj_checked llong llong "long" "create local variable llong"
-mi_create_varobj_checked lplong lplong {long int \*} "create local variable lplong"
+mi_create_varobj_checked lplong lplong {long \*} "create local variable lplong"
mi_create_varobj_checked lfloat lfloat float "create local variable lfloat"
# Type names (like int, long, etc..) are all proper expressions to gdb.
# make sure variable code does not allow users to create variables, though.
mi_gdb_test "-var-create int * int" \
- "&\"Attempt to use a type name as an expression.\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
+ "&\"Attempt to use a type name as an expression.\\\\n\".*\\^error,msg=\"-var-create: unable to create variable object\"" \
"create int"
#
###
mi_gdb_test "-var-assign global_simple 0" \
- "\\^error,msg=\"mi_cmd_var_assign: Variable object is not editable\"" \
+ "\\^error,msg=\"-var-assign: Variable object is not editable\"" \
"assign to global_simple"
mi_gdb_test "-var-assign linteger 3333" \
"\\^done,value=\"3333\"" \
- "assign to linteger"
+ "assign to linteger, 1st"
# Allow lpcharacter to update, optionally. Because it points to a
# char variable instead of a zero-terminated string, if linteger is
mi_gdb_test "-var-assign lpinteger \"&linteger + 3\"" \
"\\^done,value=\"$hex\"" \
- "assign to lpinteger"
+ "assign to lpinteger, 1st"
mi_gdb_test "-var-update *" \
"\\^done,changelist=\\\[\{name=\"lpinteger\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
mi_gdb_test "-var-assign linteger 4321" \
"\\^done,value=\"4321\"" \
- "assign to linteger"
+ "assign to linteger, 2nd"
mi_gdb_test "-var-assign lpinteger &linteger" \
"\\^done,value=\"$hex\"" \
- "assign to lpinteger"
+ "assign to lpinteger, 2nd"
mi_gdb_test "-var-assign lcharacter 'z'" \
"\\^done,value=\"122 'z'\"" \
mi_gdb_test "-var-assign llong 1313L" \
"\\^done,value=\"1313\"" \
- "assign to llong"
+ "assign to llong, 1st"
mi_gdb_test "-var-evaluate-expression llong" \
"\\^done,value=\"1313\"" \
"eval llong"
mi_gdb_test "-var-assign llong 1212L" \
"\\^done,value=\"1212\"" \
- "assign to llong"
+ "assign to llong, 2nd"
mi_gdb_test "-var-assign lplong &llong+4" \
"\\^done,value=\"$hex\"" \
- "assign to lplong"
+ "assign to lplong, 1st"
mi_gdb_test "-var-evaluate-expression lplong" \
"\\^done,value=\"$hex\"" \
"eval lplong"
mi_gdb_test "-var-assign lplong &llong" \
"\\^done,value=\"$hex\"" \
- "assign to lplong"
+ "assign to lplong, 2nd"
mi_gdb_test "-var-assign lfloat 3.4567" \
"\\^done,value=\"3.45.*\"" \
- "assign to lfloat"
+ "assign to lfloat, 1st"
mi_gdb_test "-var-evaluate-expression lfloat" \
"\\^done,value=\"3.45.*\"" \
"eval lfloat"
mi_gdb_test "-var-assign lfloat 1.2345" \
"\\^done,value=\"1.23.*\"" \
- "assign to lfloat"
+ "assign to lfloat, 2nd"
mi_gdb_test "-var-assign lpfloat &lfloat+4" \
"\\^done,value=\"$hex\"" \
"assign same value to func (update)"
mi_gdb_test "-var-create array_ptr * array_ptr" \
- "\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex\",type=\"int \\*\",has_more=\"0\"" \
+ "\\^done,name=\"array_ptr\",numchild=\"1\",value=\"$hex <array>\",type=\"int \\*\",has_more=\"0\"" \
"create global variable array_ptr"
mi_gdb_test "-var-assign array_ptr array2" \
- "\\^done,value=\"$hex\"" \
+ "\\^done,value=\"$hex <array2>\"" \
"assign array to pointer"
mi_gdb_test "-var-update *" \
"assign array to pointer (update)"
mi_gdb_test "-var-assign array_ptr array2" \
- "\\^done,value=\"$hex\"" \
+ "\\^done,value=\"$hex <array2>\"" \
"assign same array to pointer"
mi_gdb_test "-var-update *" \
# Desc: create variable for locals i,l in subroutine1
mi_create_varobj_checked i i int "create i"
-mi_create_varobj_checked l l {long int \*} "create l"
+mi_create_varobj_checked l l {long \*} "create l"
# Test: c_variable-2.11
# Desc: create do_locals_tests local in subroutine1
mi_gdb_test "-var-create linteger * linteger" \
- "\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
+ "\\^error,msg=\"-var-create: unable to create variable object\"" \
"create linteger"
mi_step_to "subroutine1" "\{name=\"i\",value=\".*\"\},\{name=\"l\",value=\".*\"\}" \
"\\^done,changelist=\\\[\{name=\"selected_a\",in_scope=\"true\",type_changed=\"true\",new_type=\"int\",new_num_children=\"0\",has_more=\"0\"\}\\\]" \
"update selected_a in do_special_tests"
-mi_gdb_test "-file-exec-and-symbols ${binfile}" "\\^done" \
+if [is_remote host] {
+ set filename ${testfile}
+} else {
+ set filename ${binfile}
+}
+
+mi_gdb_test "-file-exec-and-symbols ${filename}" "\\^done" \
"floating varobj invalidation"
mi_delete_varobj selected_a "delete selected_a"
mi_prepare_inline_tests $srcfile
mi_run_inline_test frozen
+mi_run_inline_test bitfield
+
# Since the inline test framework does not really work with
# function calls, first to inline tests and then do the reminder
# manually.
"kill program before endvar"
mi_gdb_test "-var-create endvar * _end" \
- {(\^done,name="endvar",numchild="0",value=".*",type=".*"|&".*unable to.*".*\^error,msg=".*")} \
+ {(\^done,name="endvar",numchild="0",value=".*",type=".*"|\^error,msg=".*")} \
"create endvar"
# Allow this to succeed whether the value is readable, unreadable, or
# missing. Most important is that GDB does not crash.
mi_gdb_test "-var-update endvar" \
- {(\^done,changelist=\[.*\]|^".*".*\^error,msg=".*not found")} \
+ {(\^done,changelist=\[.*\]|\^error,msg=".*not found")} \
"update endvar"
mi_gdb_test "-var-delete endvar" \
- "\\^done,ndeleted=\"1\"" \
+ {(\^done,ndeleted="1"|\^error,msg=".*not found")} \
"delete endvar"
mi_delete_breakpoints
-mi_runto do_locals_tests
+with_test_prefix "second run" {
+ mi_runto do_locals_tests
+}
mi_create_varobj "L" "lsimple" "in-and-out-of-scope: create varobj"
mi_check_varobj_value "L" "{...}" "in-and-out-of-scope: check initial value"