2 from lldbsuite
.test
.decorators
import *
3 from lldbsuite
.test
.lldbtest
import *
4 from lldbsuite
.test
import lldbutil
8 class LibCxxInternalsRecognizerTestCase(TestBase
):
9 NO_DEBUG_INFO_TESTCASE
= True
11 @add_test_categories(["libc++"])
12 @skipIf(compiler
="clang", compiler_version
=["<", "16.0"])
13 def test_frame_recognizer(self
):
14 """Test that implementation details of libc++ are hidden"""
16 (target
, process
, thread
, bkpt
) = lldbutil
.run_to_source_breakpoint(
17 self
, "break here", lldb
.SBFileSpec("main.cpp")
21 "sort_less(int, int)": ["::sort", "test_algorithms"],
22 # `std::ranges::sort` is implemented as an object of types `__sort`.
23 # We never hide the frame of the entry-point into the standard library, even
24 # if the name starts with `__` which usually indicates an internal function.
25 "ranges_sort_less(int, int)": [
26 re
.compile("ranges::__sort::(__fn::)?operator\(\)"),
29 # `ranges::views::transform` internally uses `std::invoke`, and that
30 # call also shows up in the stack trace
31 "view_transform(int)": [
33 "ranges::transform_view",
36 # Various types of `invoke` calls
37 "consume_number(int)": ["::invoke", "test_invoke"],
38 "invoke_add(int, int)": ["::invoke", "test_invoke"],
39 "Callable::member_function(int) const": ["::invoke", "test_invoke"],
40 "Callable::operator()(int) const": ["::invoke", "test_invoke"],
42 "MyKey::operator<(MyKey const&) const": [
49 while process
.GetState() != lldb
.eStateExited
:
50 fn
= thread
.GetFrameAtIndex(0).GetFunctionName()
52 self
.assertIn(fn
, expected_parents
.keys())
54 for expected_parent
in expected_parents
[fn
]:
55 # Skip all hidden frames
57 frame_id
< thread
.GetNumFrames()
58 and thread
.GetFrameAtIndex(frame_id
).IsHidden()
60 frame_id
= frame_id
+ 1
61 # Expect the correct parent frame
62 func_name
= thread
.GetFrameAtIndex(frame_id
).GetFunctionName()
63 if isinstance(expected_parent
, re
.Pattern
):
65 expected_parent
.search(func_name
) is not None,
66 f
"'{expected_parent}' not found in '{func_name}'"
69 self
.assertIn(expected_parent
, func_name
)
70 frame_id
= frame_id
+ 1
73 # Make sure that we actually verified all intended scenarios
74 self
.assertEqual(len(stop_set
), len(expected_parents
))