This is an archive of the discontinued LLVM Phabricator instance.

Add SymbolVendor::GetMainFileSpec and simplify CommandObjectTargetModulesList::PrintModule
ClosedPublic

Authored by ki.stfu on Mar 2 2015, 6:26 AM.

Diff Detail

Event Timeline

ki.stfu updated this revision to Diff 21002.Mar 2 2015, 6:26 AM
ki.stfu retitled this revision from to Fix Module::GetSymbolFileFileSpec and simplify CommandObjectTargetModulesList::PrintModule.
ki.stfu updated this object.
ki.stfu edited the test plan for this revision. (Show Details)
ki.stfu added reviewers: abidh, clayborg.
ki.stfu added subscribers: abidh, clayborg, Unknown Object (MLST).
clayborg requested changes to this revision.Mar 2 2015, 10:52 AM
clayborg edited edge metadata.

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();
if (symbol_file)
{
    ObjectFile *object_file = symbol_file->GetObjectFile();
    if (object_file)
        return object_file->GetFileSpec();
}
return FileSpec();

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.

This revision now requires changes to proceed.Mar 2 2015, 10:52 AM
ki.stfu updated this revision to Diff 21567.Mar 10 2015, 5:41 AM
ki.stfu edited edge metadata.

Add SymbolVendor::GetMainFileSpec

ki.stfu retitled this revision from Fix Module::GetSymbolFileFileSpec and simplify CommandObjectTargetModulesList::PrintModule to Add SymbolVendor::GetMainFileSpec and simplify CommandObjectTargetModulesList::PrintModule.Mar 10 2015, 5:42 AM
ki.stfu updated this object.
ki.stfu edited edge metadata.
ki.stfu updated this revision to Diff 21570.Mar 10 2015, 5:53 AM

Some fixes

clayborg accepted this revision.Mar 10 2015, 11:42 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Mar 10 2015, 11:42 AM
ki.stfu closed this revision.Mar 10 2015, 2:21 PM