diff options
Diffstat (limited to 'lldb/source/Target/StackFrameRecognizer.cpp')
-rw-r--r-- | lldb/source/Target/StackFrameRecognizer.cpp | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/lldb/source/Target/StackFrameRecognizer.cpp b/lldb/source/Target/StackFrameRecognizer.cpp index 75a6cd215126c..7dc6e9d1e490a 100644 --- a/lldb/source/Target/StackFrameRecognizer.cpp +++ b/lldb/source/Target/StackFrameRecognizer.cpp @@ -1,4 +1,4 @@ -//===-- StackFrameRecognizer.cpp --------------------------------*- C++ -*-===// +//===-- StackFrameRecognizer.cpp ------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -50,31 +50,42 @@ ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) { class StackFrameRecognizerManagerImpl { public: - void AddRecognizer(StackFrameRecognizerSP recognizer, - ConstString module, ConstString symbol, + void AddRecognizer(StackFrameRecognizerSP recognizer, ConstString module, + llvm::ArrayRef<ConstString> symbols, bool first_instruction_only) { - m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, false, module, RegularExpressionSP(), - symbol, RegularExpressionSP(), - first_instruction_only}); + m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, + false, module, RegularExpressionSP(), symbols, + RegularExpressionSP(), first_instruction_only}); } void AddRecognizer(StackFrameRecognizerSP recognizer, RegularExpressionSP module, RegularExpressionSP symbol, bool first_instruction_only) { - m_recognizers.push_front({(uint32_t)m_recognizers.size(), false, recognizer, true, ConstString(), module, - ConstString(), symbol, first_instruction_only}); + m_recognizers.push_front( + {(uint32_t)m_recognizers.size(), false, recognizer, true, ConstString(), + module, std::vector<ConstString>(), symbol, first_instruction_only}); } - void ForEach( - std::function<void(uint32_t recognized_id, std::string recognizer_name, std::string module, - std::string symbol, bool regexp)> const &callback) { + void ForEach(std::function< + void(uint32_t recognized_id, std::string recognizer_name, + std::string module, llvm::ArrayRef<ConstString> symbols, + bool regexp)> const &callback) { for (auto entry : m_recognizers) { if (entry.is_regexp) { - callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module_regexp->GetText(), - entry.symbol_regexp->GetText(), true); + std::string module_name; + std::string symbol_name; + + if (entry.module_regexp) + module_name = entry.module_regexp->GetText().str(); + if (entry.symbol_regexp) + symbol_name = entry.symbol_regexp->GetText().str(); + + callback(entry.recognizer_id, entry.recognizer->GetName(), module_name, + llvm::makeArrayRef(ConstString(symbol_name)), true); + } else { - callback(entry.recognizer_id, entry.recognizer->GetName(), entry.module.GetCString(), - entry.symbol.GetCString(), false); + callback(entry.recognizer_id, entry.recognizer->GetName(), + entry.module.GetCString(), entry.symbols, false); } } } @@ -91,8 +102,8 @@ public: } StackFrameRecognizerSP GetRecognizerForFrame(StackFrameSP frame) { - const SymbolContext &symctx = - frame->GetSymbolContext(eSymbolContextModule | eSymbolContextFunction); + const SymbolContext &symctx = frame->GetSymbolContext( + eSymbolContextModule | eSymbolContextFunction | eSymbolContextSymbol); ConstString function_name = symctx.GetFunctionName(); ModuleSP module_sp = symctx.module_sp; if (!module_sp) return StackFrameRecognizerSP(); @@ -110,8 +121,9 @@ public: if (entry.module_regexp) if (!entry.module_regexp->Execute(module_name.GetStringRef())) continue; - if (entry.symbol) - if (entry.symbol != function_name) continue; + if (!entry.symbols.empty()) + if (!llvm::is_contained(entry.symbols, function_name)) + continue; if (entry.symbol_regexp) if (!entry.symbol_regexp->Execute(function_name.GetStringRef())) @@ -139,7 +151,7 @@ public: bool is_regexp; ConstString module; RegularExpressionSP module_regexp; - ConstString symbol; + std::vector<ConstString> symbols; RegularExpressionSP symbol_regexp; bool first_instruction_only; }; @@ -155,9 +167,9 @@ StackFrameRecognizerManagerImpl &GetStackFrameRecognizerManagerImpl() { void StackFrameRecognizerManager::AddRecognizer( StackFrameRecognizerSP recognizer, ConstString module, - ConstString symbol, bool first_instruction_only) { - GetStackFrameRecognizerManagerImpl().AddRecognizer(recognizer, module, symbol, - first_instruction_only); + llvm::ArrayRef<ConstString> symbols, bool first_instruction_only) { + GetStackFrameRecognizerManagerImpl().AddRecognizer( + recognizer, module, symbols, first_instruction_only); } void StackFrameRecognizerManager::AddRecognizer( @@ -168,8 +180,9 @@ void StackFrameRecognizerManager::AddRecognizer( } void StackFrameRecognizerManager::ForEach( - std::function<void(uint32_t recognized_id, std::string recognizer_name, std::string module, - std::string symbol, bool regexp)> const &callback) { + std::function<void(uint32_t recognized_id, std::string recognizer_name, + std::string module, llvm::ArrayRef<ConstString> symbols, + bool regexp)> const &callback) { GetStackFrameRecognizerManagerImpl().ForEach(callback); } |