[all-commits] [llvm/llvm-project] 5f7f8a: [lldb][Linux] Fix false watchpoint stop on single-...
LiRvs-Miria via All-commits
all-commits at lists.llvm.org
Wed Sep 30 05:31:13 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5f7f8aec603b0f1144052c179352d3379fc8e424
https://github.com/llvm/llvm-project/commit/5f7f8aec603b0f1144052c179352d3379fc8e424
Author: LiRvs-Miria <1753531985 at qq.com>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
M lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
M lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg.cpp
Log Message:
-----------
[lldb][Linux] Fix false watchpoint stop on single-step when hw debug regset read fails (#226880)
On aarch64 Linux, the kernel reports instruction single-step exceptions
as SIGTRAP/TRAP_HWBKPT. NativeProcessLinux::MonitorSIGTRAP handles
si_code 0, TRAP_TRACE and TRAP_HWBKPT in the same case, so every
instruction-level stop goes through GetWatchpointHitIndex().
NativeRegisterContextLinux_arm64::GetWatchpointHitIndex() reads the
hardware debug registers via PTRACE_GETREGSET(NT_ARM_HW_WATCH /
NT_ARM_HW_BREAK). On kernels where those regsets are unavailable, the
read fails with EINVAL and GetWatchpointHitIndex() returns an error
without assigning `wp_index`. NativeProcessLinux declares `wp_index`
uninitialized, logs the error, and then still tests it.
Observed behavior on Cortex-A35, OpenWrt, PREEMPT_RT 6.1.82-rt27:
- lldb-dap next/stepOver advances a single instruction (PC + 4)
- the stopped event reports description "watchpoint -1", reason
"breakpoint"
Fix in two places, following the contract that `GetWatchpointHitIndex()`
must always assign `wp_index` (`LLDB_INVALID_INDEX32` when there is no
hit or on error), as the base class default and the other
implementations already do:
- `NativeRegisterContextDBReg::GetWatchpointHitIndex()` assigns
`LLDB_INVALID_INDEX32` before any early return, so the error path leaves
a defined value. This also stops the entry `LLDB_LOG` from reading an
uninitialized `wp_index`.
- `NativeProcessLinux::MonitorSIGTRAP` checks `error.Success()` before
testing the `wp_index`/`bp_index` out-params, so an out-param is never
read after a failed call.
With these changes, when the hardware debug register read fails,
execution falls through to normal trace-stop handling; genuine
watchpoint hits behave exactly as before. On kernels without the
hw-debug regsets, hardware watchpoints/breakpoints are unavailable
anyway; software breakpoints (BRK) and single-stepping are unaffected.
AI tool usage: I used an AI assistant to help analyze the root cause and
draft this PR description. The code change and testing were done by me.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list