[Lldb-commits] [lldb] [lldb] Initial plugin and test for SymbolLocatorSymStore (PR #183302)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 5 01:03:40 PST 2026
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>,
Stefan =?utf-8?q?Gränitz?= <stefan.graenitz at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/183302 at github.com>
================
@@ -0,0 +1,113 @@
+import glob
+import os
+import shutil
+import tempfile
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+"""
+Test debug symbol acquisition from a local SymStore repository.
+"""
+
+
+class MockedSymStore:
+ """
+ Populate a file structure equivalent to SymStore.exe in a temporary directory.
+ This can work cross-platform and for arbitrary debug info formats. Right now,
+ we support only PDB.
+ """
+
+ def __init__(self, test, exe, pdb):
+ self._test = test
+ self._exe = exe
+ self._pdb = pdb
+ self._tmp = None
+
+ def get_key_pdb(self, exe):
+ """
+ Module UUID: 12345678-1234-5678-9ABC-DEF012345678-00000001
+ To SymStore key: 12345678123456789ABCDEF0123456781
+ """
+ try:
+ spec = lldb.SBModuleSpec()
+ spec.SetFileSpec(lldb.SBFileSpec(self._test.getBuildArtifact(exe)))
+ module = lldb.SBModule(spec)
+ raw = module.GetUUIDString().replace("-", "").upper()
+ if len(raw) != 40:
+ return None
+ guid_hex = raw[:32]
+ age = int(raw[32:], 16)
+ return guid_hex + str(age)
+ except Exception:
+ return None
+
+ def __enter__(self):
+ """
+ Mock local symstore directory tree, move PDB there and report path.
+ """
+ key = None
+ if self._test.getDebugInfo() == "pdb":
+ key = self.get_key_pdb(self._exe)
+ self._test.assertIsNotNone(key)
+ self._tmp = tempfile.mkdtemp()
+ pdb_dir = os.path.join(self._tmp, self._pdb, key)
+ os.makedirs(pdb_dir)
+ shutil.move(
+ self._test.getBuildArtifact(self._pdb),
+ os.path.join(pdb_dir, self._pdb),
+ )
+ return self._tmp.replace("\\", "/")
+
+ def __exit__(self, *exc_info):
+ """
+ Clean up and delete original exe so next make won't skip link command.
+ """
+ shutil.rmtree(self._tmp)
+ self._test.runCmd("settings clear plugin.symbol-locator.symstore")
+ os.remove(self._test.getBuildArtifact(self._exe))
+ return False # do not suppress exceptions
+
+
+class SymStoreLocalTests(TestBase):
+ TEST_WITH_PDB_DEBUG_INFO = True
+
+ def build_inferior(self):
+ self.build()
+ exe_file = "a.out"
+ if self.getDebugInfo() == "pdb":
+ sym_file = "a.pdb"
+ else:
+ self.skipTest("Non-PDB debug info variants not yet supported")
+ self.assertTrue(os.path.isfile(self.getBuildArtifact(exe_file)))
+ self.assertTrue(os.path.isfile(self.getBuildArtifact(sym_file)))
+ return exe_file, sym_file
+
+ def try_breakpoint(self, exe, should_have_loc):
+ self.runCmd("settings set symbols.enable-external-lookup true")
----------------
DavidSpickett wrote:
The scenario I imagine:
* I set my SymStore URLs and enable external lookup.
* I have a SymStore with what I think is some bogus data in it, because something came out wrong.
* I turn off the external lookup.
* The something is still wrong.
* ???
* After much struggle, I realise that I either have to:
* Move the SymStore files (which might have been created by my preconfigured toolchain, so I may not want to mess with it)
* Clear the SymStore URL setting. Which is easy to do but only once you realise you need to.
This isn't the end of the world while it's still local machine only, but once you're capable of downloading files, it's more important to know that it's not going to reach out over the network.
So yes, it disrupts your neat test setup here, sorry about that, but I do think it's worth checking `symbols.enable-external-lookup false` behaves as it should.
https://github.com/llvm/llvm-project/pull/183302
More information about the lldb-commits
mailing list