xref: /llvm-project/lldb/test/API/functionalities/step-avoids-regexp/TestStepAvoidsRegexp.py (revision 9c2468821ec51defd09c246fea4a47886fff8c01)
1a4561d93SMichael Buch"""
2a4561d93SMichael BuchTest thread step-in ignores frames according to the "Avoid regexp" option.
3a4561d93SMichael Buch"""
4a4561d93SMichael Buch
5a4561d93SMichael Buchimport lldb
6a4561d93SMichael Buchfrom lldbsuite.test.decorators import *
7a4561d93SMichael Buchfrom lldbsuite.test.lldbtest import *
8a4561d93SMichael Buchfrom lldbsuite.test import lldbutil
9a4561d93SMichael Buch
102238dcc3SJonas Devlieghere
11a4561d93SMichael Buchclass StepAvoidsRegexTestCase(TestBase):
12a4561d93SMichael Buch    def hit_correct_function(self, pattern):
13a4561d93SMichael Buch        name = self.thread.frames[0].GetFunctionName()
14*9c246882SJordan Rupprecht        self.assertIn(
15*9c246882SJordan Rupprecht            pattern,
16*9c246882SJordan Rupprecht            name,
172238dcc3SJonas Devlieghere            "Got to '%s' not the expected function '%s'." % (name, pattern),
182238dcc3SJonas Devlieghere        )
19a4561d93SMichael Buch
20a4561d93SMichael Buch    def setUp(self):
21a4561d93SMichael Buch        TestBase.setUp(self)
22a4561d93SMichael Buch        self.dbg.HandleCommand(
232238dcc3SJonas Devlieghere            "settings set target.process.thread.step-avoid-regexp ^ignore::"
242238dcc3SJonas Devlieghere        )
25a4561d93SMichael Buch
26fd91e8f5SMichael Buch    @skipIfWindows
272238dcc3SJonas Devlieghere    @skipIf(compiler="clang", compiler_version=["<", "11.0"])
28a4561d93SMichael Buch    def test_step_avoid_regex(self):
29a4561d93SMichael Buch        """Tests stepping into a function which matches the avoid regex"""
30a4561d93SMichael Buch        self.build()
312238dcc3SJonas Devlieghere        (_, _, self.thread, _) = lldbutil.run_to_source_breakpoint(
322238dcc3SJonas Devlieghere            self, "main", lldb.SBFileSpec("main.cpp")
332238dcc3SJonas Devlieghere        )
34a4561d93SMichael Buch
35a4561d93SMichael Buch        # Try to step into ignore::auto_ret
36a4561d93SMichael Buch        self.thread.StepInto()
37a4561d93SMichael Buch        self.hit_correct_function("main")
38a4561d93SMichael Buch
39a4561d93SMichael Buch        # Try to step into ignore::with_tag
40a4561d93SMichael Buch        self.thread.StepInto()
41a4561d93SMichael Buch        self.hit_correct_function("main")
42a4561d93SMichael Buch
43a4561d93SMichael Buch        # Try to step into ignore::decltype_auto_ret
44a4561d93SMichael Buch        self.thread.StepInto()
45a4561d93SMichael Buch        self.hit_correct_function("main")
46a4561d93SMichael Buch
47a4561d93SMichael Buch        # Try to step into ignore::with_tag_template
48a4561d93SMichael Buch        self.thread.StepInto()
49a4561d93SMichael Buch        self.hit_correct_function("main")
503cc98845SMichael Buch
513cc98845SMichael Buch        # Step into with_tag_template_returns_ignore which is outside the 'ignore::'
523cc98845SMichael Buch        # namespace but returns a type from 'ignore::'
533cc98845SMichael Buch        self.thread.StepInto()
543cc98845SMichael Buch        self.hit_correct_function("with_tag_template_returns_ignore")
55