From 36bce68b97316363085ae3681e8dde33a62fc9b1 Mon Sep 17 00:00:00 2001 From: jimingham Date: Thu, 9 Oct 2025 08:37:21 -0700 Subject: 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 --- .../ScriptedBreakpointPythonInterface.cpp | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedBreakpointPythonInterface.cpp') 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 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( + "was_hit", py_error, frame_sp, bp_loc_sp); + + if (py_error.Fail()) + return bp_loc_sp; + + return loc_sp; +} + +std::optional +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 ci_usages = { "breakpoint set -P classname [-k key -v value ...]"}; -- cgit v1.2.3