summaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2013-09-05 11:50:48 +0000
committerPedro Alves <palves@redhat.com>2013-09-05 11:50:48 +0000
commiteda72100f3a374bc40a590fc3c8528e6f436d9e6 (patch)
tree83cc48c7870265128268f280d360a11880ce6e04 /gdb/tui
parent6bb41be8f47878c94ab31579ee8d0229e37b0a07 (diff)
downloadgdb-eda72100f3a374bc40a590fc3c8528e6f436d9e6.tar.gz
[TUI] Rewrite register-changed decision bits.
I stumbled on the TUI's register-changed decision code before (used to decided whether the register should be highlighted in the register window), for it is trying to compare all the different possible states and contents or previous/current register contents, and as such may need updating whenever the value machinery changes to have more state. It's just much simpler and more future proof to compare the previous/current printable representation instead. The bit in tui_register_format that returns early if the register has no name gets a bit in the way of the new prototype (what to return in that case? NULL, empty string, etc.?). Fortunately, that check isn't really necessary. All the callers will have already skipped unnamed registers. gdb/ 2013-09-05 Pedro Alves <palves@redhat.com> * tui/tui-regs.c (tui_register_format): Don't look at the register's name here. Return string representing register value instead of storing it in the data element. (tui_get_register): Compare register string representations instead of register value states and contents.
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-regs.c55
1 files changed, 15 insertions, 40 deletions
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index b043a29c24b..5ebf4c804cf 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -58,9 +58,6 @@ static enum tui_status tui_get_register (struct frame_info *frame,
struct tui_data_element *data,
int regnum, int *changedp);
-static void tui_register_format (struct frame_info *,
- struct tui_data_element*, int);
-
static void tui_scroll_regs_forward_command (char *, int);
static void tui_scroll_regs_backward_command (char *, int);
@@ -669,23 +666,18 @@ tui_restore_gdbout (void *ui)
pagination_enabled = 1;
}
-/* Get the register from the frame and make a printable representation
- of it in the data element. */
-static void
-tui_register_format (struct frame_info *frame,
- struct tui_data_element *data_element,
- int regnum)
+/* Get the register from the frame and return a printable
+ representation of it. */
+
+static char *
+tui_register_format (struct frame_info *frame, int regnum)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
struct ui_file *stream;
struct ui_file *old_stdout;
- const char *name;
struct cleanup *cleanups;
char *p, *s;
-
- name = gdbarch_register_name (gdbarch, regnum);
- if (name == 0 || *name == '\0')
- return;
+ char *ret;
pagination_enabled = 0;
old_stdout = gdb_stdout;
@@ -702,9 +694,10 @@ tui_register_format (struct frame_info *frame,
if (s && s[1] == 0)
*s = 0;
- xfree (data_element->content);
- data_element->content = xstrdup (p);
+ ret = xstrdup (p);
do_cleanups (cleanups);
+
+ return ret;
}
/* Get the register value from the given frame and format it for the
@@ -721,33 +714,15 @@ tui_get_register (struct frame_info *frame,
*changedp = FALSE;
if (target_has_registers)
{
- struct value *old_val = data->value;
+ char *prev_content = data->content;
- data->value = get_frame_register_value (frame, regnum);
- release_value (data->value);
- if (changedp)
- {
- struct gdbarch *gdbarch = get_frame_arch (frame);
- int size = register_size (gdbarch, regnum);
-
- /* We only know whether a value chunk is available if we've
- tried to read it. */
- if (value_lazy (data->value))
- value_fetch_lazy (data->value);
- if (value_lazy (old_val))
- value_fetch_lazy (old_val);
-
- if (value_optimized_out (data->value) != value_optimized_out (old_val)
- || !value_available_contents_eq (data->value, 0,
- old_val, 0, size))
- *changedp = TRUE;
- }
+ data->content = tui_register_format (frame, regnum);
- value_free (old_val);
+ if (changedp != NULL
+ && strcmp (prev_content, data->content) != 0)
+ *changedp = 1;
- /* Reformat the data content if the value changed. */
- if (changedp == 0 || *changedp == TRUE)
- tui_register_format (frame, data, regnum);
+ xfree (prev_content);
ret = TUI_SUCCESS;
}