summaryrefslogtreecommitdiff
path: root/tools/llvm-pdbutil/DiffPrinter.h
AgeCommit message (Collapse)Author
2017-07-10Resubmit "Add pdb-diff test."Zachary Turner
This was originally reverted because of two issues. 1) Printing ANSI color escape codes even when outputting to a file 2) Module name comparisons were failing when comparing a PDB generated on one machine to a PDB generated on another machine. I attempted to fix #2 by adding command line options which let you specify prefixes to strip from the beginning of embedded paths, which effectively lets us specify a path to "base" each PDB from and only compare the parts under the base. But this is tricky because PDB paths always use Windows path syntax, even when they are created on non-Windows hosts. A problem still existed when constructing the prefix to strip, where we were accidentally using a host-specific path separator instead of a Windows path separator. This resubmission fixes the issue on Linux (and I have verified that the test now passes on Linux). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307571 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10Revert "Build fixes for pdb-diff test."Zachary Turner
This reverts commit 180af3fdbdb17ec35b45ec1f925fd743b28d37e1. This is still breaking due to linux-specific path differences. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307559 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-10Fix pdb-diff test.Zachary Turner
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
2017-07-07[llvm-pdbutil] Fix build.Zachary Turner
Some platforms require an explicit specialization of std::hash for PdbRaw_FeaturesSig. Also a test involving case sensitivity needed to be fixed. For now that particular check just accepts any path even if they're completely different. Long term we should output paths in the correct case to match MSVC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-07Fix some differences between lld and MSVC generated PDBs.Zachary Turner
A couple of things were different about our generated PDBs. 1) We were outputting the wrong Version on the PDB Stream. The version we were setting was newer than what MSVC is setting. It's not clear what the implications are, but we change LLD to use PdbImplVC70, as MSVC does. 2) For the optional debug stream indices in the DBI Stream, we were outputting 0 to mean "the stream is not present". MSVC outputs uint16_t(-1), which is the "correct" way to specify that a stream is not present. So we fix that as well. 3) We were setting the PDB Stream signature to 0. This is supposed to be the result of calling time(nullptr). Although this leads to non-deterministic builds, a better way to solve that is by having a command line option explicitly for generating a reproducible build, and have the default behavior of lld-link match the default behavior of link. To test this, I'm making use of the new and improved `pdb diff` sub command. To make it suitable for writing tests against, I had to modify the diff subcommand slightly to print less verbose output. Previously it would always print | <column> | <value1> | <value2> | which is quite verbose, and the values are fragile. All we really want to know is "did we produce the same value as link?" So I added command line options to print a single character representing the result status (different, identical, equivalent), and another to hide the value display. Note that just inspecting the diff output used to write the test, you can see some things that are obviously wrong. That is just reflective of the fact that this is the state of affairs today, not that we're asserting that this is "correct". We can use this as a starting point to discover differences, fix them, and update the test. Differential Revision: https://reviews.llvm.org/D35086 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-07[llvm-pdbutil] Improve diff mode.Zachary Turner
We're getting to the point that some MS tools (e.g. DIA) can recognize our PDBs but others (e.g. link.exe) cannot. I think the way forward is to improve our tooling to help us find differences more easily. For example, if we can compile the same program with clang-cl and cl and have a tool tell us all the places where the PDBs differ, this could tell us what we're doing wrong. It's tricky though, because there are a lot of "benign" differences in a PDB. For example, if the string table in one PDB consists of "foo" followed by "bar" and in the other PDB it consists of "bar" followed by "foo", this is not necessarily a critical difference, as long as the uses of these strings also refer to the correct location. On the other hand, if the second PDB doesn't even contain the string "foo" at all, this is a critical difference. diff mode has been in llvm-pdbutil for quite a while, but because of the above challenge along with some others, it's been hard to make it useful. I think this patch addresses that. It looks for all the same things, but it now prints the output in tabular format (carefully formatted and aligned into tables and fields), and it highlights critical differences in red, non-critical differences in yellow, and identical fields in green. This makes it easy to spot the places we differ, and the general concept of outputting arbitrary fields in tabular format can be extended to provide analysis into many of the different types of information that show up in a PDB. Differential Revision: https://reviews.llvm.org/D35039 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307421 91177308-0d34-0410-b5e6-96231b3b80d8