[Lldb-commits] [lldb] [lldb] Fix false watchpoint stop on single-step when hw debug regset read fails (PR #226880)

via lldb-commits lldb-commits at lists.llvm.org
Sun Sep 27 21:16:51 PDT 2026


https://github.com/LiRvs-Miria updated https://github.com/llvm/llvm-project/pull/226880

>From 594545d3642bde9a9d365182360654ae709ecb2a Mon Sep 17 00:00:00 2001
From: LiRvs-Miria <1753531985 at qq.com>
Date: Mon, 28 Sep 2026 11:58:55 +0800
Subject: [PATCH] [lldb] Fix false watchpoint stop on single-step when hw debug
 regset read fails

On aarch64 single-step is reported as TRAP_HWBKPT, so every step enters
the watchpoint query path. If GetWatchpointHitIndex() fails without
setting wp_index (e.g. NT_ARM_HW_WATCH unavailable), the uninitialized
value makes NativeProcessLinux report a bogus watchpoint hit.

Initialize wp_index to LLDB_INVALID_INDEX32 so the failure falls
through to normal trace-stop handling.
---
 lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index fd7c2557a1fc0..d31044b9da908 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -759,7 +759,10 @@ void NativeProcessLinux::MonitorSIGTRAP(const siginfo_t &info,
   case TRAP_HWBKPT: // We receive this on watchpoint hit
   {
     // If a watchpoint was hit, report it
-    uint32_t wp_index;
+    // GetWatchpointHitIndex() may fail without setting wp_index, e.g. when
+    // the hardware debug regset is unavailable. Initialize it so the failure
+    // path falls through instead of reporting a bogus watchpoint hit
+    uint32_t wp_index = LLDB_INVALID_INDEX32;
     Status error = thread.GetRegisterContext().GetWatchpointHitIndex(
         wp_index, (uintptr_t)info.si_addr);
     if (error.Fail())



More information about the lldb-commits mailing list