aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/API
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2025-07-03 11:17:19 -0700
committerGitHub <noreply@github.com>2025-07-03 11:17:19 -0700
commit378f248934d603e3fba9d958d2db997814d057d5 (patch)
treed528925e5138678456f77176f845a12f7696ddc4 /lldb/source/API
parent1e76f012db3ccfaa05e238812e572b5b6d12c17e (diff)
downloadllvm-378f248934d603e3fba9d958d2db997814d057d5.zip
llvm-378f248934d603e3fba9d958d2db997814d057d5.tar.gz
llvm-378f248934d603e3fba9d958d2db997814d057d5.tar.bz2
[lldb] Add SB API to make a breakpoint a hardware breakpoint (#146602)
This adds SBBreakpoint::SetIsHardware, allowing clients to mark an existing breakpoint as a hardware breakpoint purely through the API. This is safe to do after creation, as the hardware/software distinction doesn't affect how breakpoint locations are selected. In some cases (e.g. when writing a trap instruction would alter program behavior), it's important to use hardware breakpoints. Ideally, we’d extend the various `Create` methods to support this, but given their number, this patch limits the scope to the post-creation API. As a workaround, users can also rely on target.require-hardware-breakpoint or use the `breakpoint set` command. rdar://153528045
Diffstat (limited to 'lldb/source/API')
-rw-r--r--lldb/source/API/SBBreakpoint.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index 87fadbc..397afc1 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -781,6 +781,18 @@ bool SBBreakpoint::IsHardware() const {
return false;
}
+lldb::SBError SBBreakpoint::SetIsHardware(bool is_hardware) {
+ LLDB_INSTRUMENT_VA(this, is_hardware);
+
+ BreakpointSP bkpt_sp = GetSP();
+ if (bkpt_sp) {
+ std::lock_guard<std::recursive_mutex> guard(
+ bkpt_sp->GetTarget().GetAPIMutex());
+ return SBError(Status::FromError(bkpt_sp->SetIsHardware(is_hardware)));
+ }
+ return SBError();
+}
+
BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); }
// This is simple collection of breakpoint id's and their target.