[Lldb-commits] [PATCH] D51967: [PDB] Use the raw PDB symbol interface more accurately

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 12 15:18:51 PDT 2018

zturner added a comment.

I've been experimenting with DIA locally and after some investigation I'm not sure this is going to be reliable.  Let's say we have a class, we want the decl context containing the class.  For example, on line 366.  So we call `GetDeclContextContainingSymbol`.  Despite what the MSDN documentation states, I'm pretty sure this is going to return a `PDBSymbolExe`.  Worse, there is no guarantee that `getLexicalParent()` or `getClassParent()` will return the same thing twice.  It all depends on how you obtained the object in the first place.

To make this concrete:

Suppose you find the PDB Global Scope object, enumerate it and you find some function called `foo` at address 12345.  If you call `getLexicalParent()` on it, it will be the Exe symbol (because the way you obtained it is by calling `ExeSymbol->findAllChildren`, so the Exe symbol is the parent).  Now you take this address 12345 and call `Session->findSymbolByAddress(12345);`  It returns a new symbol **with the same uid** but now suddenly the lexical parent is the compiland where the symbol is defined.  I hacked up `llvm-pdbutil` to dump some output from a test exe I created, and it outputs this:

  Calling Session->findSymbolByAddress(1752)
  3 `__raise_securityfailure` [Class: <null>, Lexical: 2 (Compiland 'f:\binaries\Intermediate\vctools\msvcrt.nativeproj_607447030\objd\x86\gs_report.obj')]
  Printing function signature
  1 `` [Class: <null>, Lexical: 4 (Tag 1)]
  Calling Session->getSymbolById(3)
  3 `__raise_securityfailure` [Class: <null>, Lexical: 2 (Compiland 'f:\binaries\Intermediate\vctools\msvcrt.nativeproj_607447030\objd\x86\gs_report.obj')]
  Enumerating all functions
  3 `__raise_securityfailure` [Class: <null>, Lexical: 4 (Tag 1)]
  5 `_RTC_CheckEsp` [Class: <null>, Lexical: 4 (Tag 1)]

So notice that `__raise_securityfailure` has Lexical Parent of 4 when I enumerate functions, but a lexical parent of 2 (the matching compiland) if I obtain it by calling `findSymbolByAddress`.

Furthermore, for types, it seems that this method will never return anything other than the Exe.  I was not able to find any way to get a symbol corresponding to a type record that returned a compiland.



More information about the lldb-commits mailing list