xref: /llvm-project/lldb/test/API/lang/cpp/limit-debug-info/TestWithLimitDebugInfo.py (revision 9677e8171c19f1a15c0234724f083bc9473c545a)
199451b44SJordan Rupprechtimport lldb
299451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
399451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
499451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
599451b44SJordan Rupprecht
699451b44SJordan Rupprecht
799451b44SJordan Rupprechtclass TestWithLimitDebugInfo(TestBase):
8*9677e817SPavel Labath    def _run_test(self, build_dict):
9*9677e817SPavel Labath        self.build(dictionary=build_dict)
1099451b44SJordan Rupprecht
1199451b44SJordan Rupprecht        # Get the path of the executable
1299451b44SJordan Rupprecht        exe_path = self.getBuildArtifact("a.out")
1399451b44SJordan Rupprecht
1499451b44SJordan Rupprecht        # Load the executable
1599451b44SJordan Rupprecht        target = self.dbg.CreateTarget(exe_path)
1699451b44SJordan Rupprecht        self.assertTrue(target.IsValid(), VALID_TARGET)
1799451b44SJordan Rupprecht
1899451b44SJordan Rupprecht        # Break on main function
19*9677e817SPavel Labath        lldbutil.run_break_set_by_file_and_line(
20*9677e817SPavel Labath            self, "derived.h", line_number("derived.h", "// break1")
21*9677e817SPavel Labath        )
22*9677e817SPavel Labath        lldbutil.run_break_set_by_file_and_line(
23*9677e817SPavel Labath            self, "derived.h", line_number("derived.h", "// break2")
242238dcc3SJonas Devlieghere        )
2599451b44SJordan Rupprecht
2699451b44SJordan Rupprecht        # Launch the process
272238dcc3SJonas Devlieghere        process = target.LaunchSimple(None, None, self.get_process_working_directory())
2899451b44SJordan Rupprecht        self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
2999451b44SJordan Rupprecht
3099451b44SJordan Rupprecht        # Get the thread of the process
312238dcc3SJonas Devlieghere        self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
3299451b44SJordan Rupprecht
3399451b44SJordan Rupprecht        self.expect_expr("1", result_type="int", result_value="1")
34*9677e817SPavel Labath        self.expect_expr("this", result_type="Foo *")
35*9677e817SPavel Labath        self.expect_expr("this->x", result_type="int", result_value="12345")
3699451b44SJordan Rupprecht
37*9677e817SPavel Labath        self.runCmd("continue")
38*9677e817SPavel Labath
39*9677e817SPavel Labath        self.expect_expr("1", result_type="int", result_value="1")
40*9677e817SPavel Labath        self.expect_expr("this", result_type="ns::Foo2 *")
41*9677e817SPavel Labath        self.expect_expr("this->x", result_type="int", result_value="23456")
42*9677e817SPavel Labath
43*9677e817SPavel Labath    @add_test_categories(["dwarf", "dwo"])
44*9677e817SPavel Labath    def test_default(self):
45*9677e817SPavel Labath        self._run_test(dict(CFLAGS_EXTRAS="$(LIMIT_DEBUG_INFO_FLAGS)"))
46*9677e817SPavel Labath
47*9677e817SPavel Labath    @add_test_categories(["dwarf", "dwo"])
48*9677e817SPavel Labath    def test_debug_names(self):
49*9677e817SPavel Labath        self._run_test(
50*9677e817SPavel Labath            dict(CFLAGS_EXTRAS="$(LIMIT_DEBUG_INFO_FLAGS) -gdwarf-5 -gpubnames")
51*9677e817SPavel Labath        )
52