This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[unavailable regs/locals, 02/11] Teach -data-list-changed-registers about REG_UNAVAILABLE.
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 22 Feb 2011 13:28:38 +0000
- Subject: [unavailable regs/locals, 02/11] Teach -data-list-changed-registers about REG_UNAVAILABLE.
This function is comparing bogus contents of REG_UNAVAILABLE
registers with a straight memcmp. Teach it not to do so,
making use of patch of the previous patch's regcache_cooked_read change,
where regcache_cooked_read was made to return an indication
of the register status (for example, if the pseudo-register is
computed from an unavailable register, regcache_cooked_read
will return REG_UNAVAILABLE), thus also simplifying the code
a bit, and, handling pseudo-registers not in the save_reggroup
better.
--
Pedro Alves
2011-02-22 Pedro Alves <pedro@codesourcery.com>
gdb/
* mi/mi-main.c (register_changed_p): Handle REG_UNAVAILABLE, and
simplify, using regcache_cooked_read.
---
gdb/mi/mi-main.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
Index: src/gdb/mi/mi-main.c
===================================================================
--- src.orig/gdb/mi/mi-main.c 2011-01-25 16:46:47.587640006 +0000
+++ src/gdb/mi/mi-main.c 2011-02-02 12:25:07.167898998 +0000
@@ -1021,23 +1021,25 @@ register_changed_p (int regnum, struct r
struct gdbarch *gdbarch = get_regcache_arch (this_regs);
gdb_byte prev_buffer[MAX_REGISTER_SIZE];
gdb_byte this_buffer[MAX_REGISTER_SIZE];
+ enum register_status prev_status;
+ enum register_status this_status;
- /* Registers not valid in this frame return count as unchanged. */
- if (regcache_register_status (this_regs, regnum) == REG_UNKNOWN)
- return 0;
-
- /* First time through or after gdbarch change consider all registers as
- changed. Same for registers not valid in the previous frame. */
- if (!prev_regs || get_regcache_arch (prev_regs) != gdbarch
- || regcache_register_status (prev_regs, regnum) == REG_UNKNOWN)
+ /* First time through or after gdbarch change consider all registers
+ as changed. */
+ if (!prev_regs || get_regcache_arch (prev_regs) != gdbarch)
return 1;
/* Get register contents and compare. */
- regcache_cooked_read (prev_regs, regnum, prev_buffer);
- regcache_cooked_read (this_regs, regnum, this_buffer);
+ prev_status = regcache_cooked_read (prev_regs, regnum, prev_buffer);
+ this_status = regcache_cooked_read (this_regs, regnum, this_buffer);
- return memcmp (prev_buffer, this_buffer,
- register_size (gdbarch, regnum)) != 0;
+ if (this_status != prev_status)
+ return 1;
+ else if (this_status == REG_VALID)
+ return memcmp (prev_buffer, this_buffer,
+ register_size (gdbarch, regnum)) != 0;
+ else
+ return 0;
}
/* Return a list of register number and value pairs. The valid