From: Gary Benson Date: Wed, 3 Sep 2014 11:05:50 +0000 (+0100) Subject: x86 debug address register clarifications X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=97ea6506c45ab5519483a0221fdc049038496492;p=binutils-gdb.git x86 debug address register clarifications The loop macro ALL_DEBUG_REGISTERS does not iterate over the status or control registers, so its name is misleading. This commit renames it as ALL_DEBUG_ADDRESS_REGISTERS and updates all uses. This commit also updates its loop conditions to an equivalent but better form, and makes two functions use it that had previously hardwired the loop. A comment on a related field in the x86_debug_reg_state structure is also updated to reflect that the field refers specifically to address registers only. gdb/ChangeLog: * nat/x86-dregs.h (ALL_DEBUG_REGISTERS): Renamed as... (ALL_DEBUG_ADDRESS_REGISTERS): New macro. All uses updated. Loop conditions changed to equivalent form. (struct x86_debug_reg_state): Updated dr_ref_count comment. * x86-linux-nat.c (x86_linux_prepare_to_resume): Use ALL_DEBUG_ADDRESS_REGISTERS. gdb/gdbserver/ChangeLog: * linux-x86-low.c (x86_linux_prepare_to_resume): Use ALL_DEBUG_ADDRESS_REGISTERS. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f4059d9198c..80961d6fc24 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2014-09-03 Gary Benson + + * nat/x86-dregs.h (ALL_DEBUG_REGISTERS): Renamed as... + (ALL_DEBUG_ADDRESS_REGISTERS): New macro. All uses updated. + Loop conditions changed to equivalent form. + (struct x86_debug_reg_state): Updated dr_ref_count comment. + * x86-linux-nat.c (x86_linux_prepare_to_resume): Use + ALL_DEBUG_ADDRESS_REGISTERS. + 2014-09-03 Joel Brobecker * dwarf2loc.h (dwarf2_evaluate_property): Minor function diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index c2c86df8905..a47ef492293 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,8 @@ +2014-09-03 Gary Benson + + * linux-x86-low.c (x86_linux_prepare_to_resume): Use + ALL_DEBUG_ADDRESS_REGISTERS. + 2014-09-02 Gary Benson * i386-low.h: Renamed as... diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index 6b73886b021..a66f61edc1c 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -787,7 +787,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) x86_linux_dr_set (ptid, DR_CONTROL, 0); - for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) + ALL_DEBUG_ADDRESS_REGISTERS (i) if (state->dr_ref_count[i] > 0) { x86_linux_dr_set (ptid, i, state->dr_mirror[i]); diff --git a/gdb/gdbserver/x86-low.c b/gdb/gdbserver/x86-low.c index aaa110e3aae..b48a15d23b5 100644 --- a/gdb/gdbserver/x86-low.c +++ b/gdb/gdbserver/x86-low.c @@ -28,7 +28,7 @@ x86_low_init_dregs (struct x86_debug_reg_state *state) { int i; - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { state->dr_mirror[i] = 0; state->dr_ref_count[i] = 0; diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c index 5381c77c786..fbb24263e33 100644 --- a/gdb/nat/x86-dregs.c +++ b/gdb/nat/x86-dregs.c @@ -205,7 +205,7 @@ x86_show_dr (struct x86_debug_reg_state *state, debug_printf ("\tCONTROL (DR7): %s STATUS (DR6): %s\n", phex (state->dr_control_mirror, 8), phex (state->dr_status_mirror, 8)); - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { debug_printf ("\ \tDR%d: addr=0x%s, ref.count=%d DR%d: addr=0x%s, ref.count=%d\n", @@ -291,7 +291,7 @@ x86_insert_aligned_watchpoint (struct x86_debug_reg_state *state, /* First, look for an occupied debug register with the same address and the same RW and LEN definitions. If we find one, we can reuse it for this watchpoint as well (and save a register). */ - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { if (!X86_DR_VACANT (state, i) && state->dr_mirror[i] == addr @@ -303,7 +303,7 @@ x86_insert_aligned_watchpoint (struct x86_debug_reg_state *state, } /* Next, look for a vacant debug register. */ - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { if (X86_DR_VACANT (state, i)) break; @@ -346,7 +346,7 @@ x86_remove_aligned_watchpoint (struct x86_debug_reg_state *state, int i, retval = -1; int all_vacant = 1; - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { if (!X86_DR_VACANT (state, i) && state->dr_mirror[i] == addr @@ -461,7 +461,7 @@ x86_update_inferior_debug_regs (struct x86_debug_reg_state *state, { int i; - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { if (X86_DR_VACANT (new_state, i) != X86_DR_VACANT (state, i)) x86_dr_low_set_addr (new_state, i); @@ -620,7 +620,7 @@ x86_dr_stopped_data_address (struct x86_debug_reg_state *state, registers. */ status = x86_dr_low_get_status (); - ALL_DEBUG_REGISTERS (i) + ALL_DEBUG_ADDRESS_REGISTERS (i) { if (!X86_DR_WATCH_HIT (status, i)) continue; diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h index fb179a594fa..aebcbce5a61 100644 --- a/gdb/nat/x86-dregs.h +++ b/gdb/nat/x86-dregs.h @@ -85,12 +85,13 @@ struct x86_debug_reg_state CORE_ADDR dr_mirror[DR_NADDR]; unsigned dr_status_mirror, dr_control_mirror; - /* Reference counts for each debug register. */ + /* Reference counts for each debug address register. */ int dr_ref_count[DR_NADDR]; }; -/* A macro to loop over all debug registers. */ -#define ALL_DEBUG_REGISTERS(i) for (i = 0; i < DR_NADDR; i++) +/* A macro to loop over all debug address registers. */ +#define ALL_DEBUG_ADDRESS_REGISTERS(i) \ + for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) /* Insert a watchpoint to watch a memory region which starts at address ADDR and whose length is LEN bytes. Watch memory accesses diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c index 5340dfe2400..0d070dda9fe 100644 --- a/gdb/x86-linux-nat.c +++ b/gdb/x86-linux-nat.c @@ -195,7 +195,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) results in EINVAL. */ x86_linux_dr_set (lwp->ptid, DR_CONTROL, 0); - for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++) + ALL_DEBUG_ADDRESS_REGISTERS (i) if (state->dr_ref_count[i] > 0) { x86_linux_dr_set (lwp->ptid, i, state->dr_mirror[i]);