diff options
author | Andrew Burgess <aburgess@broadcom.com> | 2013-07-25 10:39:39 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@broadcom.com> | 2013-07-25 10:39:39 +0000 |
commit | fdc8aae84831d0ae839672f4ee47e53f295a7869 (patch) | |
tree | c27df8427c8d8689477fd525a02f8dca5cc67edb /gdb/mi | |
parent | 6fbe845e0c00ca40e98aa23401e0b5490717a646 (diff) | |
download | fsf-binutils-gdb-fdc8aae84831d0ae839672f4ee47e53f295a7869.zip fsf-binutils-gdb-fdc8aae84831d0ae839672f4ee47e53f295a7869.tar.gz fsf-binutils-gdb-fdc8aae84831d0ae839672f4ee47e53f295a7869.tar.bz2 |
Resue 'z' formatter from mi register display code.
http://sourceware.org/ml/gdb-patches/2013-07/msg00236.html
gdb/ChangeLog
* mi/mi-main.c (output_register): Make MI 'r' format use standard
'z' format code. Remove error for optimized out values, standard
code will handle these fine.
gdb/testsuite/ChangeLog
* gdb.mi/mi-reg-undefined.exp: New file.
* gdb.mi/mi-reg-undefined.c: Likewise.
* gdb.mi/mi-reg-undefined.S: Likewise.
Diffstat (limited to 'gdb/mi')
-rw-r--r-- | gdb/mi/mi-main.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 6289143..c2d8501 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1163,6 +1163,8 @@ output_register (struct frame_info *frame, int regnum, int format, struct ui_out *uiout = current_uiout; struct value *val = get_frame_register_value (frame, regnum); struct cleanup *tuple_cleanup; + struct value_print_options opts; + struct ui_file *stb; if (skip_unavailable && !value_entirely_available (val)) return; @@ -1173,45 +1175,19 @@ output_register (struct frame_info *frame, int regnum, int format, if (format == 'N') format = 0; - if (value_optimized_out (val)) - error (_("Optimized out")); - if (format == 'r') - { - int j; - char *ptr, buf[1024]; - const gdb_byte *valaddr = value_contents_for_printing (val); + format = 'z'; - strcpy (buf, "0x"); - ptr = buf + 2; - for (j = 0; j < register_size (gdbarch, regnum); j++) - { - int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? - j : register_size (gdbarch, regnum) - 1 - j; - - sprintf (ptr, "%02x", (unsigned char) valaddr[idx]); - ptr += 2; - } - ui_out_field_string (uiout, "value", buf); - } - else - { - struct value_print_options opts; - struct ui_file *stb; - struct cleanup *old_chain; - - stb = mem_fileopen (); - old_chain = make_cleanup_ui_file_delete (stb); - - get_formatted_print_options (&opts, format); - opts.deref_ref = 1; - val_print (value_type (val), - value_contents_for_printing (val), - value_embedded_offset (val), 0, - stb, 0, val, &opts, current_language); - ui_out_field_stream (uiout, "value", stb); - do_cleanups (old_chain); - } + stb = mem_fileopen (); + make_cleanup_ui_file_delete (stb); + + get_formatted_print_options (&opts, format); + opts.deref_ref = 1; + val_print (value_type (val), + value_contents_for_printing (val), + value_embedded_offset (val), 0, + stb, 0, val, &opts, current_language); + ui_out_field_stream (uiout, "value", stb); do_cleanups (tuple_cleanup); } |