[AMDGPU] Add True16 register classes.
[llvm-project.git] / lldb / test / API / python_api / symbol-context / TestSymbolContext.py
blob4c125779f60bbb691aaed1cf805f0895cbbd122b
1 """
2 Test SBSymbolContext 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 SymbolContextAPITestCase(TestBase):
12 def setUp(self):
13 # Call super's setUp().
14 TestBase.setUp(self)
15 # Find the line number to of function 'c'.
16 self.line = line_number(
17 "main.c", '// Find the line number of function "c" here.'
20 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778")
21 def test(self):
22 """Exercise SBSymbolContext API extensively."""
23 self.build()
24 exe = self.getBuildArtifact("a.out")
26 # Create a target by the debugger.
27 target = self.dbg.CreateTarget(exe)
28 self.assertTrue(target, VALID_TARGET)
30 # Now create a breakpoint on main.c by name 'c'.
31 breakpoint = target.BreakpointCreateByName("c", exe)
32 self.assertTrue(
33 breakpoint and breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT
36 # Now launch the process, and do not stop at entry point.
37 process = target.LaunchSimple(None, None, self.get_process_working_directory())
38 self.assertTrue(process, PROCESS_IS_VALID)
40 # Frame #0 should be on self.line.
41 thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
42 self.assertTrue(
43 thread.IsValid(), "There should be a thread stopped due to breakpoint"
45 frame0 = thread.GetFrameAtIndex(0)
46 self.assertEqual(frame0.GetLineEntry().GetLine(), self.line)
48 # Now get the SBSymbolContext from this frame. We want everything. :-)
49 context = frame0.GetSymbolContext(lldb.eSymbolContextEverything)
50 self.assertTrue(context)
52 # Get the description of this module.
53 module = context.GetModule()
54 desc = lldbutil.get_description(module)
55 self.expect(desc, "The module should match", exe=False, substrs=[exe])
57 compileUnit = context.GetCompileUnit()
58 self.expect(
59 str(compileUnit),
60 "The compile unit should match",
61 exe=False,
62 substrs=[self.getSourcePath("main.c")],
65 function = context.GetFunction()
66 self.assertTrue(function)
68 block = context.GetBlock()
69 self.assertTrue(block)
71 lineEntry = context.GetLineEntry()
72 self.expect(
73 lineEntry.GetFileSpec().GetDirectory(),
74 "The line entry should have the correct directory",
75 exe=False,
76 substrs=[self.mydir],
78 self.expect(
79 lineEntry.GetFileSpec().GetFilename(),
80 "The line entry should have the correct filename",
81 exe=False,
82 substrs=["main.c"],
84 self.assertEqual(
85 lineEntry.GetLine(), self.line, "The line entry's line number should match "
88 symbol = context.GetSymbol()
89 self.assertTrue(
90 function.GetName() == symbol.GetName() and symbol.GetName() == "c",
91 "The symbol name should be 'c'",
94 sc_list = lldb.SBSymbolContextList()
95 sc_list.Append(context)
96 self.assertEqual(len(sc_list), 1)
97 for sc in sc_list:
98 self.assertEqual(lineEntry, sc.GetLineEntry())