2 Test SBSymbolContext APIs.
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
13 class SymbolContextTwoFilesTestCase(TestBase):
15 mydir = TestBase.compute_mydir(__file__)
17 @add_test_categories(['pyapi'])
18 @expectedFailureAll(oslist=["windows"])
19 def test_lookup_by_address(self):
20 """Test lookup by address in a module with multiple compilation units"""
22 exe = self.getBuildArtifact("a.out")
23 target = self.dbg.CreateTarget(exe)
24 self.assertTrue(target, VALID_TARGET)
26 module = target.GetModuleAtIndex(0)
27 self.assertTrue(module.IsValid())
28 for symbol_name in ["struct1::f()", "struct2::f()"]:
29 sc_list = module.FindFunctions(symbol_name, lldb.eSymbolTypeCode)
30 self.assertTrue(1, sc_list.GetSize())
31 symbol_address = sc_list.GetContextAtIndex(
32 0).GetSymbol().GetStartAddress()
33 self.assertTrue(symbol_address.IsValid())
34 sc_by_address = module.ResolveSymbolContextForAddress(
35 symbol_address, lldb.eSymbolContextFunction)
36 self.assertEqual(symbol_name,
37 sc_by_address.GetFunction().GetName())
39 @add_test_categories(['pyapi'])
40 def test_ranges_in_multiple_compile_unit(self):
41 """This test verifies that we correctly handle the case when multiple
42 compile unit contains DW_AT_ranges and DW_AT_ranges_base attributes."""
44 exe = self.getBuildArtifact("a.out")
45 target = self.dbg.CreateTarget(exe)
46 self.assertTrue(target, VALID_TARGET)
49 line1 = line_number(source1, '// Break1')
50 breakpoint1 = target.BreakpointCreateByLocation(source1, line1)
51 self.assertIsNotNone(breakpoint1)
52 self.assertTrue(breakpoint1.IsValid())
55 line2 = line_number(source2, '// Break2')
56 breakpoint2 = target.BreakpointCreateByLocation(source2, line2)
57 self.assertIsNotNone(breakpoint2)
58 self.assertTrue(breakpoint2.IsValid())
60 process = target.LaunchSimple(None, None, self.get_process_working_directory())
61 self.assertIsNotNone(process, PROCESS_IS_VALID)
63 threads = lldbutil.get_threads_stopped_at_breakpoint(
65 self.assertEqual(len(threads), 1)
66 frame = threads[0].GetFrameAtIndex(0)
67 value = frame.FindVariable("x")
68 self.assertTrue(value.IsValid())
72 threads = lldbutil.get_threads_stopped_at_breakpoint(
74 self.assertEqual(len(threads), 1)
75 frame = threads[0].GetFrameAtIndex(0)
76 value = frame.FindVariable("x")
77 self.assertTrue(value.IsValid())