diff options
author | Zachary Turner <zturner@google.com> | 2017-07-10 16:52:15 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-07-10 16:52:15 +0000 |
commit | 80e0f20bdec8e1775c1c5d350d9825bde47a2100 (patch) | |
tree | ff8570f1569651907898832a831dce60836ef361 /tools/llvm-pdbutil/llvm-pdbutil.cpp | |
parent | 65eefa7f01381abcf94b13fd5df5dc0e657b7c51 (diff) |
Fix pdb-diff test.
A test was checked in on Friday that worked by checking in an
object file and PDB generated locally by MSVC, and then having
the test run lld-link on the object file and diffing LLD's PDB
against the checked in PDB.
This failed because part of the diffing algorithm involves
determining if two modules are the same, and if so drilling into
the module and diffing individual fields of the module. The
only thing we can use to make this determination though is the
"name" of the module, which is a path to where the module (obj
file) was read from on the machine where it was linked. This
fails for obvious reasons when comparing a PDB generated on one
machine to a PDB on another machine.
The fix employed here is to add two command line options to the
diff subcommand, which allow the user to specify a "binary root
path". The bin root path, if specified, is stripped from the
beginning of any embedded PDB paths. The test is updated to
specify the user's local test output directory for the left
PDB, and is hardcoded to the location where the original PDB
was created for the right PDB. This way all the equivalence
comparisons should succeed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-pdbutil/llvm-pdbutil.cpp')
-rw-r--r-- | tools/llvm-pdbutil/llvm-pdbutil.cpp | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index 6432b9ce86c0..6aa08ff3cd87 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -293,9 +293,23 @@ cl::opt<bool> cl::desc("Print a column with the result status"), cl::Optional, cl::sub(DiffSubcommand)); -cl::list<std::string> InputFilenames(cl::Positional, - cl::desc("<first> <second>"), - cl::OneOrMore, cl::sub(DiffSubcommand)); +cl::opt<std::string> LeftRoot( + "left-bin-root", cl::Optional, + cl::desc("Treats the specified path as the root of the tree containing " + "binaries referenced by the left PDB. The root is stripped from " + "embedded paths when doing equality comparisons."), + cl::sub(DiffSubcommand)); +cl::opt<std::string> RightRoot( + "right-bin-root", cl::Optional, + cl::desc("Treats the specified path as the root of the tree containing " + "binaries referenced by the right PDB. The root is stripped from " + "embedded paths when doing equality comparisons"), + cl::sub(DiffSubcommand)); + +cl::opt<std::string> Left(cl::Positional, cl::desc("<left>"), + cl::sub(DiffSubcommand)); +cl::opt<std::string> Right(cl::Positional, cl::desc("<right>"), + cl::sub(DiffSubcommand)); } cl::OptionCategory FileOptions("Module & File Options"); @@ -1151,11 +1165,7 @@ int main(int argc_, const char *argv_[]) { std::for_each(opts::bytes::InputFilenames.begin(), opts::bytes::InputFilenames.end(), dumpBytes); } else if (opts::DiffSubcommand) { - if (opts::diff::InputFilenames.size() != 2) { - errs() << "diff subcommand expects exactly 2 arguments.\n"; - exit(1); - } - diff(opts::diff::InputFilenames[0], opts::diff::InputFilenames[1]); + diff(opts::diff::Left, opts::diff::Right); } else if (opts::MergeSubcommand) { if (opts::merge::InputFilenames.size() < 2) { errs() << "merge subcommand requires at least 2 input files.\n"; |