summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbutil
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "Build fixes for pdb-diff test."Zachary Turner2017-07-107-289/+147
| | | | | | | | This reverts commit 180af3fdbdb17ec35b45ec1f925fd743b28d37e1. This is still breaking due to linux-specific path differences. llvm-svn: 307559
* Build fixes for pdb-diff test.Zachary Turner2017-07-101-3/+3
| | | | llvm-svn: 307556
* Fix pdb-diff test.Zachary Turner2017-07-107-147/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 307555
* [llvm-pdbutil] Fix build.Zachary Turner2017-07-071-0/+11
| | | | | | | | | | 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. llvm-svn: 307426
* Use windows path syntax when writing PDB module name.Zachary Turner2017-07-072-40/+50
| | | | | | | | | | | | | | Without this we would just append whatever the user wrote on the command line, so if we're in C:\foo and we run lld-link bar/baz.obj, we would write C:\foo\bar/baz.obj in various places in the PDB. MSVC linker does not do this, so we shouldn't either. This fixes some differences in the diff test, so we update the test as well. Differential Revision: https://reviews.llvm.org/D35092 llvm-svn: 307423
* Fix some differences between lld and MSVC generated PDBs.Zachary Turner2017-07-075-44/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 307422
* [llvm-pdbutil] Improve diff mode.Zachary Turner2017-07-076-261/+584
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 307421
* [PDB] Teach libpdb to write DBI Stream ECNames.Zachary Turner2017-07-071-0/+7
| | | | | | | | | | | | | | | | | | | | | | | Based strictly on the name, this seems to have something to do width edit & continue. The goal of this patch has nothing to do with supporting edit and continue though. msvc link.exe writes very basic information into this area even when *not* compiling with support for E&C, and so the goal here is to bring lld-link to parity. Since we cannot know what assumptions standard tools make about the content of PDB files, we need to be as close as possible. This ECNames data structure is a standard PDB string hash table. link.exe puts a single string into this hash table, which is the full path to the PDB file on disk. It then references this string from the module descriptor for the compiler generated `* Linker *` module. With this patch, lld-link will generate the exact same sequence of bytes as MSVC link for this subsection for a given object file input (as reported by `llvm-pdbutil bytes -ec`). llvm-svn: 307356
* Fix -Wunused-function by making function declarations in a header non-staticDavid Blaikie2017-07-061-2/+2
| | | | | | | | Also avoids ODR violations by ensuring names used in headers find the same entity, not different, file-local entities in each translation unit. llvm-svn: 307237
* Fix std::min ambiguity between uint32 and size_t.Zachary Turner2017-07-051-1/+1
| | | | llvm-svn: 307205
* [llvm-pdbutil] Add the ability to truncate stream purpose names.Zachary Turner2017-07-054-36/+83
| | | | | | | This will be useful for aligning fields to a fixed with in subsequent patches. llvm-svn: 307204
* [PDB] Add a test that verifies every known type record.Zachary Turner2017-07-052-5/+5
| | | | | | | | | | | | | | We had a lot of one-off tests for this type and that type, or "every type that happens to be generated by this program I built". Eventually I got a bug report filed where we were crashing on a type that was not covered by any of these tests. So this test carefully constructs a minimal C++ program that will cause every type we support to be emitted. This ensures full coverage for type records. Differential Revision: https://reviews.llvm.org/D34915 llvm-svn: 307187
* Remove spurious semicolons.Zachary Turner2017-06-301-34/+0
| | | | llvm-svn: 306891
* [llvm-pdbutil] Output the symbol offset when dumping.Zachary Turner2017-06-303-46/+91
| | | | | | | | | | | | | | | | Type records have a unique type index, but symbol records do not. Instead, symbol records refer to other symbol records by referencing their offset in the symbol stream. In a sense this is the analogue of the TypeIndex, but we are not printing it in the dumper. Printing it not only gives us more useful information when manually investigating the contents of a PDB, but also allows us to write better tests by enabling us to verify that fields that reference other symbol records do so correctly. Differential Revision: https://reviews.llvm.org/D34906 llvm-svn: 306890
* Fix ODR violations due to abuse of LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTORRichard Smith2017-06-301-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | This is a short-term fix for PR33650 aimed to get the modules build bots green again. Remove all the places where we use the LLVM_YAML_IS_(FLOW_)?SEQUENCE_VECTOR macros to try to locally specialize a global template for a global type. That's not how C++ works. Instead, we now centrally define how to format vectors of fundamental types and of string (std::string and StringRef). We use flow formatting for the former cases, since that's the obvious right thing to do; in the latter case, it's less clear what the right choice is, but flow formatting is really bad for some cases (due to very long strings), so we pick block formatting. (Many of the cases that were using flow formatting for strings are improved by this change.) Other than the flow -> block formatting change for some vectors of strings, this should result in no functionality change. Differential Revision: https://reviews.llvm.org/D34907 Corresponding updates to clang, clang-tools-extra, and lld to follow. llvm-svn: 306878
* [llvm-pdbutil] Add the ability to dump the dependency tree for a typeZachary Turner2017-06-305-26/+91
| | | | | | | | | | | | | | | Previously we had the -type-index option which would dump the record of a single, but we had no way to follow the dependency graph backwards and also dump all dependent types. Having this option makes test-writing better, because we can limit the test to only those records that are of importance for the thing we're trying to test, which allows us to use things like CHECK-NEXT to reduce fragility. Differential Revision: https://reviews.llvm.org/D34899 llvm-svn: 306852
* [llvm-pdbutil] Add a mode to `bytes` for dumping split debug chunks.Zachary Turner2017-06-263-43/+90
| | | | llvm-svn: 306309
* [llvm-pdbutil] Dump raw bytes of module symbols and debug chunks.Zachary Turner2017-06-234-0/+132
| | | | llvm-svn: 306179
* [llvm-pdbutil] Dump raw bytes of type and id records.Zachary Turner2017-06-234-0/+90
| | | | llvm-svn: 306167
* [llvm-pdbutil] Dump raw bytes of various DBI stream subsections.Zachary Turner2017-06-235-7/+138
| | | | llvm-svn: 306160
* [llvm-pdbutil] Show what blocks a stream occupies.Zachary Turner2017-06-233-0/+13
| | | | | | | | This is useful when you want to look at a specific chunk of a stream or look for discontinuities, and you need to know the list of blocks occupied by a stream. llvm-svn: 306150
* [llvm-pdbutil] Dump raw bytes of pdb name map.Zachary Turner2017-06-236-15/+30
| | | | | | | | This patch dumps the raw bytes of the pdb name map which contains the mapping of stream name to stream index for the string table and other reserved streams. llvm-svn: 306148
* [llvm-pdbutil] Add the ability to dump raw bytes from the file.Zachary Turner2017-06-234-20/+72
| | | | | | | | | | Normally we can only make sense of the content of a PDB in terms of streams and blocks, but in some cases it may be useful to dump bytes at a specific absolute file offset. For example, if you know that some interesting data is at a particular location and you want to see some surrounding data. llvm-svn: 306146
* [llvm-pdbutil] Add a function for formatting MSF data.Zachary Turner2017-06-233-27/+149
| | | | | | | | | | | | | | | | | | | The goal here is to make it possible to display absolute file offsets when dumping byets from an MSF. The problem is that when dumping bytes from an MSF, often the bytes will cross a block boundary and encounter a discontinuity. We can't use the normal formatBinary() function for this because this would just treat the sequence as entirely ascending, and not account out-of-order blocks. This patch adds a formatMsfData() function to our printer, and then uses this function to improve the output of the -stream-data command line option for dumping bytes from a particular stream. Test coverage is also expanded to make sure to include all possible scenarios of offsets, sizes, and crossing block boundaries. llvm-svn: 306141
* [llvm-pdbutil] Create a "bytes" subcommand.Zachary Turner2017-06-228-138/+292
| | | | | | | | | | | | | | | | | | | This idea originally came about when I was doing some deep investigation of why certain bytes in a PDB that we round-tripped differed from their original bytes in the source PDB. I found myself having to hack up the code in many places to dump the bytes of this substream, or that record. It would be nice if we could just do this for every possible stream, substream, debug chunk type, etc. It doesn't make sense to put this under dump because there's just so many options that would detract from the more common use case of just dumping deserialized records. So making a new subcommand seems like the most logical course of action. In doing so, we already have two command line options that are suitable for this new subcommand, so start out by moving them there. llvm-svn: 306056
* [llvm-pdbutil] Rename "raw" to "dump".Zachary Turner2017-06-225-119/+120
| | | | | | | | | Now you run llvm-pdbutil dump <options>. This is a followup after having renamed the tool, whereas before raw was obviously just the style of dumping, whereas now "dump" is the action to perform with the "util". llvm-svn: 306055
* Remove diff pedantic mode.Zachary Turner2017-06-203-191/+91
| | | | llvm-svn: 305818
* [CodeView] Fix dumping of public symbol record flagsReid Kleckner2017-06-191-1/+15
| | | | | | | I noticed nonsensical type information while dumping PDBs produced by MSVC. llvm-svn: 305708
* Remove some dead code / includes.Zachary Turner2017-06-168-137/+47
| | | | | | | I'm trying to get rid of the TypeDatabase class, so the first step is to minimize its footprint. llvm-svn: 305611
* [llvm-pdbutil] Add support for dumping cross module imports/exports.Zachary Turner2017-06-165-5/+81
| | | | llvm-svn: 305532
* [llvm-pdbutil] Add a function for iterating over debug subsections.Zachary Turner2017-06-151-104/+102
| | | | | | NFC, just adds a helper function to reduce boilerplate. llvm-svn: 305531
* [llvm-pdbutil] Add support for dumping lines and inlinee lines.Zachary Turner2017-06-154-53/+271
| | | | llvm-svn: 305529
* [llvm-pdbutil] Add back support for dumping file checksums.Zachary Turner2017-06-152-6/+106
| | | | | | When dumping module source files, also dump checksums. llvm-svn: 305526
* [llvm-pdbutil] Add back the ability to dump hashes and index offsets.Zachary Turner2017-06-155-19/+76
| | | | | | | This was regressed in a previous patch that re-wrote the dumper, and I'm incrementally adding back the pieces that are missing. llvm-svn: 305524
* Resubmit "[llvm-pdbutil] rewrite the "raw" output style."Zachary Turner2017-06-1515-1363/+2399
| | | | | | | | | This resubmits commit c0c249e9f2ef83e1d1e5f166b50673d92f3579d7. It was broken due to some weird template issues, which have since been fixed. llvm-svn: 305517
* Revert "[llvm-pdbutil] rewrite the "raw" output style."Zachary Turner2017-06-1515-2370/+1363
| | | | | | | | | This reverts commit 83ea17ebf2106859a51fbc2a86031b44d33696ad. This is failing due to some strange template problems, so reverting until it can be straightened out. llvm-svn: 305505
* Fix some more warnings.Zachary Turner2017-06-154-28/+19
| | | | llvm-svn: 305499
* Fix some -Wreorder issues.Zachary Turner2017-06-153-3/+2
| | | | llvm-svn: 305497
* [llvm-pdbutil] rewrite the "raw" output style.Zachary Turner2017-06-1515-1363/+2380
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After some internal discussions, we agreed that the raw output style had outlived its usefulness. It was originally created before we had even thought of dumping to YAML, and it was intended to give us some insight into the internals of a PDB file. Now we have YAML mode which does almost exactly this but is more powerful in that it can round-trip back to a PDB, which the raw mode could not do. So the raw mode had become purely a maintenance burden. One option was to just delete it. However, its original goal was to be as readable as possible while staying close to the "metal" - i.e. presenting the output in a way that maps directly to the underlying file format. We don't actually need that last requirement anymore since it's covered by the yaml mode, so we could repurpose "raw" mode to actually just be as readable as possible. This patch implements about 80% of the functionality previously in raw mode, but in a completely different style that is more akin to what cvdump outputs. Records are very compressed, often times appearing on just one line. One nice thing about this is that it makes full record matching easier, because you can grep for indices, names, and leaf types on a single line often. See the tests for some examples of what the new output looks like. Note that this patch actually regresses the functionality of raw mode in a few areas, but only because the patch was already unreasonably large and going 100% would have been even worse. Specifically, this patch is missing: The ability to dump module debug subsections (checksums, lines, etc) The ability to dump section headers Aside from that everything is here. While goign through the tests fixing them all up, I found many duplicate tests. They've been deleted. In subsequent patches I will go through and re-add the missing functionality. Differential Revision: https://reviews.llvm.org/D34191 llvm-svn: 305495
* Resubmit "[codeview] Make obj2yaml/yaml2obj support .debug$S..."Zachary Turner2017-06-143-20/+31
| | | | | | | | | This was originally reverted because of some non-deterministic failures on certain buildbots. Luckily ASAN eventually caught this as a stack-use-after-scope, so the fix is included in this patch. llvm-svn: 305393
* Revert "[codeview] Make obj2yaml/yaml2obj support .debug$S..."Zachary Turner2017-06-143-31/+20
| | | | | | | | This is causing failures on linux bots with an invalid stream read. It doesn't repro in any configuration on Windows, so reverting until I have a chance to investigate on Linux. llvm-svn: 305371
* [codeview] Make obj2yaml/yaml2obj support .debug$S/T sections.Zachary Turner2017-06-143-20/+31
| | | | | | | | | | | | | | | This allows us to use yaml2obj and obj2yaml to round-trip CodeView symbol and type information without having to manually specify the bytes of the section. This makes for much easier to maintain tests. See the tests under lld/COFF in this patch for example. Before they just said SectionData: <blob> whereas now we can use meaningful record descriptions. Note that it still supports the SectionData yaml field, which could be useful for initializing a section to invalid bytes for testing, for example. Differential Revision: https://reviews.llvm.org/D34127 llvm-svn: 305366
* Fix printing error.Zachary Turner2017-06-121-1/+1
| | | | llvm-svn: 305240
* [llvm-pdbutil] Fix one more issue with no-id-stream PDBs.Zachary Turner2017-06-121-13/+20
| | | | | | | | | | This one occurred when we were dumping symbols, we have code that is prepared to dump many different types of symbols, including symbols which reference an ID stream. So when creating the dumper object, we assume that there is an ID stream. Fix this assumption. llvm-svn: 305237
* Slightly better fix for dealing with no-id-stream PDBs.Zachary Turner2017-06-121-8/+0
| | | | | | | | | The last fix required the user to manually add the required feature. This caused an LLD test to fail because I failed to update LLD. In practice we can hide this logic so it can just be transparently added when we write the PDB. llvm-svn: 305236
* [llvm-pdbdump] Don't fail on PDBs with no ID stream.Zachary Turner2017-06-123-3/+20
| | | | | | | | | Older PDBs don't have this. Its presence is detected by using the various "feature" flags that come at the end of the PDB Stream. Detect this, and don't try to dump the ID stream if the features tells us it's not present. llvm-svn: 305235
* Fix a null pointer dereference in llvm-pdbutil pretty.Zachary Turner2017-06-121-12/+12
| | | | | | | | Static data members were causing a problem because I mistakenly assumed all members would affect a class's layout and so the Layout member would be non-null. llvm-svn: 305229
* [pdb] Support CoffSymbolRVA debug subsection.Zachary Turner2017-06-093-0/+14
| | | | llvm-svn: 305108
* Rename llvm-pdbdump -> llvm-pdbutil.Zachary Turner2017-06-0943-0/+6579
This is to reflect the evolving nature of the tool as being useful for more than just dumping PDBs, as it can do many other things. Differential Revision: https://reviews.llvm.org/D34062 llvm-svn: 305106
OpenPOWER on IntegriCloud