This is an archive of the discontinued LLVM Phabricator instance.

[NativePDB] Extend .pdb files search folders
AcceptedPublic

Authored by zloyrobot on Apr 22 2019, 4:49 AM.

Details

Summary

This patch adds ability to find .pdb files in NT_SYMBOL_PATH folders and in .exe file folder

Diff Detail

Repository
rLLDB LLDB

Event Timeline

zloyrobot created this revision.Apr 22 2019, 4:49 AM
lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
5

Is this not testing finding the PDB file in the _NT_SYMBOL_PATH?

zloyrobot added inline comments.Apr 22 2019, 11:06 PM
lldb/lit/SymbolFile/NativePDB/pdb-file-lookup.cpp
5

Thanks for feedback, this description is wrong and test checks that we can find PDB file in the _NT_SYMBOL_PATH and doesn't check PDB file in folder containing EXE file.

I'll update test and make it test both cases.

zloyrobot updated this revision to Diff 196226.Apr 23 2019, 5:50 AM

Add test case for searching .pdb file in the same folder as .exe file

zloyrobot updated this revision to Diff 196232.Apr 23 2019, 6:18 AM
This revision is now accepted and ready to land.Apr 23 2019, 10:00 AM

cc: Pavel Labath because I know he's been involved in conversations about how to find symbol files in general (PDB, split DWARF, Breakpad, etc.), especially when doing post-mortem debugging.

I believe there are complications when the debugger host is different than the target host, (e.g., post-mortem debugging a Windows minidump using LLDB on Linux).

I'm not concerned about the details of this patch but whether this approach is going to be compatible with the more general solution being discussed. This is small enough that it's probably not a big deal if it's helpful for now, but I'm going to hold my LGTM until Pavel has a chance to weigh in.

The problem I have is that PDB is not following the lldb convention of doing the symbol file search inside a SymbolVendor class (which should really be called a SymbolFinder), but instead they implement their own little symbol vendor privately. There are reasons which make switching that not trivial, but they're not important in the context of this patch, which seems fine to me, as any reasonable future symbol vendor should also support the standard windows search mechanism. So overall, I do not see a reason to not accept this patch.

lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
110

I find the interface of this function odd. First, the consts on the StringRef argument are useless and should be removed. Secondly, the by-ref return of the magic argument is something that would be nice to avoid. It looks like that could easily be done here by just checking whether the file exists and doing the identify_magic check in the caller (if you want an existing-but-not-pdb file to abort the search), or by checking the signature in this function (if you want to skip past non-pdb files). Also, this patch could use clang-formatting as this line is over the column limit.

111

Llvm policy is to use auto "if and only if it makes the code more readable" http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable. Whether that's the case here is somewhat subjective, but I'd say that none of the uses of auto in this patch are helping readability, as all the types used in this patch are short enough and spelling them out saves the reader from guessing whether ec really is a std::error_code, etc.

Thanks Pavel!

Please address Pavel's inline comments, and I'll accept this.

zloyrobot marked 2 inline comments as done.Apr 25 2019, 2:41 AM
zloyrobot added inline comments.
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
110

I want to skip past non-pdb files. Am I understand correctly that you suggest me to get rid of file_magic parameter and call identify_magic (open and read pdb file) additional time (in caller)?

111

Please note that I moved `auto ec = ...` from original Turner's code

zloyrobot marked 2 inline comments as not done.Apr 25 2019, 2:44 AM
labath added a subscriber: zturner.Apr 25 2019, 3:44 AM
labath added inline comments.
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
110

In that case, what you could do is get rid of the magic as an argument, and change this function to return a valid result, only if you found the file *and* that files magic number is correct. (note that this is not what the current implementation does)

111

yeah, I know, but that doesn't make it right. :) In fact, based on a random sample, I would guess that about 90% of uses of auto ec in llvm is @zturner's code. :P

TBH, the ec is no the part I'm having problems with the most. If it was just that, I wouldn't mention it, but the fact that you're using it all over the place tells me you weren't aware of llvm's policy regarding auto (which explicitly states "don't 'almost always use auto'"), and I figured it's best to mention that early on.

zloyrobot updated this revision to Diff 196614.Apr 25 2019, 4:54 AM
zloyrobot marked 2 inline comments as done.Apr 25 2019, 5:00 AM
zloyrobot added inline comments.
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
110

got it, thanks

111

Thanks for the clarifications, I updated the path

Thanks Pavel!

Please address Pavel's inline comments, and I'll accept this.

Kind reminder

labath accepted this revision.May 16 2019, 8:45 AM

Adrian is on vacation now, but given that he was just waiting until you resolve my comments (which you have), I think we don't have to wait for him.

Adrian is on vacation now, but given that he was just waiting until you resolve my comments (which you have), I think we don't have to wait for him.

Thank you for one more review.

amccarth accepted this revision.May 22 2019, 3:30 PM

Curious what the status of this is? Looks like its been ready for almost one year :)