21#include "llvm/Support/FormatVariadic.h"
31 std::string stop_desc,
65 auto obj_or_err =
m_interface_sp->CreatePluginObject(scripted_metadata);
71 llvm::formatv(
"failed to create ScriptedStackFrameRecognizer: {0}",
72 llvm::toString(obj_or_err.takeError()))
85 auto args_synthesized = std::make_shared<ValueObjectList>();
87 for (
const auto &o : args->GetObjects())
99 if (frame->GetConcreteFrameIndex() == 0)
100 step_through_sp =
m_interface_sp->GetStepThroughPlan(frame->GetThread());
103 args_synthesized, hidden, std::move(most_relevant), std::move(exception),
104 std::move(stop_desc), std::move(step_through_sp)));
109 n = (n + 1) & ((1 << 16) - 1);
115 llvm::ArrayRef<ConstString> symbols,
120 first_instruction_only,
true});
127 bool first_instruction_only) {
130 symbol, symbol_mangling, first_instruction_only,
136 const std::function<
void(
137 uint32_t,
bool, std::string, std::string, llvm::ArrayRef<ConstString>,
140 if (entry.is_regexp) {
141 std::string module_name;
142 std::string symbol_name;
144 if (entry.module_regexp)
145 module_name = entry.module_regexp->GetText().str();
146 if (entry.symbol_regexp)
147 symbol_name = entry.symbol_regexp->GetText().str();
149 callback(entry.recognizer_id, entry.enabled, entry.recognizer->GetName(),
150 module_name, llvm::ArrayRef(
ConstString(symbol_name)),
151 entry.symbol_mangling,
true);
153 callback(entry.recognizer_id, entry.enabled, entry.recognizer->GetName(),
154 entry.module.GetCString(), entry.symbols, entry.symbol_mangling,
168 found->enabled = enabled;
174 uint32_t recognizer_id) {
194 eSymbolContextModule | eSymbolContextFunction | eSymbolContextSymbol);
198 llvm::StringRef module_name = module_sp->GetFileSpec().GetFilename();
206 Address current_addr = frame->GetFrameCodeAddress();
211 if (
TargetSP target_sp = frame->CalculateTarget())
212 if (
Architecture *arch = target_sp->GetArchitecturePlugin())
213 start_addr = arch->SkipFunctionHeader(start_addr);
220 if (entry.module != module_name)
223 if (entry.module_regexp)
224 if (!entry.module_regexp->Execute(module_name))
229 if (!entry.symbols.empty())
230 if (!llvm::is_contained(entry.symbols, function_name))
233 if (entry.symbol_regexp)
234 if (!entry.symbol_regexp->Execute(function_name.
GetStringRef()))
237 if (entry.first_instruction_only)
238 if (start_addr != current_addr)
241 return entry.recognizer;
251 return recognizer->RecognizeFrame(frame);
lldb::StackFrameSP GetMostRelevantFrame() override
lldb::StackFrameSP m_most_relevant_frame
lldb::ValueObjectSP GetExceptionObject() override
lldb::ThreadPlanSP m_thread_plan_sp
ScriptedRecognizedStackFrame(ValueObjectListSP args, bool hidden, lldb::StackFrameSP most_relevant_frame, lldb::ValueObjectSP exception, std::string stop_desc, lldb::ThreadPlanSP step_through_plan_sp)
bool ShouldHide() override
Controls whether this frame should be filtered out when displaying backtraces, for example.
lldb::ValueObjectSP m_exception
lldb::ThreadPlanSP GetStepThroughPlan() override
A section + offset based address class.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
const Address & GetAddress() const
Return the address of the function (its entry point).
This class provides extra information about a stack frame that was provided by a specific stack frame...
lldb::ValueObjectListSP m_arguments
virtual lldb::ScriptedStackFrameRecognizerInterfaceSP CreateScriptedStackFrameRecognizerInterface()
Debugger & GetDebugger()
Get the debugger associated with this script interpreter.
ScriptedStackFrameRecognizer(lldb_private::ScriptInterpreter *interpreter, const char *pclass)
lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame) override
lldb::ScriptedStackFrameRecognizerInterfaceSP m_interface_sp
std::string m_python_class
void BumpGeneration()
Increase the generation counter.
void AddRecognizer(lldb::StackFrameRecognizerSP recognizer, ConstString module, llvm::ArrayRef< ConstString > symbols, Mangled::NamePreference symbol_mangling, bool first_instruction_only=true)
Add a new recognizer that triggers on a given symbol name.
void ForEach(std::function< void(uint32_t recognizer_id, bool enabled, std::string recognizer_name, std::string module, llvm::ArrayRef< ConstString > symbols, Mangled::NamePreference name_preference, bool regexp)> const &callback)
lldb::StackFrameRecognizerSP GetRecognizerForFrame(lldb::StackFrameSP frame)
lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame)
bool RemoveRecognizerWithID(uint32_t recognizer_id)
void RemoveAllRecognizers()
bool SetEnabledForID(uint32_t recognizer_id, bool enabled)
std::deque< RegisteredEntry > m_recognizers
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
lldb::ModuleSP module_sp
The Module for a given query.
Symbol * symbol
The Symbol for a given query.
Address GetAddress() const
static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type)
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ThreadPlan > ThreadPlanSP
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::RegularExpression > RegularExpressionSP
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
@ eValueTypeVariableArgument
function argument variables
std::shared_ptr< lldb_private::StackFrameRecognizer > StackFrameRecognizerSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
lldb::user_id_t GetID() const
Get accessor for the user ID.