This is an archive of the discontinued LLVM Phabricator instance.

Enable more abilities in SymbolFilePDB
ClosedPublic

Authored by asmith on Dec 11 2017, 1:40 PM.

Details

Summary
  1. Finding symbols through --symfile
  2. More abilities: Functions, Blocks, GlobalVariables, LocalVariables, VariableTypes

Diff Detail

Repository
rL LLVM

Event Timeline

asmith created this revision.Dec 11 2017, 1:40 PM
clayborg added inline comments.
source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
127

I am assuming this assert won't fire if we give this an ELF or MachO file or any file that doesn't contain PDB info? Every SymbolFile subclass gets to calculate its abilities on each file until on of them returns that they can handle all abilities, or until all plug-ins have had a chance to answer and then the best one is picked. Seems like this shouldn't be here? I can't remember what checks get run before SymbolFile::CalculateAbilities() is called...

zturner added inline comments.Dec 11 2017, 2:00 PM
source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
108–125

LLVM coding style dictates the use of early returns whenever possible. So this block should be changed to something like.

auto module_sp = m_obj_file->GetModule();
if (!module_sp)
  return 0;

FileSpec symfile = module_sp->GetSymbolFileSpec();
if (!symfile)
  return 0;

error = loadDataForPDB(...);
if (error) {
  llvm::consumeError(error);
  return 0;
}

// etc
141

Similar thing here. Assign first, and then add:

if (!enum_dbg_streams_up)
  break;
144
if (stream_name != "SECTIONHEADERS")
  continue;
151–157

Is this correct? If *any* of these 3 sections of present, then *all* of these capabilities are present?

Shouldn't we be actually trying to query DIA for a global, local, or variable and then seeing what it returns?

(Incidentally, it's easy to figure this out with the native PDB reader, since you can just look for the presence of a module symbol stream, globals stream, and/or TPI stream).

asmith added inline comments.Dec 13 2017, 10:42 AM
source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
127

Any ELF or MachO other than PDB or PECOFF will error when calling loadDataForEXE or loadDataForPDB and return before reaching the assertion.

asmith updated this revision to Diff 127658.Dec 19 2017, 8:57 PM

If a Symbols table is present then lldb can retrieve symbols for the types listed in PDBSym_Type. In other words, if we want symbolic information for a function then checking for the Symbols table is sufficient.

asmith marked 5 inline comments as done.Dec 19 2017, 8:58 PM
zturner accepted this revision.Dec 20 2017, 8:07 AM

This looks better. Technically it's possible to break this with some weird PDBs but I don't think it's possible to do better without using the native reader.

This revision is now accepted and ready to land.Dec 20 2017, 8:07 AM
asmith closed this revision.Dec 21 2017, 4:05 PM