Skip to content

Commit 85460c1

Browse files
committed
gdb: convert nat/x86-dregs.c macros to functions
I'm debugging why GDB crashes on OpenBSD/amd64, turns out it's because x86_dr_low.get_status is nullptr. It would have been useful to be able to break on x86_dr_low_get_status, so I thought it would be a good reason to convert these function-like macros into functions. Change-Id: Ic200b50ef8455b4697bc518da0fa2bb704cf4721
1 parent 04dd800 commit 85460c1

File tree

1 file changed

+48
-11
lines changed

1 file changed

+48
-11
lines changed

gdb/nat/x86-dregs.c

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,68 @@
3535
/* Accessor macros for low-level function vector. */
3636

3737
/* Can we update the inferior's debug registers? */
38-
#define x86_dr_low_can_set_addr() (x86_dr_low.set_addr != NULL)
38+
39+
static bool
40+
x86_dr_low_can_set_addr ()
41+
{
42+
return x86_dr_low.set_addr != nullptr;
43+
}
3944

4045
/* Update the inferior's debug register REGNUM from STATE. */
41-
#define x86_dr_low_set_addr(new_state, i) \
42-
(x86_dr_low.set_addr ((i), (new_state)->dr_mirror[(i)]))
46+
47+
static void
48+
x86_dr_low_set_addr (struct x86_debug_reg_state *new_state, int i)
49+
{
50+
x86_dr_low.set_addr (i, new_state->dr_mirror[i]);
51+
}
4352

4453
/* Return the inferior's debug register REGNUM. */
45-
#define x86_dr_low_get_addr(i) (x86_dr_low.get_addr ((i)))
54+
55+
static unsigned long
56+
x86_dr_low_get_addr (int i)
57+
{
58+
return x86_dr_low.get_addr (i);
59+
}
4660

4761
/* Can we update the inferior's DR7 control register? */
48-
#define x86_dr_low_can_set_control() (x86_dr_low.set_control != NULL)
62+
63+
static bool
64+
x86_dr_low_can_set_control ()
65+
{
66+
return x86_dr_low.set_control != nullptr;
67+
}
4968

5069
/* Update the inferior's DR7 debug control register from STATE. */
51-
#define x86_dr_low_set_control(new_state) \
52-
(x86_dr_low.set_control ((new_state)->dr_control_mirror))
70+
71+
static void
72+
x86_dr_low_set_control (struct x86_debug_reg_state *new_state)
73+
{
74+
x86_dr_low.set_control (new_state->dr_control_mirror);
75+
}
5376

5477
/* Return the value of the inferior's DR7 debug control register. */
55-
#define x86_dr_low_get_control() (x86_dr_low.get_control ())
78+
79+
static unsigned long
80+
x86_dr_low_get_control ()
81+
{
82+
return x86_dr_low.get_control ();
83+
}
5684

5785
/* Return the value of the inferior's DR6 debug status register. */
58-
#define x86_dr_low_get_status() (x86_dr_low.get_status ())
86+
87+
static unsigned long
88+
x86_dr_low_get_status ()
89+
{
90+
return x86_dr_low.get_status ();
91+
}
5992

6093
/* Return the debug register size, in bytes. */
61-
#define x86_get_debug_register_length() \
62-
(x86_dr_low.debug_register_length)
94+
95+
static int
96+
x86_get_debug_register_length ()
97+
{
98+
return x86_dr_low.debug_register_length;
99+
}
63100

64101
/* Support for 8-byte wide hw watchpoints. */
65102
#define TARGET_HAS_DR_LEN_8 (x86_get_debug_register_length () == 8)

0 commit comments

Comments
 (0)