]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: LoongArch: Adjust loongarch_stopped_data_address()
authorHui Li <lihui@loongson.cn>
Mon, 6 Jan 2025 10:21:22 +0000 (18:21 +0800)
committerTiezhu Yang <yangtiezhu@loongson.cn>
Wed, 15 Jan 2025 13:31:10 +0000 (21:31 +0800)
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>
gdb/loongarch-linux-nat.c
gdb/nat/loongarch-hw-point.c
gdb/nat/loongarch-hw-point.h

index 07359924b0e2db8b1cee2a85993bf526b29ce32e..bef88ca06320d3aba19a913a9902191599135c36 100644 (file)
@@ -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
index cf5ddb68d783eeae0ea16947bd530ea98b4415b7..7306d4c71c10107bccc7e9355a235e09c47fa3f6 100644 (file)
@@ -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;
+}
index 799df89b428d0b5365c0f64570db7ac1cf7ad143..3098752043a1756ac818c6d5ed83f55285e5d8f1 100644 (file)
@@ -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 */