xref: /llvm-project/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py (revision 9c2468821ec51defd09c246fea4a47886fff8c01)
1"""
2Test thread step-in ignores frames according to the "Avoid regexp" option.
3"""
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test import lldbutil
9
10
11class StepAvoidsRegexTestCase(TestBase):
12    def hit_correct_function(self, pattern):
13        name = self.thread.frames[0].GetFunctionName()
14        self.assertIn(
15            pattern,
16            name,
17            "Got to '%s' not the expected function '%s'." % (name, pattern),
18        )
19
20    def setUp(self):
21        TestBase.setUp(self)
22        self.dbg.HandleCommand(
23            "settings set target.process.thread.step-avoid-regexp ^ignore::"
24        )
25
26    @skipIfWindows
27    @skipIf(compiler="clang", compiler_version=["<", "11.0"])
28    def test_step_avoid_regex(self):
29        """Tests stepping into a function which matches the avoid regex"""
30        self.build()
31        (_, _, self.thread, _) = lldbutil.run_to_source_breakpoint(
32            self, "main", lldb.SBFileSpec("main.cpp")
33        )
34
35        # Try to step into ignore::auto_ret
36        self.thread.StepInto()
37        self.hit_correct_function("main")
38
39        # Try to step into ignore::with_tag
40        self.thread.StepInto()
41        self.hit_correct_function("main")
42
43        # Try to step into ignore::decltype_auto_ret
44        self.thread.StepInto()
45        self.hit_correct_function("main")
46
47        # Try to step into ignore::with_tag_template
48        self.thread.StepInto()
49        self.hit_correct_function("main")
50
51        # Step into with_tag_template_returns_ignore which is outside the 'ignore::'
52        # namespace but returns a type from 'ignore::'
53        self.thread.StepInto()
54        self.hit_correct_function("with_tag_template_returns_ignore")
55