-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[lldb] Add frame recognizers for libc++ std::invoke
#105695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
e90463e
6947b13
e384eb9
51eb02e
44059b8
17302d3
3763051
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
//===----------------------------------------------------------------------===// | ||
|
||
#include <cstring> | ||
#include <iostream> | ||
|
||
#include <memory> | ||
|
||
|
@@ -44,7 +45,7 @@ char CPPLanguageRuntime::ID = 0; | |
/// A frame recognizer that is installed to hide libc++ implementation | ||
/// details from the backtrace. | ||
class LibCXXFrameRecognizer : public StackFrameRecognizer { | ||
RegularExpression m_hidden_function_regex; | ||
std::array<RegularExpression, 4> m_hidden_regex; | ||
RecognizedStackFrameSP m_hidden_frame; | ||
|
||
struct LibCXXHiddenFrame : public RecognizedStackFrame { | ||
|
@@ -53,10 +54,39 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer { | |
|
||
public: | ||
LibCXXFrameRecognizer() | ||
: m_hidden_function_regex( | ||
R"(^std::__.*::(__function.*::operator\(\)|__invoke))" | ||
R"((\[.*\])?)" // ABI tag. | ||
R"(( const)?$)"), // const. | ||
: m_hidden_regex{ | ||
// internal implementation details of std::function | ||
vogelsgesang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// std::__1::__function::__alloc_func<void (*)(), std::__1::allocator<void (*)()>, void ()>::operator()[abi:ne200000] | ||
// std::__1::__function::__func<void (*)(), std::__1::allocator<void (*)()>, void ()>::operator() | ||
// std::__1::__function::__value_func<void ()>::operator()[abi:ne200000]() const | ||
RegularExpression{"" | ||
R"(^std::__[^:]*::)" // Namespace. | ||
R"(__function::.*::operator\(\))" | ||
R"((\[.*\])?)" // ABI tag. | ||
R"(( const)?$)"}, // const. | ||
vogelsgesang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// internal implementation details of std::function in ABI v2 | ||
// std::__2::__function::__policy_invoker<void (int, int)>::__call_impl[abi:ne200000]<std::__2::__function::__default_alloc_func<int (*)(int, int), int (int, int)>> | ||
RegularExpression{"" | ||
R"(^std::__[^:]*::)" // Namespace. | ||
R"(__function::.*::__call_impl)" | ||
R"((\[.*\])?)" // ABI tag. | ||
R"(<.*>)"}, // template argument. | ||
// internal implementation details of std::invoke | ||
// std::__1::__invoke[abi:ne200000]<void (*&)()> | ||
RegularExpression{ | ||
R"(^std::__[^:]*::)" // Namespace. | ||
R"(__invoke)" | ||
|
||
R"((\[.*\])?)" // ABI tag. | ||
R"(<.*>)"}, // template argument. | ||
// internal implementation details of std::invoke | ||
// std::__1::__invoke_void_return_wrapper<void, true>::__call[abi:ne200000]<void (*&)()> | ||
RegularExpression{ | ||
R"(^std::__[^:]*::)" // Namespace. | ||
R"(__invoke_void_return_wrapper<.*>::__call)" | ||
R"((\[.*\])?)" // ABI tag. | ||
R"(<.*>)"} // template argument. | ||
|
||
}, | ||
m_hidden_frame(new LibCXXHiddenFrame()) {} | ||
|
||
std::string GetName() override { return "libc++ frame recognizer"; } | ||
|
@@ -69,8 +99,9 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer { | |
if (!sc.function) | ||
return {}; | ||
|
||
if (m_hidden_function_regex.Execute(sc.function->GetNameNoArguments())) | ||
return m_hidden_frame; | ||
for (RegularExpression &r : m_hidden_regex) | ||
if (r.Execute(sc.function->GetNameNoArguments())) | ||
return m_hidden_frame; | ||
|
||
return {}; | ||
} | ||
|
@@ -81,8 +112,9 @@ CPPLanguageRuntime::CPPLanguageRuntime(Process *process) | |
if (process) | ||
process->GetTarget().GetFrameRecognizerManager().AddRecognizer( | ||
StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {}, | ||
std::make_shared<RegularExpression>("^std::__.*::"), | ||
/*first_instruction_only*/ false); | ||
std::make_shared<RegularExpression>("^std::__[^:]*::"), | ||
/*mangling_preference=*/Mangled::ePreferDemangledWithoutArguments, | ||
/*first_instruction_only=*/false); | ||
} | ||
|
||
bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) { | ||
|
@@ -108,8 +140,7 @@ bool contains_lambda_identifier(llvm::StringRef &str_ref) { | |
|
||
CPPLanguageRuntime::LibCppStdFunctionCallableInfo | ||
line_entry_helper(Target &target, const SymbolContext &sc, Symbol *symbol, | ||
llvm::StringRef first_template_param_sref, | ||
bool has_invoke) { | ||
llvm::StringRef first_template_param_sref, bool has_invoke) { | ||
|
||
CPPLanguageRuntime::LibCppStdFunctionCallableInfo optional_info; | ||
|
||
|
@@ -190,7 +221,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo( | |
ValueObjectSP sub_member_f_(member_f_->GetChildMemberWithName("__f_")); | ||
|
||
if (sub_member_f_) | ||
member_f_ = sub_member_f_; | ||
member_f_ = sub_member_f_; | ||
} | ||
|
||
if (!member_f_) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can just push this as an NFC separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have direct push-access and piggy-backing it in this PR is less effort for me