diff options
author | Yao Qi <yao.qi@linaro.org> | 2015-07-17 14:32:40 +0100 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2015-07-17 14:32:40 +0100 |
commit | c67ca4de63fb3018a7e21ec4afe709d4c0dd52c4 (patch) | |
tree | bad99de03f148179148431f5a1bcc6282df33cf3 /gdb/aarch64-linux-nat.c | |
parent | 25abf97969e50190cb5532b25b8e1deef3ab3bde (diff) | |
download | gdb-c67ca4de63fb3018a7e21ec4afe709d4c0dd52c4.zip gdb-c67ca4de63fb3018a7e21ec4afe709d4c0dd52c4.tar.gz gdb-c67ca4de63fb3018a7e21ec4afe709d4c0dd52c4.tar.bz2 |
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.
Diffstat (limited to 'gdb/aarch64-linux-nat.c')
-rw-r--r-- | gdb/aarch64-linux-nat.c | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c index 7dc0a6e..9a14ed8 100644 --- a/gdb/aarch64-linux-nat.c +++ b/gdb/aarch64-linux-nat.c @@ -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); } |