[Lldb-commits] [lldb] [lldb] Avoid force loading symbol files in statistics collection (PR #129593)
David Peixotto via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 7 16:05:39 PST 2025
================
@@ -718,3 +720,40 @@ TEST_F(SymtabTest, TestDecodeCStringMaps) {
Symtab::eVisibilityAny);
ASSERT_NE(symbol, nullptr);
}
+
+TEST_F(SymtabTest, TestSymtabCreatedOnDemand) {
+ auto ExpectedFile = TestFile::fromYaml(R"(
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+ Entry: 0x0000000000400180
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ Address: 0x0000000000400180
+ AddressAlign: 0x0000000000000010
+ Content: 554889E58B042500106000890425041060005DC3
+Symbols:
+ - Name: _start
+ Type: STT_FUNC
+ Section: .text
+ Value: 0x0000000000400180
+ Size: 0x0000000000000014
+ Binding: STB_GLOBAL
+...
+)");
+ ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+ auto module_sp = std::make_shared<Module>(ExpectedFile->moduleSpec());
+
+ // The symbol table should not be loaded by default.
+ Symtab *module_symtab = module_sp->GetSymtab(/*can_create=*/false);
+ ASSERT_EQ(module_symtab, nullptr);
+
+ // But it should be created on demand.
+ module_symtab = module_sp->GetSymtab(/*can_create=*/true);
+ ASSERT_NE(module_symtab, nullptr);
----------------
dmpots wrote:
Good idea. Updated the test.
https://github.com/llvm/llvm-project/pull/129593
More information about the lldb-commits
mailing list