Skip to content

Commit d31e3c5

Browse files
committed
Don't hide frame of entry point into libc++
1 parent d0cf329 commit d31e3c5

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,22 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
7979
if (!sc.function)
8080
return {};
8181

82+
// Check if we have a regex match
83+
bool matches_regex = false;
8284
for (RegularExpression &r : m_hidden_regex)
83-
if (r.Execute(sc.function->GetNameNoArguments()))
85+
if (r.Execute(sc.function->GetNameNoArguments())) {
86+
matches_regex = true;
87+
break;
88+
}
89+
90+
if (matches_regex) {
91+
// Only hide this frame if the immediate caller is also within libc++.
92+
lldb::StackFrameSP parent_frame = frame_sp->GetThread()->GetStackFrameAtIndex(frame_sp->GetFrameIndex() + 1);
93+
const auto& parent_sc = parent_frame->GetSymbolContext(lldb::eSymbolContextFunction);
94+
if (parent_sc.function->GetNameNoArguments().GetStringRef().starts_with("std::")) {
8495
return m_hidden_frame;
96+
}
97+
}
8598

8699
return {};
87100
}

lldb/test/API/lang/cpp/libcxx-internals-recognizer/TestLibcxxInternalsRecognizer.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def test_frame_recognizer(self):
1717

1818
expected_parents = {
1919
"sort_less(int, int)": ["::sort", "test_algorithms"],
20-
# `std::ranges::sort` is implemented as an object of types `__sort`,
21-
# which unfortunately means that there is no `std::ranges::sort`
22-
# stack frame, and `main` is the direct parent of `my_less_ranges`.
23-
"ranges_sort_less(int, int)": ["test_algorithms"],
20+
# `std::ranges::sort` is implemented as an object of types `__sort`.
21+
# We never hide the frame of the entry-point into the standard library, even
22+
# if the name starts with `__` which usually indicates an internal function.
23+
"ranges_sort_less(int, int)": ["ranges::__sort::operator()", "test_algorithms"],
2424
# `ranges::views::transform` internally uses `std::invoke`, and that
2525
# call also shows up in the stack trace
2626
"view_transform(int)": ["::invoke", "ranges::transform_view", "test_algorithms"],

0 commit comments

Comments
 (0)