llvm-project/lldb/test/API/tools/lldb-dap/moduleSymbols/TestDAP_moduleSymbols.py
Ely Ronnen 428ffbd506
Re-land LLDB dap module symbol tables (#155021)
Re-land the symbol table feature in lldb-dap after it was
[reverted](2b8e806942)
because of a crash in the `aarch64` tests, which was caused by
dereferencing `SBSymbol::GetName` which might return `nullptr` for an
invalid symbol.

This patch reapplies the original commits and adds the missing null
check.

Also adding `skipIfWindows` for the module symbols tests, since LLDB
doesn't recognize the symbols from a.out there.
2025-08-23 08:19:46 +02:00

41 lines
1.3 KiB
Python

"""
Test lldb-dap moduleSymbols request
"""
import lldbdap_testcase
from lldbsuite.test.decorators import *
class TestDAP_moduleSymbols(lldbdap_testcase.DAPTestCaseBase):
# On windows LLDB doesn't recognize symbols in a.out.
@skipIfWindows
def test_moduleSymbols(self):
"""
Test that the moduleSymbols request returns correct symbols from the module.
"""
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
symbol_names = []
i = 0
while True:
next_symbol = self.dap_server.request_moduleSymbols(
moduleName="a.out", startIndex=i, count=1
)
self.assertIn("symbols", next_symbol["body"])
result_symbols = next_symbol["body"]["symbols"]
self.assertLessEqual(len(result_symbols), 1)
if len(result_symbols) == 0:
break
self.assertIn("name", result_symbols[0])
symbol_names.append(result_symbols[0]["name"])
i += 1
if i >= 1000:
break
self.assertGreater(len(symbol_names), 0)
self.assertIn("main", symbol_names)
self.assertIn("func1", symbol_names)
self.assertIn("func2", symbol_names)