From fdc8aae84831d0ae839672f4ee47e53f295a7869 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Thu, 25 Jul 2013 10:39:39 +0000 Subject: 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. --- gdb/mi/mi-main.c | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'gdb/mi') 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); } -- cgit v1.1