Issue 175499
Summary [lldb] Hardware execution breakpoints not implemented on x86/x64 Linux
Labels new issue
Assignees
Reporter xusheng6
    Hardware execution breakpoints (`breakpoint set -H`) always fail on x86/x64 Linux because `NativeRegisterContextDBReg_x86` only implements watchpoints, not breakpoints.

Note: I am a bit surprised that it is not supported and there is no open issue for it. Hopefully it is not my skill issues

## Reproduction

```
$ lldb ./helloworld
(lldb) b main
(lldb) r
(lldb) breakpoint set -a 0x555555555183 -H
warning: failed to set breakpoint site at 0x555555555183 for breakpoint 2.1: error: 9 sending the hardware breakpoint request
```

This happens even with no other hardware breakpoints set.

## Root Cause

[`NativeRegisterContextDBReg_x86`](https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_x86.h#L16-L50) only implements watchpoint methods. It does not override `SetHardwareBreakpoint()` or `NumSupportedHardwareBreakpoints()`.

The call falls through to the [base class default](https://github.com/llvm/llvm-project/blob/main/lldb/source/Host/common/NativeRegisterContext.cpp#L241-L246) which returns failure:

```cpp
uint32_t NativeRegisterContext::NumSupportedHardwareBreakpoints() { return 0; }

uint32_t NativeRegisterContext::SetHardwareBreakpoint(lldb::addr_t addr, size_t size) {
  return LLDB_INVALID_INDEX32;
}
```

In contrast, [`NativeRegisterContextDBReg`](https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg.h#L28-L37) (used by ARM64/LoongArch) implements both breakpoints and watchpoints, and works correctly.

## Suggested Fix

Add hardware breakpoint support to `NativeRegisterContextDBReg_x86`, similar to the existing watchpoint implementation but using DR7 type bits `00` (execution) instead of `01`/`11` (data write/access).

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to