mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 19:08:21 +08:00
When you are trying for instance to set a breakpoint on a function by name, but the SBFunction or SBSymbol are returning demangled names with argument lists, that match can be tedious to do. Internally, the base name of a symbol is something we handle all the time, so it's reasonable that there should be a way to get that info from the API as well. rdar://159318791
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
"""
|
|
Test SBFunction::GetBaseName() and SBSymbol::GetBaseName() APIs.
|
|
"""
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class GetBaseNameTestCase(TestBase):
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
def setUp(self):
|
|
TestBase.setUp(self)
|
|
self.main_source_file = lldb.SBFileSpec("main.cpp")
|
|
|
|
def test(self):
|
|
"""Test SBFunction.GetBaseName() and SBSymbol.GetBaseName()"""
|
|
self.build()
|
|
_, _, thread, _ = lldbutil.run_to_source_breakpoint(
|
|
self, "Set a breakpoint here", self.main_source_file
|
|
)
|
|
|
|
frame0 = thread.GetFrameAtIndex(0)
|
|
|
|
# Get both function and symbol
|
|
function = frame0.GetFunction()
|
|
symbol = frame0.GetSymbol()
|
|
|
|
# Test consistency between function and symbol basename
|
|
function_basename = function.GetBaseName()
|
|
symbol_basename = symbol.GetBaseName()
|
|
|
|
self.assertEqual(function_basename, "templateFunc")
|
|
self.assertEqual(symbol_basename, "templateFunc")
|