44 lines · python
1"""2Test lookup unnamed symbols.3"""4 5 6import lldb7from lldbsuite.test.decorators import *8from lldbsuite.test.lldbtest import *9from lldbsuite.test import lldbutil10 11# --keep-symbol causes error on Windows: llvm-strip.exe: error: option is not supported for COFF12@skipIfWindows13# Unnamed symbols don't get into the .eh_frame section on ARM, so LLDB can't find them.14@skipIf(archs=["arm$"])15class TestUnnamedSymbolLookup(TestBase):16 def test_unnamed_symbol_lookup(self):17 """Test looking up unnamed symbol synthetic name"""18 self.build()19 (target, process, thread, bkpt) = lldbutil.run_to_name_breakpoint(20 self, "main", exe_name="a.out.stripped"21 )22 23 main_frame = thread.GetFrameAtIndex(0)24 25 # Step until reaching the unnamed symbol called from main26 for _ in range(100):27 thread.StepInto()28 if thread.GetFrameAtIndex(0) != main_frame:29 break30 31 thread.StepInto()32 33 self.assertEqual(34 main_frame, thread.GetFrameAtIndex(1), "Expected to be called from main"35 )36 symbol = thread.GetFrameAtIndex(0).GetSymbol()37 self.assertIsNotNone(symbol, "unnamed symbol called from main not reached")38 self.assertTrue(symbol.name.startswith("___lldb_unnamed_symbol"))39 40 exe_module = symbol.GetStartAddress().GetModule()41 found_symbols = exe_module.FindSymbols(symbol.name)42 self.assertIsNotNone(found_symbols)43 self.assertEqual(found_symbols.GetSize(), 1)44