[Lldb-commits] [PATCH] D55384: [NativePDB] Reconstruct FunctionDecl AST nodes from PDB debug info

Zachary Turner via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 7 10:04:41 PST 2018


zturner marked 2 inline comments as done.
zturner added a comment.

In D55384#1322702 <https://reviews.llvm.org/D55384#1322702>, @labath wrote:

> In D55384#1321970 <https://reviews.llvm.org/D55384#1321970>, @zturner wrote:
>
> > Clang-cl emits `S_LOCAL` symbols while MSVC emits `S_REGREL32` and `S_REGISTER` symbols.  So, to get more test coverage, I added an MSVC test as well.
>
>
> I don't want to block this patch, but my thoughts after reading this is that this is repeating the same mistakes that we did with dwarf. The reason we need so much to run our tests in so many configurations is that we haven't found a way way to handle the fact that some things can be expressed in multiple ways in the debug info other than compiling the source code with the compiler which happens to use that dialect. Then, if a later e.g. clang chooses to do the same thing that msvc does, we lose coverage here without anyone noticing. For low-level details like these, I believe a test where the type of the symbol is explicit would be more appropriate (for dwarf that might be a .s file, I don't know if that would work for pdbs).


I considered this, and we actually have a test that does (see `s_constant.s`).  The reason I didn't do it here because my experience writing `s_constant.s` taught me just how difficult it is to write these assembly files.

However, now I have a new idea.  We can teach `llvm-pdbutil` to dump its output exactly in llvm assembly format, so the output can just be copy-pasted into a .s file.  Then, we can build something with MSVC, dump it to .s format, and paste individual records into a test and mix and match them as necessary to create all the interesting cases.

For the purposes of this test, we don't even need to run the program, so it actually doesn't even matter if the addresses in the debug info records are correct.  All we care about is that the AST is reconstructed correctly.  I'll add this to my todo list because I think it would be a really useful feature.



================
Comment at: lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp:577
+
+  clang::DeclContext *decl_context = m_clang->GetTranslationUnitDecl();
+  clang::FunctionDecl *function_decl = m_clang->CreateFunctionDeclaration(
----------------
aleksandr.urakov wrote:
> May be it would be worth to leave a TODO here (about searching a correct declaration context in the future)?
Let me know how the new diff looks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55384/new/

https://reviews.llvm.org/D55384





More information about the lldb-commits mailing list