[Lldb-commits] [lldb] [LLDB][LoongArch] Fix build errors and extend watchpoint numbers (PR #126020)

via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 5 23:40:57 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: None (seehearfeel)

<details>
<summary>Changes</summary>

1. [LLDB][LoongArch] Fix build errors about NT_LOONGARCH_HW_{BREAK,WATCH}
2. [LLDB][LoongArch] Extend the maximum number of watchpoints

---
Full diff: https://github.com/llvm/llvm-project/pull/126020.diff


1 Files Affected:

- (modified) lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp (+22-2) 


``````````diff
diff --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp
index b04018ee243fd7d..8eb2cb65c76d2ea 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp
@@ -36,9 +36,29 @@
   0xa03 /* LoongArch Advanced SIMD eXtension registers */
 #endif
 
+#ifndef NT_LOONGARCH_HW_BREAK
+#define NT_LOONGARCH_HW_BREAK	0xa05   /* LoongArch hardware breakpoint registers */
+#endif
+
+#ifndef NT_LOONGARCH_HW_WATCH
+#define NT_LOONGARCH_HW_WATCH	0xa06   /* LoongArch hardware watchpoint registers */
+#endif
+
 #define REG_CONTEXT_SIZE                                                       \
   (GetGPRSize() + GetFPRSize() + sizeof(m_lsx) + sizeof(m_lasx))
 
+#ifndef user_watch_state_v2
+struct user_watch_state_v2 {
+	uint64_t dbg_info;
+	struct {
+		uint64_t    addr;
+		uint64_t    mask;
+		uint32_t    ctrl;
+		uint32_t    pad;
+	} dbg_regs[14];
+};
+#endif
+
 using namespace lldb;
 using namespace lldb_private;
 using namespace lldb_private::process_linux;
@@ -528,7 +548,7 @@ llvm::Error NativeRegisterContextLinux_loongarch64::ReadHardwareDebugInfo() {
 
   int regset = NT_LOONGARCH_HW_WATCH;
   struct iovec ioVec;
-  struct user_watch_state dreg_state;
+  struct user_watch_state_v2 dreg_state;
   Status error;
 
   ioVec.iov_base = &dreg_state;
@@ -556,7 +576,7 @@ llvm::Error NativeRegisterContextLinux_loongarch64::ReadHardwareDebugInfo() {
 llvm::Error NativeRegisterContextLinux_loongarch64::WriteHardwareDebugRegs(
     DREGType hwbType) {
   struct iovec ioVec;
-  struct user_watch_state dreg_state;
+  struct user_watch_state_v2 dreg_state;
   int regset;
 
   memset(&dreg_state, 0, sizeof(dreg_state));

``````````

</details>


https://github.com/llvm/llvm-project/pull/126020


More information about the lldb-commits mailing list