diff options
| author | jimingham <jingham@apple.com> | 2025-10-09 08:37:21 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-09 08:37:21 -0700 |
| commit | 36bce68b97316363085ae3681e8dde33a62fc9b1 (patch) | |
| tree | a7d732cc45aae98d91fc8747efd27c655ea5c423 /lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp | |
| parent | c4f36758b73fbf651650d8b650347e0ac172795f (diff) | |
Add a scripted way to re-present a stop location (#158128)
This patch adds the notion of "Facade" locations which can be reported
from a ScriptedResolver instead of the actual underlying breakpoint
location for the breakpoint. Also add a "was_hit" method to the scripted
resolver that allows the breakpoint to say which of these "Facade"
locations was hit, and "get_location_description" to provide a
description for the facade locations.
I apologize in advance for the size of the patch. Almost all of what's
here was necessary to (a) make the feature testable and (b) not break
any of the current behavior.
The motivation for this feature is given in the "Providing Facade
Locations" section that I added to the python-reference.rst so I won't
repeat it here.
rdar://152112327
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp')
| -rw-r--r-- | lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp index 660edaa0191f..c9bb38d213c9 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp @@ -81,6 +81,32 @@ std::optional<std::string> ScriptedBreakpointPythonInterface::GetShortHelp() { return obj->GetAsString()->GetValue().str(); } +lldb::BreakpointLocationSP ScriptedBreakpointPythonInterface::WasHit( + lldb::StackFrameSP frame_sp, lldb::BreakpointLocationSP bp_loc_sp) { + Status py_error; + lldb::BreakpointLocationSP loc_sp = Dispatch<lldb::BreakpointLocationSP>( + "was_hit", py_error, frame_sp, bp_loc_sp); + + if (py_error.Fail()) + return bp_loc_sp; + + return loc_sp; +} + +std::optional<std::string> +ScriptedBreakpointPythonInterface::GetLocationDescription( + lldb::BreakpointLocationSP bp_loc_sp, lldb::DescriptionLevel level) { + Status error; + StructuredData::ObjectSP obj = + Dispatch("get_location_description", error, bp_loc_sp, level); + + if (!ScriptedInterface::CheckStructuredDataObject(LLVM_PRETTY_FUNCTION, obj, + error)) + return {}; + + return obj->GetAsString()->GetValue().str(); +} + void ScriptedBreakpointPythonInterface::Initialize() { const std::vector<llvm::StringRef> ci_usages = { "breakpoint set -P classname [-k key -v value ...]"}; |
