[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / python_api / symbol-context / two-files / TestSymbolContextTwoFiles.py
blob0d3209b355e00ffe68d61f579984e729567556bc
1 """
2 Test SBSymbolContext APIs.
3 """
6 import lldb
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 class SymbolContextTwoFilesTestCase(TestBase):
13 @expectedFailureAll(oslist=["windows"])
14 def test_lookup_by_address(self):
15 """Test lookup by address in a module with multiple compilation units"""
16 self.build()
17 exe = self.getBuildArtifact("a.out")
18 target = self.dbg.CreateTarget(exe)
19 self.assertTrue(target, VALID_TARGET)
21 module = target.GetModuleAtIndex(0)
22 self.assertTrue(module.IsValid())
23 for symbol_name in ["struct1::f()", "struct2::f()"]:
24 sc_list = module.FindFunctions(symbol_name, lldb.eSymbolTypeCode)
25 self.assertTrue(1, sc_list.GetSize())
26 symbol_address = sc_list.GetContextAtIndex(0).GetSymbol().GetStartAddress()
27 self.assertTrue(symbol_address.IsValid())
28 sc_by_address = module.ResolveSymbolContextForAddress(
29 symbol_address, lldb.eSymbolContextFunction
31 self.assertEqual(symbol_name, sc_by_address.GetFunction().GetName())
33 def test_ranges_in_multiple_compile_unit(self):
34 """This test verifies that we correctly handle the case when multiple
35 compile unit contains DW_AT_ranges and DW_AT_ranges_base attributes."""
36 self.build()
37 exe = self.getBuildArtifact("a.out")
38 target = self.dbg.CreateTarget(exe)
39 self.assertTrue(target, VALID_TARGET)
41 source1 = "file1.cpp"
42 line1 = line_number(source1, "// Break1")
43 breakpoint1 = target.BreakpointCreateByLocation(source1, line1)
44 self.assertIsNotNone(breakpoint1)
45 self.assertTrue(breakpoint1.IsValid())
47 source2 = "file2.cpp"
48 line2 = line_number(source2, "// Break2")
49 breakpoint2 = target.BreakpointCreateByLocation(source2, line2)
50 self.assertIsNotNone(breakpoint2)
51 self.assertTrue(breakpoint2.IsValid())
53 process = target.LaunchSimple(None, None, self.get_process_working_directory())
54 self.assertIsNotNone(process, PROCESS_IS_VALID)
56 threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint2)
57 self.assertEqual(len(threads), 1)
58 frame = threads[0].GetFrameAtIndex(0)
59 value = frame.FindVariable("x")
60 self.assertTrue(value.IsValid())
62 process.Continue()
64 threads = lldbutil.get_threads_stopped_at_breakpoint(process, breakpoint1)
65 self.assertEqual(len(threads), 1)
66 frame = threads[0].GetFrameAtIndex(0)
67 value = frame.FindVariable("x")
68 self.assertTrue(value.IsValid())
70 process.Continue()