Re: [PATCH]: MI -var-set-format

Nick Roberts
2006-05-16T02:35:48Z

> Could you resubmit the patch including any necessary testsuite changes,
> please?

I've just changed mi-var-display.exp. Shall I do the same for
mi2-var-display.exp?

I've tried to create a global for $octal. I see that mi-regs.exp has its own
but it probably makes sense to centralise it.

Have you made a test for your change to val_print? It could go in this
file or mi-var-cmd.exp.

--
Nick http://www.inet.net.nz/~nickrob

2006-05-16 Nick Roberts <nickrob@snap.net.nz>

* mi/mi-cmd-var.c (mi_cmd_var_set_format): Add value field to output.

* gdb.mi/mi-var-display.exp: Add value field to tests for output of
-var-set-format.

*** mi-cmd-var.c 31 Mar 2006 12:46:48 +1200 1.23
--- mi-cmd-var.c 02 May 2006 18:16:39 +1200
***************
*** 211,216 ****
--- 211,219 ----

/* Report the new current format */
ui_out_field_string (uiout, "format", varobj_format_string[(int) format]);
+
+ /* Report the value in the new format */
+ ui_out_field_string (uiout, "value", varobj_get_value (var));
return MI_CMD_DONE;
}

*** mi-support.exp 29 Sep 2005 08:33:05 +1200 1.32
--- mi-support.exp 17 May 2006 14:03:01 +1200
*************** global mi_inferior_tty_name
*** 33,38 ****
--- 33,39 ----

set MIFLAGS "-i=mi"

+ set octal "\[0-7\]+"
#
# mi_gdb_exit -- exit the GDB, killing the target program if necessary
#
*************** proc mi_runto {func} {
*** 870,876 ****
}

global mi_gdb_prompt expect_out
! global hex decimal fullname_syntax

set test "mi runto $func"
mi_gdb_test "200-break-insert $func" \
--- 871,877 ----
}

global mi_gdb_prompt expect_out
! global hex octal decimal fullname_syntax

set test "mi runto $func"
mi_gdb_test "200-break-insert $func" \
*************** proc mi_execute_to_helper { cmd reason f
*** 926,932 ****
return -1
}
global mi_gdb_prompt
! global hex
global decimal
global fullname_syntax
send_gdb "220-$cmd\n"
--- 927,933 ----
return -1
}
global mi_gdb_prompt
! global hex octal
global decimal
global fullname_syntax
send_gdb "220-$cmd\n"

*** mi-var-display.exp 30 May 2005 14:02:09 +1200 1.13
--- mi-var-display.exp 17 May 2006 14:10:52 +1200
*************** mi_gdb_test "-var-evaluate-expression ba
*** 89,95 ****
# Test: c_variable-6.5
# Desc: change format of bar to hex
mi_gdb_test "-var-set-format bar hexadecimal" \
! "\\^done,format=\"hexadecimal\"" \
"set format variable bar"

# Test: c_variable-6.6
--- 89,95 ----
# Test: c_variable-6.5
# Desc: change format of bar to hex
mi_gdb_test "-var-set-format bar hexadecimal" \
! "\\^done,format=\"hexadecimal\",value=\"0x849\"" \
"set format variable bar"

# Test: c_variable-6.6
*************** mi_gdb_test "-var-assign bar 3" \
*** 105,111 ****
"assing to variable bar"

mi_gdb_test "-var-set-format bar decimal" \
! "\\^done,format=\"decimal\"" \
"set format variable bar"

mi_gdb_test "-var-evaluate-expression bar" \
--- 105,111 ----
"assing to variable bar"

mi_gdb_test "-var-set-format bar decimal" \
! "\\^done,format=\"decimal\",value=\"3\"" \
"set format variable bar"

mi_gdb_test "-var-evaluate-expression bar" \
*************** mi_gdb_test "-var-evaluate-expression fo
*** 143,149 ****
# Test: c_variable-6.15
# Desc: change format of var to octal
mi_gdb_test "-var-set-format foo octal" \
! "\\^done,format=\"octal\"" \
"set format variable foo"

mi_gdb_test "-var-show-format foo" \
--- 143,149 ----
# Test: c_variable-6.15
# Desc: change format of var to octal
mi_gdb_test "-var-set-format foo octal" \
! "\\^done,format=\"octal\",value=\"$octal\"" \
"set format variable foo"

