[13/15] Move macros from i386-{nat,low}.c to i386-{nat,low}.h
Commit Message
This commit moves macros required by the soon-to-be-created
nat/i386-dregs.c into i386-{nat,low}.h.
gdb/
2014-06-17 Gary Benson <gbenson@redhat.com>
* i386-nat.h (i386_dr_low_can_set_addr): New macro.
(i386_dr_low_set_addr): Likewise.
(i386_dr_low_get_addr): Likewise.
(i386_dr_low_can_set_control): Likewise.
(i386_dr_low_set_control): Likewise.
(i386_dr_low_get_control): Likewise.
(i386_dr_low_get_status): Likewise.
(i386_get_debug_register_length): Likewise.
* i386-nat.c (i386_dr_low_can_set_addr): Now in i386-nat.h.
(i386_dr_low_set_addr): Likewise.
(i386_dr_low_get_addr): Likewise.
(i386_dr_low_can_set_control): Likewise.
(i386_dr_low_set_control): Likewise.
(i386_dr_low_get_control): Likewise.
(i386_dr_low_get_status): Likewise.
(i386_get_debug_register_length): Likewise.
gdb/gdbserver/
2014-06-17 Gary Benson <gbenson@redhat.com>
* i386-low.h (i386_dr_low_can_set_addr): New macro.
(i386_dr_low_can_set_control): Likewise.
(i386_get_debug_register_length): Likewise.
* i386-low.c (i386_dr_low_can_set_addr): Now in i386-low.h.
(i386_dr_low_can_set_control): Likewise.
(i386_get_debug_register_length): Likewise.
---
gdb/ChangeLog | 19 +++++++++++++++++++
gdb/gdbserver/ChangeLog | 9 +++++++++
gdb/gdbserver/i386-low.c | 7 -------
gdb/gdbserver/i386-low.h | 10 ++++++++++
gdb/i386-nat.c | 17 -----------------
gdb/i386-nat.h | 27 +++++++++++++++++++++++++++
6 files changed, 65 insertions(+), 24 deletions(-)
Comments
On 06/17/2014 03:12 PM, Gary Benson wrote:
> This commit moves macros required by the soon-to-be-created
> nat/i386-dregs.c into i386-{nat,low}.h.
To get rid of the remaining '#ifdef GDBSERVER's in the
new i386-dregs.c, we could make gdbserver use the i386_dr_low vector
too. Did you look into that?
Meanwhile, this is already much better than what we have today.
Thus, this is OK.
Thanks,
Pedro Alves wrote:
> On 06/17/2014 03:12 PM, Gary Benson wrote:
> > This commit moves macros required by the soon-to-be-created
> > nat/i386-dregs.c into i386-{nat,low}.h.
>
> To get rid of the remaining '#ifdef GDBSERVER's in the new
> i386-dregs.c, we could make gdbserver use the i386_dr_low
> vector too. Did you look into that?
I'm not 100% sure I know what you mean. The only '#ifdef GDBSERVER's
in i386-dregs.c are the one surrounding the #include files and the
one surrounding debug_printf.
It would be possible to make gdbserver use the i386_dr_low vector and
remove the macros from i386-{nat,low}.h, but you'd have to change the
function signatures in either gdb or gdbserver as the i386_dr_low
"set" functions take an argument (what to set it to) but the functions
in gdbserver don't. I think in gdbserver they all get set at once,
but I have to confess I don't fully understand it yet.
I'll think about this some more.
> Meanwhile, this is already much better than what we have today.
> Thus, this is OK.
Ok, I pushed it.
Thanks,
Gary
On 06/18/2014 12:33 PM, Gary Benson wrote:
> Pedro Alves wrote:
>> On 06/17/2014 03:12 PM, Gary Benson wrote:
>>> This commit moves macros required by the soon-to-be-created
>>> nat/i386-dregs.c into i386-{nat,low}.h.
>>
>> To get rid of the remaining '#ifdef GDBSERVER's in the new
>> i386-dregs.c, we could make gdbserver use the i386_dr_low
>> vector too. Did you look into that?
>
> I'm not 100% sure I know what you mean. The only '#ifdef GDBSERVER's
> in i386-dregs.c are the one surrounding the #include files and the
> one surrounding debug_printf.
Yes, that one. The ideal end state builds the exact same code in
gdb and gdbserver.
>
> It would be possible to make gdbserver use the i386_dr_low vector and
> remove the macros from i386-{nat,low}.h, but you'd have to change the
> function signatures in either gdb or gdbserver as the i386_dr_low
> "set" functions take an argument (what to set it to) but the functions
> in gdbserver don't. I think in gdbserver they all get set at once,
> but I have to confess I don't fully understand it yet.
Normalizing this is fine, and actually desirable. Reducing divergence
is what we're really after.
> I'll think about this some more.
Thanks.
@@ -32,13 +32,6 @@
The functions below implement debug registers sharing by reference
counts, and allow to watch regions up to 16 bytes long. */
-#define i386_dr_low_can_set_addr() 1
-#define i386_dr_low_can_set_control() 1
-
-/* Debug register size, in bytes. */
-/* NOTE: sizeof (long) == 4 on win64. */
-#define i386_get_debug_register_length() (sizeof (void *))
-
/* Support for 8-byte wide hw watchpoints. */
#define TARGET_HAS_DR_LEN_8 (i386_get_debug_register_length () == 8)
@@ -38,6 +38,9 @@ extern void i386_low_init_dregs (struct i386_debug_reg_state *state);
status (DR6) register.
*/
+/* Can we update the inferior's debug registers? */
+#define i386_dr_low_can_set_addr() 1
+
/* Update the inferior's debug register REGNUM from STATE. */
extern void i386_dr_low_set_addr (const struct i386_debug_reg_state *state,
int regnum);
@@ -45,6 +48,9 @@ extern void i386_dr_low_set_addr (const struct i386_debug_reg_state *state,
/* Return the inferior's debug register REGNUM. */
extern CORE_ADDR i386_dr_low_get_addr (int regnum);
+/* Can we update the inferior's DR7 control register? */
+#define i386_dr_low_can_set_control() 1
+
/* Update the inferior's DR7 debug control register from STATE. */
extern void i386_dr_low_set_control (const struct i386_debug_reg_state *state);
@@ -53,3 +59,7 @@ extern unsigned i386_dr_low_get_control (void);
/* Return the value of the inferior's DR6 debug status register. */
extern unsigned i386_dr_low_get_status (void);
+
+/* Return the debug register size, in bytes. */
+/* Note that sizeof (long) == 4 on win64. */
+#define i386_get_debug_register_length() (sizeof (void *))
@@ -47,23 +47,6 @@ static int debug_hw_points;
/* Low-level function vector. */
struct i386_dr_low_type i386_dr_low;
-#define i386_dr_low_can_set_addr() (i386_dr_low.set_addr != NULL)
-#define i386_dr_low_can_set_control() (i386_dr_low.set_control != NULL)
-
-#define i386_dr_low_set_addr(new_state, i) \
- (i386_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))
-
-#define i386_dr_low_set_control(new_state) \
- (i386_dr_low.set_control ((new_state)->dr_control_mirror))
-
-#define i386_dr_low_get_addr(i) (i386_dr_low.get_addr ((i)))
-#define i386_dr_low_get_status() (i386_dr_low.get_status ())
-#define i386_dr_low_get_control() (i386_dr_low.get_control ())
-
-/* Debug register size, in bytes. */
-#define i386_get_debug_register_length() \
- (i386_dr_low.debug_register_length)
-
/* Support for 8-byte wide hw watchpoints. */
#define TARGET_HAS_DR_LEN_8 (i386_get_debug_register_length () == 8)
@@ -73,6 +73,33 @@ struct i386_dr_low_type
extern struct i386_dr_low_type i386_dr_low;
+/* Can we update the inferior's debug registers? */
+#define i386_dr_low_can_set_addr() (i386_dr_low.set_addr != NULL)
+
+/* Update the inferior's debug register REGNUM from STATE. */
+#define i386_dr_low_set_addr(new_state, i) \
+ (i386_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))
+
+/* Return the inferior's debug register REGNUM. */
+#define i386_dr_low_get_addr(i) (i386_dr_low.get_addr ((i)))
+
+/* Can we update the inferior's DR7 control register? */
+#define i386_dr_low_can_set_control() (i386_dr_low.set_control != NULL)
+
+/* Update the inferior's DR7 debug control register from STATE. */
+#define i386_dr_low_set_control(new_state) \
+ (i386_dr_low.set_control ((new_state)->dr_control_mirror))
+
+/* Return the value of the inferior's DR7 debug control register. */
+#define i386_dr_low_get_control() (i386_dr_low.get_control ())
+
+/* Return the value of the inferior's DR6 debug status register. */
+#define i386_dr_low_get_status() (i386_dr_low.get_status ())
+
+/* Return the debug register size, in bytes. */
+#define i386_get_debug_register_length() \
+ (i386_dr_low.debug_register_length)
+
/* Use this function to set i386_dr_low debug_register_length field
rather than setting it directly to check that the length is only
set once. It also enables the 'maint set/show show-debug-regs'