aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Target/StackFrameRecognizer.cpp
diff options
context:
space:
mode:
authorAdrian Vogelsgesang <avogelsgesang@salesforce.com>2024-08-27 19:15:42 +0200
committerGitHub <noreply@github.com>2024-08-27 19:15:42 +0200
commitdd060bdede8edec18ad5ca122e15cc24a821e3fe (patch)
treeab6091e6c0c8781a992e8237d6d7e90131bdef0f /lldb/source/Target/StackFrameRecognizer.cpp
parent4baf29e81e30e6ebc1da56b9e5c338014961acf9 (diff)
downloadllvm-dd060bdede8edec18ad5ca122e15cc24a821e3fe.zip
llvm-dd060bdede8edec18ad5ca122e15cc24a821e3fe.tar.gz
llvm-dd060bdede8edec18ad5ca122e15cc24a821e3fe.tar.bz2
[lldb] Add frame recognizers for libc++ `std::invoke` (#105695)
With this commit, we also hide the implementation details of `std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more regular expressions. The regular expression passed into `AddRecognizer` became problematic, as it was evaluated on the demangled name. Those names also included result types for C++ symbols. For `std::__invoke` the return type is a huge `decltype(...)`, making the regular expresison really hard to write. Instead, I added support to `AddRecognizer` for matching on the demangled names without result type and argument types. By hiding the implementation details of `invoke`, also the back traces for `std::function` become even nicer, because `std::function` is using `__invoke` internally. Co-authored-by: Adrian Prantl <aprantl@apple.com>
Diffstat (limited to 'lldb/source/Target/StackFrameRecognizer.cpp')
-rw-r--r--lldb/source/Target/StackFrameRecognizer.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/lldb/source/Target/StackFrameRecognizer.cpp b/lldb/source/Target/StackFrameRecognizer.cpp
index 44411af..fa24253 100644
--- a/lldb/source/Target/StackFrameRecognizer.cpp
+++ b/lldb/source/Target/StackFrameRecognizer.cpp
@@ -62,25 +62,29 @@ void StackFrameRecognizerManager::BumpGeneration() {
void StackFrameRecognizerManager::AddRecognizer(
StackFrameRecognizerSP recognizer, ConstString module,
- llvm::ArrayRef<ConstString> symbols, bool first_instruction_only) {
+ llvm::ArrayRef<ConstString> symbols,
+ Mangled::NamePreference symbol_mangling, bool first_instruction_only) {
m_recognizers.push_front({(uint32_t)m_recognizers.size(), recognizer, false,
module, RegularExpressionSP(), symbols,
- RegularExpressionSP(), first_instruction_only});
+ RegularExpressionSP(), symbol_mangling,
+ first_instruction_only});
BumpGeneration();
}
void StackFrameRecognizerManager::AddRecognizer(
StackFrameRecognizerSP recognizer, RegularExpressionSP module,
- RegularExpressionSP symbol, bool first_instruction_only) {
+ RegularExpressionSP symbol, Mangled::NamePreference symbol_mangling,
+ bool first_instruction_only) {
m_recognizers.push_front({(uint32_t)m_recognizers.size(), recognizer, true,
ConstString(), module, std::vector<ConstString>(),
- symbol, first_instruction_only});
+ symbol, symbol_mangling, first_instruction_only});
BumpGeneration();
}
void StackFrameRecognizerManager::ForEach(
- const std::function<void(uint32_t, std::string, std::string,
- llvm::ArrayRef<ConstString>, bool)> &callback) {
+ const std::function<
+ void(uint32_t, std::string, std::string, llvm::ArrayRef<ConstString>,
+ Mangled::NamePreference name_reference, bool)> &callback) {
for (auto entry : m_recognizers) {
if (entry.is_regexp) {
std::string module_name;
@@ -92,11 +96,13 @@ void StackFrameRecognizerManager::ForEach(
symbol_name = entry.symbol_regexp->GetText().str();
callback(entry.recognizer_id, entry.recognizer->GetName(), module_name,
- llvm::ArrayRef(ConstString(symbol_name)), true);
+ llvm::ArrayRef(ConstString(symbol_name)), entry.symbol_mangling,
+ true);
} else {
callback(entry.recognizer_id, entry.recognizer->GetName(),
- entry.module.GetCString(), entry.symbols, false);
+ entry.module.GetCString(), entry.symbols, entry.symbol_mangling,
+ false);
}
}
}
@@ -125,7 +131,6 @@ StackFrameRecognizerSP
StackFrameRecognizerManager::GetRecognizerForFrame(StackFrameSP frame) {
const SymbolContext &symctx = frame->GetSymbolContext(
eSymbolContextModule | eSymbolContextFunction | eSymbolContextSymbol);
- ConstString function_name = symctx.GetFunctionName();
ModuleSP module_sp = symctx.module_sp;
if (!module_sp)
return StackFrameRecognizerSP();
@@ -145,6 +150,8 @@ StackFrameRecognizerManager::GetRecognizerForFrame(StackFrameSP frame) {
if (!entry.module_regexp->Execute(module_name.GetStringRef()))
continue;
+ ConstString function_name = symctx.GetFunctionName(entry.symbol_mangling);
+
if (!entry.symbols.empty())
if (!llvm::is_contained(entry.symbols, function_name))
continue;