================
@@ -749,10 +749,20 @@ TEST_F(SymtabTest, TestSymtabCreatedOnDemand) {
ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
auto module_sp = std::make_shared<Module>(ExpectedFile->moduleSpec());
- // The symbol table should not be loaded by default.
+ // The symbol file should not be created by default.
Symtab *module_symtab = module_sp->GetSymtab(/*can_create=*/false);
ASSERT_EQ(module_symtab, nullptr);
+ // Even if the symbol file is created, the symbol table should not be
created by default.
+
+ // TODO:
+ // I need to create a symbol file here, but without causing it to parse the
symbol table.
+ // See next line as a failed attempt.
+
+ // module_sp->GetSymbolFile(/*can_create=*/true); // Cannot do this because
it will parse the symbol table.
----------------
royitaqi wrote:
Thanks @jimingham for the info. You are right. This isn't because of dynamic
loader.
The first divergence is between Linux and Darwin, when they call
[`platform_sp->LocateExecutableScriptingResources`](https://github.com/llvm/llvm-project/blob/9e3982d9ae8173171cd7247ee505e9c02079c6bf/lldb/source/Core/Module.cpp#L1433).
On Linux, there is no override, so it called the default
`Platform::LocateExecutableScriptingResources` and didn't go further. So no
symbol file created in this case. On Darwin, there is
`PlatformDarwin::LocateExecutableScriptingResources`, which calls
`Module::GetSymbolFile`, which creates a symbol file.
The second divergence is on Darwin, between dSYM and .O file, when
[`SymbolFile::CalculateAbilities`](https://github.com/llvm/llvm-project/blob/5c3789811fd5b50df1178e7068efb75c5b359383/lldb/include/lldb/Symbol/SymbolFile.h#L530)
is called. Depending on the type of symbol file we have, it goes into
`SymbolFileDWARF::CalculateAbilities` and
`SymbolFileDWARFDebugMap::CalculateAbilities`, respectively. In the former, it
returned almost directly, without parsing symbol tables. In the latter, it goes
to loading all the OSO, which includes parsing all the symbol tables in there.
This is why I cannot repro on Linux - it never created the symbol file, not to
mention the symbol table.
cc @dmpots just as a read (not related to "how to make the test work" by too
much).
https://github.com/llvm/llvm-project/pull/136236
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits