13#include "clang/CodeGen/ModuleBuilder.h"
25 const size_t max_stack_depth = 128;
32 while (most_relevant_frame_sp && stack_idx <= max_stack_depth) {
34 most_relevant_frame_sp->GetSymbolContext(eSymbolContextEverything);
43 return most_relevant_frame_sp;
53 StackFrameSP most_relevant_frame_sp, std::string stop_desc)
54 : m_most_relevant_frame(most_relevant_frame_sp) {
60 if (frame_sp->GetFrameIndex())
63 ThreadSP thread_sp = frame_sp->GetThread();
64 ProcessSP process_sp = thread_sp->GetProcess();
68 if (!most_relevant_frame_sp) {
72 "Failed to find most relevant frame: Hit unwinding bound (1 frame)!");
76 SymbolContext sc = frame_sp->GetSymbolContext(eSymbolContextEverything);
95 if (func_name.empty())
98 static auto trap_regex =
99 llvm::Regex(llvm::formatv(
"^{0}\\$(.*)\\$(.*)$", ClangTrapPrefix).str());
100 SmallVector<llvm::StringRef, 3> matches;
101 std::string regex_err_msg;
102 if (!trap_regex.match(func_name, &matches, ®ex_err_msg)) {
104 "Failed to parse match trap regex for '%s': %s", func_name.data(),
105 regex_err_msg.c_str());
114 if (matches.size() != 3) {
116 "Unexpected function name format. Expected '<trap prefix>$<trap "
117 "category>$<trap message>'$ but got: '%s'.",
123 auto category = matches[1];
124 auto message = matches[2];
126 std::string stop_reason =
127 category.empty() ?
"<empty category>" : category.str();
128 if (!message.empty()) {
130 stop_reason += message.str();
133 return std::make_shared<VerboseTrapRecognizedStackFrame>(
134 most_relevant_frame_sp, std::move(stop_reason));
145 auto symbol_regex_sp = std::make_shared<RegularExpression>(
146 llvm::formatv(
"^{0}", ClangTrapPrefix).str());
149 std::make_shared<VerboseTrapFrameRecognizer>();
152 srf_recognizer_sp, module_regex_sp, symbol_regex_sp,
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
static StackFrameSP FindMostRelevantFrame(Thread &selected_thread)
The 0th frame is the artificial inline frame generated to store the verbose_trap message.
A class that describes a single lexical block.
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
A class that describes information for an inlined function.
ConstString GetName() const
A plug-in interface definition class for debugging a process.
Target & GetTarget()
Get the target object pointer for this module.
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.
Defines a symbol context baton that can be handed other debug core functions.
Block * block
The Block for a given query.
StackFrameRecognizerManager & GetFrameRecognizerManager()
virtual lldb::StackFrameSP GetStackFrameAtIndex(uint32_t idx)
lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame) override
lldb::StackFrameSP GetMostRelevantFrame() override
lldb::StackFrameSP m_most_relevant_frame
VerboseTrapRecognizedStackFrame(lldb::StackFrameSP most_relevant_frame_sp, std::string stop_desc)
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
void RegisterVerboseTrapFrameRecognizer(Process &process)
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::RegularExpression > RegularExpressionSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::StackFrameRecognizer > StackFrameRecognizerSP