[Lldb-commits] [PATCH] Fix Module::GetSymbolFileFileSpec and simplify CommandObjectTargetModulesList::PrintModule
clayborg at gmail.com
Mon Mar 2 10:52:25 PST 2015
m_symfile_spec is in Module _only_ for the case where you told us where the symbol file was manually so that we could create the symbol file lazily only when we needed to. You might have /tmp/a.out as the file and /users/me/symbols/a.out as the symbol file and when you create the symbol file we will use Module::GetSymbolFileFileSpec() as a hint as to where to look. The problem is this path might be a path to a bundle, like a dSYM file on MacOSX. So the path might not be resolved and the right file inside the bundle might not be correct. So on MacOSX you might have /tmp/a.out as the module's object file path and "/tmp/a.out.dSYM" as the symbol file path. The SymbolVendorMacOSX will know what to do with this bundle path (it will actually create an object file with "/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out", so though you are updating the m_symfile_spec, it won't be usable by anyone unless they first call Module::GetSymbolVendor() and then call Module::GetSymbolFileFileSpec(). So that isn't a great API. Granted this should be documented better in the GetSymbolFileFileSpec() prototype in the Module.h header file. So the previous code that was there is correct and no changes really need to be made since I wouldn't want anyone really using GetSymbolFileFileSpec() since they would have to know to call Module::GetSymbolVendor() first. Feel free to add a SymbolVendor::GetMainFileSpec() to SymbolVendor and place the following code in it:
SymbolFile *symbol_file = symbol_vendor->GetSymbolFile();
ObjectFile *object_file = symbol_file->GetObjectFile();
We should name the accessor SymbolVendor::GetMainFileSpec() because a SymbolVendor might use more than one file for the debug info. None currently do, but that is the idea behind SymbolVendor: do what you need to do to get the best debug info possible and use as many sources/files as required.
More information about the lldb-commits