Pass aarch64_debug_reg_state to functions
Some functions on handling HW watchpoint in GDB and GDBserver looks the same except the code getting debug register state from current inferior. In GDB, we get debug register state like this: state = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid)); while in GDBserver, we get debug register state like this: state = aarch64_get_debug_reg_state (); This patch is to move two lines above out of some functions, and pass aarch64_debug_reg_state to these functions, in this way, these functions are the same, and can be moved to a common place. gdb: 2015-07-17 Yao Qi <yao.qi@linaro.org> * aarch64-linux-nat.c (aarch64_handle_breakpoint): Add argument state and don't call aarch64_get_debug_reg_state. All callers update. (aarch64_linux_insert_hw_breakpoint): Call aarch64_get_debug_reg_state earlier. (aarch64_linux_remove_hw_breakpoint): Likewise. (aarch64_handle_aligned_watchpoint): Add argument state and don't call aarch64_get_debug_reg_state. All callers update. (aarch64_handle_unaligned_watchpoint): Likewise. (aarch64_handle_watchpoint): Add argument state. (aarch64_linux_insert_watchpoint): Call aarch64_get_debug_reg_state earlier. (aarch64_linux_remove_watchpoint): Likewise. gdb/gdbserver: 2015-07-17 Yao Qi <yao.qi@linaro.org> * linux-aarch64-low.c (aarch64_handle_breakpoint): Add argument state and don't aarch64_get_debug_reg_state. All callers update. (aarch64_handle_aligned_watchpoint): Likewise. (aarch64_handle_unaligned_watchpoint): Likewise. (aarch64_handle_watchpoint): Likewise. (aarch64_insert_point): Call aarch64_get_debug_reg_state earlier. (aarch64_remove_point): Likewise.
This commit is contained in:
parent
25abf97969
commit
c67ca4de63
4 changed files with 72 additions and 53 deletions
|
@ -1,3 +1,19 @@
|
|||
2015-07-17 Yao Qi <yao.qi@linaro.org>
|
||||
|
||||
* aarch64-linux-nat.c (aarch64_handle_breakpoint): Add argument
|
||||
state and don't call aarch64_get_debug_reg_state. All callers
|
||||
update.
|
||||
(aarch64_linux_insert_hw_breakpoint): Call
|
||||
aarch64_get_debug_reg_state earlier.
|
||||
(aarch64_linux_remove_hw_breakpoint): Likewise.
|
||||
(aarch64_handle_aligned_watchpoint): Add argument state and
|
||||
don't call aarch64_get_debug_reg_state. All callers update.
|
||||
(aarch64_handle_unaligned_watchpoint): Likewise.
|
||||
(aarch64_handle_watchpoint): Add argument state.
|
||||
(aarch64_linux_insert_watchpoint): Call aarch64_get_debug_reg_state
|
||||
earlier.
|
||||
(aarch64_linux_remove_watchpoint): Likewise.
|
||||
|
||||
2015-07-17 Yao Qi <yao.qi@linaro.org>
|
||||
|
||||
* aarch64-linux-nat.c (aarch64_show_debug_reg_state): Use
|
||||
|
|
|
@ -1291,17 +1291,14 @@ aarch64_dr_state_remove_one_point (struct aarch64_debug_reg_state *state,
|
|||
|
||||
static int
|
||||
aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
||||
int len, int is_insert)
|
||||
int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state;
|
||||
|
||||
/* The hardware breakpoint on AArch64 should always be 4-byte
|
||||
aligned. */
|
||||
if (!aarch64_point_is_aligned (0 /* is_watchpoint */ , addr, len))
|
||||
return -1;
|
||||
|
||||
state = aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
if (is_insert)
|
||||
return aarch64_dr_state_insert_one_point (state, type, addr, len);
|
||||
else
|
||||
|
@ -1320,6 +1317,8 @@ aarch64_linux_insert_hw_breakpoint (struct target_ops *self,
|
|||
CORE_ADDR addr = bp_tgt->placed_address = bp_tgt->reqstd_address;
|
||||
const int len = 4;
|
||||
const enum target_hw_bp_type type = hw_execute;
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
if (show_debug_regs)
|
||||
fprintf_unfiltered
|
||||
|
@ -1327,13 +1326,10 @@ aarch64_linux_insert_hw_breakpoint (struct target_ops *self,
|
|||
"insert_hw_breakpoint on entry (addr=0x%08lx, len=%d))\n",
|
||||
(unsigned long) addr, len);
|
||||
|
||||
ret = aarch64_handle_breakpoint (type, addr, len, 1 /* is_insert */);
|
||||
ret = aarch64_handle_breakpoint (type, addr, len, 1 /* is_insert */, state);
|
||||
|
||||
if (show_debug_regs)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
aarch64_show_debug_reg_state (state,
|
||||
"insert_hw_breakpoint", addr, len, type);
|
||||
}
|
||||
|
@ -1353,19 +1349,18 @@ aarch64_linux_remove_hw_breakpoint (struct target_ops *self,
|
|||
CORE_ADDR addr = bp_tgt->placed_address;
|
||||
const int len = 4;
|
||||
const enum target_hw_bp_type type = hw_execute;
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
if (show_debug_regs)
|
||||
fprintf_unfiltered
|
||||
(gdb_stdlog, "remove_hw_breakpoint on entry (addr=0x%08lx, len=%d))\n",
|
||||
(unsigned long) addr, len);
|
||||
|
||||
ret = aarch64_handle_breakpoint (type, addr, len, 0 /* is_insert */);
|
||||
ret = aarch64_handle_breakpoint (type, addr, len, 0 /* is_insert */, state);
|
||||
|
||||
if (show_debug_regs)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
aarch64_show_debug_reg_state (state,
|
||||
"remove_hw_watchpoint", addr, len, type);
|
||||
}
|
||||
|
@ -1378,11 +1373,9 @@ aarch64_linux_remove_hw_breakpoint (struct target_ops *self,
|
|||
|
||||
static int
|
||||
aarch64_handle_aligned_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
||||
int len, int is_insert)
|
||||
int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
if (is_insert)
|
||||
return aarch64_dr_state_insert_one_point (state, type, addr, len);
|
||||
else
|
||||
|
@ -1398,11 +1391,9 @@ aarch64_handle_aligned_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
|||
|
||||
static int
|
||||
aarch64_handle_unaligned_watchpoint (int type, CORE_ADDR addr, int len,
|
||||
int is_insert)
|
||||
int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
CORE_ADDR aligned_addr;
|
||||
|
@ -1435,12 +1426,15 @@ aarch64_handle_unaligned_watchpoint (int type, CORE_ADDR addr, int len,
|
|||
/* Implements insertion and removal of a single watchpoint. */
|
||||
|
||||
static int
|
||||
aarch64_handle_watchpoint (int type, CORE_ADDR addr, int len, int is_insert)
|
||||
aarch64_handle_watchpoint (int type, CORE_ADDR addr, int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
if (aarch64_point_is_aligned (1 /* is_watchpoint */ , addr, len))
|
||||
return aarch64_handle_aligned_watchpoint (type, addr, len, is_insert);
|
||||
return aarch64_handle_aligned_watchpoint (type, addr, len, is_insert,
|
||||
state);
|
||||
else
|
||||
return aarch64_handle_unaligned_watchpoint (type, addr, len, is_insert);
|
||||
return aarch64_handle_unaligned_watchpoint (type, addr, len, is_insert,
|
||||
state);
|
||||
}
|
||||
|
||||
/* Implement the "to_insert_watchpoint" target_ops method.
|
||||
|
@ -1455,6 +1449,8 @@ aarch64_linux_insert_watchpoint (struct target_ops *self,
|
|||
struct expression *cond)
|
||||
{
|
||||
int ret;
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
if (show_debug_regs)
|
||||
fprintf_unfiltered (gdb_stdlog,
|
||||
|
@ -1463,13 +1459,10 @@ aarch64_linux_insert_watchpoint (struct target_ops *self,
|
|||
|
||||
gdb_assert (type != hw_execute);
|
||||
|
||||
ret = aarch64_handle_watchpoint (type, addr, len, 1 /* is_insert */);
|
||||
ret = aarch64_handle_watchpoint (type, addr, len, 1 /* is_insert */, state);
|
||||
|
||||
if (show_debug_regs)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
aarch64_show_debug_reg_state (state,
|
||||
"insert_watchpoint", addr, len, type);
|
||||
}
|
||||
|
@ -1488,6 +1481,8 @@ aarch64_linux_remove_watchpoint (struct target_ops *self,
|
|||
struct expression *cond)
|
||||
{
|
||||
int ret;
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
if (show_debug_regs)
|
||||
fprintf_unfiltered (gdb_stdlog,
|
||||
|
@ -1496,13 +1491,10 @@ aarch64_linux_remove_watchpoint (struct target_ops *self,
|
|||
|
||||
gdb_assert (type != hw_execute);
|
||||
|
||||
ret = aarch64_handle_watchpoint (type, addr, len, 0 /* is_insert */);
|
||||
ret = aarch64_handle_watchpoint (type, addr, len, 0 /* is_insert */, state);
|
||||
|
||||
if (show_debug_regs)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state (ptid_get_pid (inferior_ptid));
|
||||
|
||||
aarch64_show_debug_reg_state (state,
|
||||
"remove_watchpoint", addr, len, type);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
2015-07-17 Yao Qi <yao.qi@linaro.org>
|
||||
|
||||
* linux-aarch64-low.c (aarch64_handle_breakpoint): Add argument state
|
||||
and don't aarch64_get_debug_reg_state. All callers update.
|
||||
(aarch64_handle_aligned_watchpoint): Likewise.
|
||||
(aarch64_handle_unaligned_watchpoint): Likewise.
|
||||
(aarch64_handle_watchpoint): Likewise.
|
||||
(aarch64_insert_point): Call aarch64_get_debug_reg_state earlier.
|
||||
(aarch64_remove_point): Likewise.
|
||||
|
||||
2015-07-17 Yao Qi <yao.qi@linaro.org>
|
||||
|
||||
* linux-aarch64-low.c (aarch64_show_debug_reg_state): Use
|
||||
|
|
|
@ -847,17 +847,14 @@ aarch64_dr_state_remove_one_point (struct aarch64_debug_reg_state *state,
|
|||
|
||||
static int
|
||||
aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
||||
int len, int is_insert)
|
||||
int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state;
|
||||
|
||||
/* The hardware breakpoint on AArch64 should always be 4-byte
|
||||
aligned. */
|
||||
if (!aarch64_point_is_aligned (0 /* is_watchpoint */ , addr, len))
|
||||
return -1;
|
||||
|
||||
state = aarch64_get_debug_reg_state ();
|
||||
|
||||
if (is_insert)
|
||||
return aarch64_dr_state_insert_one_point (state, type, addr, len);
|
||||
else
|
||||
|
@ -869,12 +866,9 @@ aarch64_handle_breakpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
|||
|
||||
static int
|
||||
aarch64_handle_aligned_watchpoint (enum target_hw_bp_type type,
|
||||
CORE_ADDR addr, int len, int is_insert)
|
||||
CORE_ADDR addr, int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state;
|
||||
|
||||
state = aarch64_get_debug_reg_state ();
|
||||
|
||||
if (is_insert)
|
||||
return aarch64_dr_state_insert_one_point (state, type, addr, len);
|
||||
else
|
||||
|
@ -890,11 +884,9 @@ aarch64_handle_aligned_watchpoint (enum target_hw_bp_type type,
|
|||
|
||||
static int
|
||||
aarch64_handle_unaligned_watchpoint (enum target_hw_bp_type type,
|
||||
CORE_ADDR addr, int len, int is_insert)
|
||||
CORE_ADDR addr, int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
struct aarch64_debug_reg_state *state
|
||||
= aarch64_get_debug_reg_state ();
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
CORE_ADDR aligned_addr;
|
||||
|
@ -927,12 +919,15 @@ aarch64_handle_unaligned_watchpoint (enum target_hw_bp_type type,
|
|||
|
||||
static int
|
||||
aarch64_handle_watchpoint (enum target_hw_bp_type type, CORE_ADDR addr,
|
||||
int len, int is_insert)
|
||||
int len, int is_insert,
|
||||
struct aarch64_debug_reg_state *state)
|
||||
{
|
||||
if (aarch64_point_is_aligned (1 /* is_watchpoint */ , addr, len))
|
||||
return aarch64_handle_aligned_watchpoint (type, addr, len, is_insert);
|
||||
return aarch64_handle_aligned_watchpoint (type, addr, len, is_insert,
|
||||
state);
|
||||
else
|
||||
return aarch64_handle_unaligned_watchpoint (type, addr, len, is_insert);
|
||||
return aarch64_handle_unaligned_watchpoint (type, addr, len, is_insert,
|
||||
state);
|
||||
}
|
||||
|
||||
/* Implementation of linux_target_ops method "supports_z_point_type". */
|
||||
|
@ -964,6 +959,7 @@ aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|||
{
|
||||
int ret;
|
||||
enum target_hw_bp_type targ_type;
|
||||
struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
|
||||
|
||||
if (show_debug_regs)
|
||||
fprintf (stderr, "insert_point on entry (addr=0x%08lx, len=%d)\n",
|
||||
|
@ -974,10 +970,12 @@ aarch64_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|||
|
||||
if (targ_type != hw_execute)
|
||||
ret =
|
||||
aarch64_handle_watchpoint (targ_type, addr, len, 1 /* is_insert */);
|
||||
aarch64_handle_watchpoint (targ_type, addr, len, 1 /* is_insert */,
|
||||
state);
|
||||
else
|
||||
ret =
|
||||
aarch64_handle_breakpoint (targ_type, addr, len, 1 /* is_insert */);
|
||||
aarch64_handle_breakpoint (targ_type, addr, len, 1 /* is_insert */,
|
||||
state);
|
||||
|
||||
if (show_debug_regs)
|
||||
aarch64_show_debug_reg_state (aarch64_get_debug_reg_state (),
|
||||
|
@ -997,6 +995,7 @@ aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|||
{
|
||||
int ret;
|
||||
enum target_hw_bp_type targ_type;
|
||||
struct aarch64_debug_reg_state *state = aarch64_get_debug_reg_state ();
|
||||
|
||||
if (show_debug_regs)
|
||||
fprintf (stderr, "remove_point on entry (addr=0x%08lx, len=%d)\n",
|
||||
|
@ -1008,10 +1007,12 @@ aarch64_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|||
/* Set up state pointers. */
|
||||
if (targ_type != hw_execute)
|
||||
ret =
|
||||
aarch64_handle_watchpoint (targ_type, addr, len, 0 /* is_insert */);
|
||||
aarch64_handle_watchpoint (targ_type, addr, len, 0 /* is_insert */,
|
||||
state);
|
||||
else
|
||||
ret =
|
||||
aarch64_handle_breakpoint (targ_type, addr, len, 0 /* is_insert */);
|
||||
aarch64_handle_breakpoint (targ_type, addr, len, 0 /* is_insert */,
|
||||
state);
|
||||
|
||||
if (show_debug_regs)
|
||||
aarch64_show_debug_reg_state (aarch64_get_debug_reg_state (),
|
||||
|
|
Loading…
Reference in a new issue