aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorYao Qi <yao.qi@linaro.org>2015-07-17 14:32:40 +0100
committerYao Qi <yao.qi@linaro.org>2015-07-17 14:32:40 +0100
commitc67ca4de63fb3018a7e21ec4afe709d4c0dd52c4 (patch)
treebad99de03f148179148431f5a1bcc6282df33cf3 /gdb
parent25abf97969e50190cb5532b25b8e1deef3ab3bde (diff)
downloadgdb-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')
-rw-r--r--gdb/ChangeLog16
-rw-r--r--gdb/aarch64-linux-nat.c56
-rw-r--r--gdb/gdbserver/ChangeLog10
-rw-r--r--gdb/gdbserver/linux-aarch64-low.c43
4 files changed, 72 insertions, 53 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 987db38..b1f9586 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,21 @@
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
debug_printf.
(aarch64_handle_unaligned_watchpoint): Likewise.
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);
}
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index e46d2f8..72a0e79 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,15 @@
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
debug_printf.
(aarch64_handle_unaligned_watchpoint): Likewise.
diff --git a/gdb/gdbserver/linux-aarch64-low.c b/gdb/gdbserver/linux-aarch64-low.c
index 8a50546..28dae5c 100644
--- a/gdb/gdbserver/linux-aarch64-low.c
+++ b/gdb/gdbserver/linux-aarch64-low.c
@@ -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 (),