diff options
author | Pedro Alves <palves@redhat.com> | 2011-01-25 17:00:27 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2011-01-25 17:00:27 +0000 |
commit | 2062226976cdf020016442cc64de30c984b407d3 (patch) | |
tree | b038383a6912ab0e9722eeb9aa5c5c555d43a394 | |
parent | 585fdaa10662a5a89a0de0dcfa076378df05a67b (diff) | |
download | gdb-2062226976cdf020016442cc64de30c984b407d3.zip gdb-2062226976cdf020016442cc64de30c984b407d3.tar.gz gdb-2062226976cdf020016442cc64de30c984b407d3.tar.bz2 |
* mi/mi-main.c (get_register): Use get_frame_register_value rather
than frame_register, and always pass a valid value to val_print.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/mi/mi-main.c | 17 |
2 files changed, 14 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 63825e7..d61ded8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2011-01-25 Pedro Alves <pedro@codesourcery.com> + * mi/mi-main.c (get_register): Use get_frame_register_value rather + than frame_register, and always pass a valid value to val_print. + +2011-01-25 Pedro Alves <pedro@codesourcery.com> + Centralize printing "<optimized out>". * valprint.h (val_print_optimized_out): Declare. diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 366e494..1f1b712 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1116,27 +1116,26 @@ static void get_register (struct frame_info *frame, int regnum, int format) { struct gdbarch *gdbarch = get_frame_arch (frame); - gdb_byte buffer[MAX_REGISTER_SIZE]; - int optim; - int realnum; CORE_ADDR addr; enum lval_type lval; static struct ui_stream *stb = NULL; + struct value *val; stb = ui_out_stream_new (uiout); if (format == 'N') format = 0; - frame_register (frame, regnum, &optim, &lval, &addr, &realnum, buffer); + val = get_frame_register_value (frame, regnum); - if (optim) + 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); strcpy (buf, "0x"); ptr = buf + 2; @@ -1145,7 +1144,7 @@ get_register (struct frame_info *frame, int regnum, int format) int idx = gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG ? j : register_size (gdbarch, regnum) - 1 - j; - sprintf (ptr, "%02x", (unsigned char) buffer[idx]); + sprintf (ptr, "%02x", (unsigned char) valaddr[idx]); ptr += 2; } ui_out_field_string (uiout, "value", buf); @@ -1157,8 +1156,10 @@ get_register (struct frame_info *frame, int regnum, int format) get_formatted_print_options (&opts, format); opts.deref_ref = 1; - val_print (register_type (gdbarch, regnum), buffer, 0, 0, - stb->stream, 0, NULL, &opts, current_language); + val_print (value_type (val), + value_contents_for_printing (val), + value_embedded_offset (val), 0, + stb->stream, 0, val, &opts, current_language); ui_out_field_stream (uiout, "value", stb); ui_out_stream_delete (stb); } |