aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorHui Li <lihui@loongson.cn>2025-01-06 18:21:22 +0800
committerTiezhu Yang <yangtiezhu@loongson.cn>2025-01-15 21:31:10 +0800
commit493975edcb722a548344893114615c6f1c194502 (patch)
tree67bdbf4e4910cec2a5661f71d50d7c3f43f250d5 /gdb
parentf6f845bb3533fe145285526a09ef4a03dc9fd8b6 (diff)
downloadgdb-493975edcb722a548344893114615c6f1c194502.zip
gdb-493975edcb722a548344893114615c6f1c194502.tar.gz
gdb-493975edcb722a548344893114615c6f1c194502.tar.bz2
gdb: LoongArch: Adjust loongarch_stopped_data_address()
loongarch_stopped_data_address() is a common function and will be used by gdb and gdbserver, so move its definition from gdb/loongarch-linux-nat.c to gdb/nat/loongarch-hw-point.c. This is preparation for later gdbserver patch on LoongArch and is no effect for the current code. Signed-off-by: Hui Li <lihui@loongson.cn> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'gdb')
-rw-r--r--gdb/loongarch-linux-nat.c27
-rw-r--r--gdb/nat/loongarch-hw-point.c24
-rw-r--r--gdb/nat/loongarch-hw-point.h8
3 files changed, 32 insertions, 27 deletions
diff --git a/gdb/loongarch-linux-nat.c b/gdb/loongarch-linux-nat.c
index 0735992..bef88ca 100644
--- a/gdb/loongarch-linux-nat.c
+++ b/gdb/loongarch-linux-nat.c
@@ -470,33 +470,6 @@ fill_fpregset (const struct regcache *regcache, gdb_fpregset_t *fpregset,
sizeof (gdb_fpregset_t));
}
-/* Helper for the "stopped_data_address" target method. Returns TRUE
- if a hardware watchpoint trap at ADDR_TRAP matches a set watchpoint.
- The address of the matched watchpoint is returned in *ADDR_P. */
-
-static bool
-loongarch_stopped_data_address (const struct loongarch_debug_reg_state *state,
- CORE_ADDR addr_trap, CORE_ADDR *addr_p)
-{
-
- int i;
-
- for (i = loongarch_num_wp_regs - 1; i >= 0; --i)
- {
- const CORE_ADDR addr_watch = state->dr_addr_wp[i];
-
- if (state->dr_ref_count_wp[i]
- && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
- && addr_trap == addr_watch)
- {
- *addr_p = addr_watch;
- return true;
- }
- }
- return false;
-}
-
-
/* Returns the number of hardware watchpoints of type TYPE that we can
set. Value is positive if we can set CNT watchpoints, zero if
setting watchpoints of type TYPE is not supported, and negative if
diff --git a/gdb/nat/loongarch-hw-point.c b/gdb/nat/loongarch-hw-point.c
index cf5ddb6..7306d4c 100644
--- a/gdb/nat/loongarch-hw-point.c
+++ b/gdb/nat/loongarch-hw-point.c
@@ -317,3 +317,27 @@ loongarch_region_ok_for_watchpoint (CORE_ADDR addr, int len)
return 1;
}
+
+/* See nat/loongarch-hw-point.h*/
+
+bool
+loongarch_stopped_data_address (const struct loongarch_debug_reg_state *state,
+ CORE_ADDR addr_trap, CORE_ADDR *addr_p)
+{
+ int i;
+
+ for (i = loongarch_num_wp_regs - 1; i >= 0; --i)
+ {
+ const CORE_ADDR addr_watch = state->dr_addr_wp[i];
+
+ if (state->dr_ref_count_wp[i]
+ && DR_CONTROL_ENABLED (state->dr_ctrl_wp[i])
+ && addr_trap == addr_watch)
+ {
+ *addr_p = addr_watch;
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/gdb/nat/loongarch-hw-point.h b/gdb/nat/loongarch-hw-point.h
index 799df89..3098752 100644
--- a/gdb/nat/loongarch-hw-point.h
+++ b/gdb/nat/loongarch-hw-point.h
@@ -100,4 +100,12 @@ void loongarch_show_debug_reg_state (struct loongarch_debug_reg_state *state,
int loongarch_region_ok_for_watchpoint (CORE_ADDR addr, int len);
+/* Helper for the "stopped_data_address/low_stopped_data_address" target
+ method. Returns TRUE if a hardware watchpoint trap at ADDR_TRAP matches
+ a set watchpoint. The address of the matched watchpoint is returned in
+ *ADDR_P. */
+
+bool loongarch_stopped_data_address (const struct loongarch_debug_reg_state *state,
+ CORE_ADDR addr_trap, CORE_ADDR *addr_p);
+
#endif /* GDB_NAT_LOONGARCH_HW_POINT_H */