mi_gdb_test "-var-show-format foo" \
*************** mi_gdb_test "-var-assign foo 3" \
*** 163,169 ****
"assing to variable foo"

mi_gdb_test "-var-set-format foo decimal" \
! "\\^done,format=\"decimal\"" \
"set format variable foo"

# Test: c_variable-6.18
--- 163,169 ----
"assing to variable foo"

mi_gdb_test "-var-set-format foo decimal" \
! "\\^done,format=\"decimal\",value=\"3\"" \
"set format variable foo"

# Test: c_variable-6.18
*************** mi_gdb_test "-var-list-children weird" \
*** 190,196 ****
# 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\"" \
"set format variable weird.func_ptr"

mi_gdb_test "-var-show-format weird.func_ptr" \
--- 190,196 ----
# 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\",value=\"$hex\"" \
"set format variable weird.func_ptr"

mi_gdb_test "-var-show-format weird.func_ptr" \
*************** mi_gdb_test "-var-show-format weird.func
*** 198,204 ****
"show format variable weird.func_ptr"

mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \
! "\\^done,format=\"hexadecimal\"" \
"set format variable weird.func_ptr_ptr"

mi_gdb_test "-var-show-format weird.func_ptr_ptr" \
--- 198,204 ----
"show format variable weird.func_ptr"

mi_gdb_test "-var-set-format weird.func_ptr_ptr hexadecimal" \
! "\\^done,format=\"hexadecimal\",value=\"$hex\"" \
"set format variable weird.func_ptr_ptr"

mi_gdb_test "-var-show-format weird.func_ptr_ptr" \
*************** mi_gdb_test "-var-show-format weird.func
*** 208,258 ****
# Test: c_variable-6.24
# Desc: format of weird and children
mi_gdb_test "-var-set-format weird natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird"

mi_gdb_test "-var-set-format weird.integer natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.integer"

mi_gdb_test "-var-set-format weird.character natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.character"

mi_gdb_test "-var-set-format weird.char_ptr natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.char_ptr"

mi_gdb_test "-var-set-format weird.long_int natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.long_int"

mi_gdb_test "-var-set-format weird.int_ptr_ptr natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.int_ptr_ptr"

mi_gdb_test "-var-set-format weird.long_array natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.long_array"

mi_gdb_test "-var-set-format weird.func_ptr hexadecimal" \
! "\\^done,format=\"hexadecimal\"" \
"set format variable weird.func_ptr"

mi_gdb_test "-var-set-format weird.func_ptr_struct hexadecimal" \
! "\\^done,format=\"hexadecimal\"" \
"set format variable weird.func_ptr_struct"

mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.func_ptr_ptr"

mi_gdb_test "-var-set-format weird.u1 natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.u1"

mi_gdb_test "-var-set-format weird.s2 natural" \
! "\\^done,format=\"natural\"" \
"set format variable weird.s2"

# Test: c_variable-6.25
--- 208,258 ----
# Test: c_variable-6.24
# Desc: format of weird and children
mi_gdb_test "-var-set-format weird natural" \
! "\\^done,format=\"natural\",value=\"$hex\"" \
"set format variable weird"

mi_gdb_test "-var-set-format weird.integer natural" \
! "\\^done,format=\"natural\",value=\"123\"" \
"set format variable weird.integer"

mi_gdb_test "-var-set-format weird.character natural" \
! "\\^done,format=\"natural\",value=\"50 '2'\"" \
"set format variable weird.character"

mi_gdb_test "-var-set-format weird.char_ptr 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\",value=\"0\"" \
"set format variable weird.long_int"

mi_gdb_test "-var-set-format weird.int_ptr_ptr 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\",value=\"\\\[10\\\]\"" \
"set format variable weird.long_array"

mi_gdb_test "-var-set-format weird.func_ptr 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\",value=\"$hex\"" \
"set format variable weird.func_ptr_struct"

mi_gdb_test "-var-set-format weird.func_ptr_ptr natural" \
! "\\^done,format=\"natural\",value=\"$hex\"" \
"set format variable weird.func_ptr_ptr"

mi_gdb_test "-var-set-format weird.u1 natural" \
! "\\^done,format=\"natural\",value=\"\{...\}\"" \
"set format variable weird.u1"

mi_gdb_test "-var-set-format weird.s2 natural" \
! "\\^done,format=\"natural\",value=\"\{...\}\"" \
"set format variable weird.s2"

# Test: c_variable-6.25