================
@@ -109,6 +109,73 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
}
};
+/// A frame recognizer that hides MSVC STL implementation details from the
+/// backtrace. MSVC STL reserves identifiers beginning with an underscore
+/// followed by an uppercase letter (e.g. `_Func_class`) for implementation
+/// details, so frames whose function name starts with `std::_` followed by an
+/// uppercase letter are hidden when called from within `std::`.
+class MSVCSTLFrameRecognizer : public StackFrameRecognizer {
+ RegularExpression m_hidden_regex;
+ RecognizedStackFrameSP m_hidden_frame;
+
+ struct MSVCSTLHiddenFrame : public RecognizedStackFrame {
+ bool ShouldHide() override { return true; }
+ };
+
+ // The MSVC demangler emits demangled names that include the return type
+ // (e.g. `void std::_Func_impl_no_alloc<...>::_Do_call`). Detect whether a
+ // function name belongs to the `std::` namespace, accounting for that
+ // optional return-type prefix.
+ static bool IsInStdNamespace(llvm::StringRef name) {
+ return name.starts_with("std::") || name.contains(" std::");
+ }
+
+public:
+ MSVCSTLFrameRecognizer()
+ // Examples of MSVC STL internals that should be hidden:
+ // void std::_Func_impl_no_alloc<`lambda...',void>::_Do_call
+ // void std::_Func_class<void>::operator()
+ // std::_Invoker_ret<std::_Unforced,1>::_Call<...>
+ // The regex is intentionally not anchored: the MSVC demangler may
+ // prepend a return type before the qualified name.
+ : m_hidden_regex(R"(std::_[A-Z])"),
----------------
Nerixyz wrote:
>From a brief look:
This might match too much. There are STL types with `_Ugly` names that you
might pass around. Iterators come to mind here. For example, the
`std::string_view` iterator is named `std::_String_view_iterator`. What if you
use this in a template?
I think we should first make sure that the demangler only returns the function
name without the return type. I'm not fully sure if that's always possible
(because we don't always have a mangled name).
https://github.com/llvm/llvm-project/pull/196336
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits