|
| 1 | +""" |
| 2 | +Test SBFunction::GetBaseName() and SBSymbol::GetBaseName() APIs. |
| 3 | +""" |
| 4 | + |
| 5 | +import lldb |
| 6 | +from lldbsuite.test.decorators import * |
| 7 | +from lldbsuite.test.lldbtest import * |
| 8 | +from lldbsuite.test import lldbutil |
| 9 | + |
| 10 | + |
| 11 | +class GetBaseNameTestCase(TestBase): |
| 12 | + |
| 13 | + NO_DEBUG_INFO_TESTCASE = True |
| 14 | + |
| 15 | + def setUp(self): |
| 16 | + # Call super's setUp(). |
| 17 | + TestBase.setUp(self) |
| 18 | + # Find the line number to break on. |
| 19 | + self.line1 = line_number( |
| 20 | + "main.cpp", "// Find the line number for breakpoint 1 here." |
| 21 | + ) |
| 22 | + |
| 23 | + def test(self): |
| 24 | + """Test SBFunction.GetBaseName() and SBSymbol.GetBaseName()""" |
| 25 | + self.build() |
| 26 | + exe = self.getBuildArtifact("a.out") |
| 27 | + |
| 28 | + # Create a target by the debugger. |
| 29 | + target = self.dbg.CreateTarget(exe) |
| 30 | + self.assertTrue(target, VALID_TARGET) |
| 31 | + |
| 32 | + # Create a breakpoint inside the C++ namespaced function. |
| 33 | + breakpoint1 = target.BreakpointCreateByLocation("main.cpp", self.line1) |
| 34 | + |
| 35 | + # Now launch the process, and do not stop at entry point. |
| 36 | + process = target.LaunchSimple(None, None, self.get_process_working_directory()) |
| 37 | + |
| 38 | + # Get stopped thread and frame |
| 39 | + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) |
| 40 | + frame0 = thread.GetFrameAtIndex(0) |
| 41 | + |
| 42 | + # Get both function and symbol |
| 43 | + function = frame0.GetFunction() |
| 44 | + symbol = frame0.GetSymbol() |
| 45 | + |
| 46 | + # Test consistency between function and symbol basename |
| 47 | + function_basename = function.GetBaseName() |
| 48 | + symbol_basename = symbol.GetBaseName() |
| 49 | + |
| 50 | + self.assertEqual(function_basename, "templateFunc") |
| 51 | + self.assertEqual(symbol_basename, "templateFunc") |
| 52 | + |
| 53 | + self.trace("Function basename:", function_basename) |
| 54 | + self.trace("Symbol basename:", symbol_basename) |
0 commit comments