Page MenuHomePhabricator

[lldb] Add support to cache a PDB's global scope and fix a bug in getting the source file name for a compiland

Authored by asmith on Dec 19 2017, 8:50 PM.



This commit is a combination of the following changes:

  • Cache PDB's global scope (executable) in SymbolFilePDB
  • Change naming of cu to compiland which is PDB specific
  • Change ParseCompileUnitForSymIndex to ParseCompileUnitForUID. Prefer using a common name UID instead of PDB's System Index Adding one more argument index to this method, which is used to specify the index of the compile unit in a cached compile unit array
  • Add GetPDBCompilandByUID method to simply code
  • Fix a bug in getting the source file name for a PDB compiland. For some reason, PDBSymbolCompiland::getSourceFileName() could return an empty name, so if that is true, we have to walk through all source files of this compiland and determine the right source file used to generate this compiland based on language indicated.

    The previous implementation called PDBSession::findOneSourceFile method to get its name for the compiland. This is not accurate since the one source file found could be a header other than source file.

Diff Detail


Event Timeline

asmith created this revision.Dec 19 2017, 8:50 PM

Since it seems like you're going to be doing some work in here, it would be great if you could update lldb-test to dump PDB symbol information. This would allow us to easily test all sorts of things in here. For example, you could find a PDB that returned an empty source file name, and then have the tool dump something like:

Compiland: {foo}, Source File: {bar}

then we could just grep this output against FileCheck.


Is it DIA that is returning the empty name?


Can you do an early return here?


This would probably be shorter as:

llvm::is_contained({"cpp", "c", "cc", "cxx"}, file_extension.GetStringRef().lower());

Early return here.


nit: .get() shouldn't be necessary


Same here.


Is this a performance win or just a convenience? I assumed the session itself would cache the global scope, but maybe that assumption was wrong.

asmith updated this revision to Diff 128312.Dec 28 2017, 6:02 PM

These changes will fix this crash in the current mainline:

lldb-test.exe symbols (path-to-your-lldb-exe)

Can you add a test with REQUIRES: windows that builds a simple program using clang-cl, generates a PDB, and then uses lldb-test to check part of the output against that executable? It can be a one line check, basically just proving that it doesn't crash, and we can add more specific tests for certain types of symbols and types later.

asmith updated this revision to Diff 129747.Jan 12 2018, 10:01 PM

Added a lit unit test

zturner accepted this revision.Jan 12 2018, 10:15 PM

It's nice that this turned out so easy. Didn't even require modifying lldb-test.


If there's only one line then CHECK-DAG is equivalent to CHECK.

This revision is now accepted and ready to land.Jan 12 2018, 10:15 PM
asmith updated this revision to Diff 129750.Jan 12 2018, 10:56 PM
asmith retitled this revision from [lldb] This commit adds support to cache a PDB's global scope and fixes a bug in getting the source file name for a compiland to [lldb] Add support to cache a PDB's global scope and fix a bug in getting the source file name for a compiland.
asmith edited the summary of this revision. (Show Details)

Cleaned up some comments before commit

asmith closed this revision.Jan 12 2018, 10:59 PM