Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / python_api / compile_unit / TestCompileUnitAPI.py
bloba12955adb7ce3806ecc9e3437e6b030cd1bdced4
1 """
2 Test SBCompileUnit APIs.
3 """
5 import lldb
6 from lldbsuite.test.decorators import *
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test import lldbutil
11 class CompileUnitAPITestCase(TestBase):
12 def test(self):
13 """Exercise some SBCompileUnit APIs."""
14 self.build()
16 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
17 self, "break here", lldb.SBFileSpec("main.c")
19 self.assertTrue(target, VALID_TARGET)
20 self.assertTrue(process, PROCESS_IS_VALID)
21 self.assertTrue(bkpt and bkpt.GetNumLocations() == 1, VALID_BREAKPOINT)
23 self.assertTrue(
24 thread.IsValid(),
25 "There should be a thread stopped due to breakpoint condition",
27 frame0 = thread.GetFrameAtIndex(0)
28 line_entry = frame0.GetLineEntry()
30 sc_list = target.FindCompileUnits(line_entry.GetFileSpec())
31 self.assertGreater(sc_list.GetSize(), 0)
33 main_cu = sc_list.compile_units[0]
34 self.assertTrue(main_cu.IsValid(), "Main executable CU is not valid")
36 self.assertEqual(
37 main_cu.FindLineEntryIndex(line_entry, True),
38 main_cu.FindLineEntryIndex(
39 0, line_entry.GetLine(), line_entry.GetFileSpec(), True