This is an archive of the discontinued LLVM Phabricator instance.

Introduce NativeEnumModules and NativeCompilandSymbol
ClosedPublic

Authored by amccarth on Mar 14 2017, 3:12 PM.

Details

Summary

Together, these allow lldb-pdbdump to list all the modules from a PDB using a native reader (rather than DIA).

Note that I'll probably be specializing NativeRawSymbol in a subsequent patch.

Diff Detail

Event Timeline

amccarth created this revision.Mar 14 2017, 3:12 PM
amccarth updated this revision to Diff 91792.Mar 14 2017, 4:32 PM

Cope with the backwards naming of the getName and getLibraryName methods.

amccarth updated this revision to Diff 91899.Mar 15 2017, 10:37 AM

Added a -native option to the llvm-pdbdump pretty subcommand to select the reader, and added a test that checks the compilands list it produces.

Note that the -native option is not yet ready for usage beyond enumerating the compilands.

zturner added inline comments.Mar 15 2017, 10:53 AM
llvm/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
2–3

The line wraps here, need to find a way to make it shorter.

llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
24

For the longest time I've wondered what they mean by EC in the native PDB code, and now it just hit me that it's edit and continue. Perhaps you could just return Module.Info.hasECInfo(); here?

26

In the future, this will be the unique (within the context of this PDB session) of the Exe symbol.

llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
35–37

Not as important as it is when you have a shared_ptr, but I think as a matter of style we prefer make_unique instead of explicitly constructing a unique_ptr with the result of a new expression.

llvm/test/DebugInfo/PDB/Native/pdb-native-compilands.test
19

Should this prefix be removed as well? (as per the comment above)?

66

newline

amccarth marked 4 inline comments as done.Mar 15 2017, 11:08 AM
amccarth added inline comments.
llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
26

Acknowledged. I'm going to make a specialization next for the Exe, so this should become clearer soon.

llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
35–37

I generally do use make_unique, but I don't know of another way to have make_unique create a unique_ptr of the base class that actually points to an instance of a subclass.

llvm/test/DebugInfo/PDB/Native/pdb-native-compilands.test
19

I missed that one. It probably doesn't matter, since the path is fixed for whoever built the PDB originally, but I've done it to be consistent.

amccarth updated this revision to Diff 91902.Mar 15 2017, 11:09 AM
amccarth marked an inline comment as done.

Fixes per comments.

zturner accepted this revision.Mar 15 2017, 11:13 AM
This revision is now accepted and ready to land.Mar 15 2017, 11:13 AM
inglorion added inline comments.
llvm/include/llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h
3

This comment seems broken. It's spread over multiple lines and the opening "-*-" is missing. Is the problem here that this really didn't fit on one line? If so, since Emacs likes its magic markers on the first line, perhaps we can put the description on the second line?

llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
2

s/\.h/.cpp/

28

Instead of "counter-intuitive", can you specify what they actually mean? That would make it easier to verify that these methods are indeed doing the right thing.

llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
33

You're choosing to return nullptr here, instead of something else, e.g. crashing or asserting. I'm curious why you prefer to return nullptr. Could you explain your rationale?

amccarth marked 2 inline comments as done.Mar 15 2017, 12:37 PM
amccarth added inline comments.
llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
28

Zach and I were having a partially offline discussion about this. We might rename these methods in a future patch, but I'll take a crack at re-wording this comment in the mean time.

llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
33

I'm following the lead set by the DIA versions of the enumerators I've looked at. For example, DIAEnumDebugStreams.cpp returns nullptr if anything goes wrong querying DIA for the desired item, and calling with an invalid index is one possibility.

I'd be happy to assert instead if you think it's important.

amccarth updated this revision to Diff 91915.Mar 15 2017, 12:47 PM

Addresses the header line mistakes caught by inglorion and re-words the comment on the mappings for getName and getLibraryName methods.

inglorion accepted this revision.Mar 15 2017, 12:58 PM

lgtm2

llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
33

I'm perfectly happy with us doing the same thing DIA does. Thanks for the explanation!

This revision was automatically updated to reflect the committed changes.