summaryrefslogtreecommitdiff
path: root/tools/llvm-pdbutil
AgeCommit message (Collapse)Author
2017-12-15Don't crash in llvm-pdbutil when dumping TypeIndexes with high bit set.Zachary Turner
This is a special code that indicates that it's a function id. While I'm still not certain how to interpret these, we definitely should *not* be using these values as indices into an array directly. For now, when we encounter one of these, just print the numeric value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320775 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13Recover some overzealously removed includes.Michael Zolotukhin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320648 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13Remove redundant includes from tools.Michael Zolotukhin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-06Fix error in llvm-pdbutil.Zachary Turner
A recent change made this print the wrong value, breaking some tests. This is now fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319862 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05Teach llvm-pdbutil to dump types from object files.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319859 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-30Split TypeTableBuilder into two classes.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319456 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29Make TypeTableBuilder inherit from TypeCollection.Zachary Turner
A couple of places in LLD were passing references to TypeTableCollections around, which makes it hard to change the implementation at runtime. However, these cases only needed to iterate over the types in the collection, and TypeCollection already provides a handy abstract interface for this purpose. By implementing this interface, we can get rid of the need to pass TypeTableBuilder references around, which should allow us to swap the implementation at runtime in subsequent patches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319345 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-29Fix line endings in llvm-pdbutil.cppZachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319340 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-28[CodeView] Refactor / Rewrite TypeSerializer and TypeTableBuilder.Zachary Turner
The motivation behind this patch is that future directions require us to be able to compute the hash value of records independently of actually using them for de-duplication. The current structure of TypeSerializer / TypeTableBuilder being a single entry point that takes an unserialized type record, and then hashes and de-duplicates it is not flexible enough to allow this. At the same time, the existing TypeSerializer is already extremely complex for this very reason -- it tries to be too many things. In addition to serializing, hashing, and de-duplicating, ti also supports splitting up field list records and adding continuations. All of this functionality crammed into this one class makes it very complicated to work with and hard to maintain. To solve all of these problems, I've re-written everything from scratch and split the functionality into separate pieces that can easily be reused. The end result is that one class TypeSerializer is turned into 3 new classes SimpleTypeSerializer, ContinuationRecordBuilder, and TypeTableBuilder, each of which in isolation is simple and straightforward. A quick summary of these new classes and their responsibilities are: - SimpleTypeSerializer : Turns a non-FieldList leaf type into a series of bytes. Does not do any hashing. Every time you call it, it will re-serialize and return bytes again. The same instance can be re-used over and over to avoid re-allocations, and in exchange for this optimization the bytes returned by the serializer only live until the caller attempts to serialize a new record. - ContinuationRecordBuilder : Turns a FieldList-like record into a series of fragments. Does not do any hashing. Like SimpleTypeSerializer, returns references to privately owned bytes, so the storage is invalidated as soon as the caller tries to re-use the instance. Works equally well for LF_FIELDLIST as it does for LF_METHODLIST, solving a long-standing theoretical limitation of the previous implementation. - TypeTableBuilder : Accepts sequences of bytes that the user has already serialized, and inserts them by de-duplicating with a hash table. For the sake of convenience and efficiency, this class internally stores a SimpleTypeSerializer so that it can accept unserialized records. The same is not true of ContinuationRecordBuilder. The user is required to create their own instance of ContinuationRecordBuilder. Differential Revision: https://reviews.llvm.org/D40518 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319198 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman
of it in some cases where it is a more clear alternative to std::for_each. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317356 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-27[PDB] Handle an empty globals hash table with no bucketsReid Kleckner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316722 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24[codeview] Fix handling of S_HEAPALLOCSITEReid Kleckner
The type index is from the TPI stream, not the IPI stream. Fix the dumper, fix type index discovery, and add a test in LLD. Also improve the log message we emit when we fail to rewrite type indices in LLD. That's how I found this bug. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316461 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03Fix -Wcovered-switch-default warnings from r314821Hans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314826 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03CodeView: Provide a .def file with the register idsHans Wennborg
The list of register ids was previously written out in a couple of dirrent places. This puts it in a .def file and also adds a few more registers (e.g. the x87 regs) which should lead to more readable dumps, but I didn't include the whole list since that seems unnecessary. X86_MC::initLLVMToSEHAndCVRegMapping is pretty ugly, but at least it's not relying on magic constants anymore. The TODO of using tablegen still stands. Differential revision: https://reviews.llvm.org/D38480 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314821 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-07COFF: PDB: Allow multiple modules with the same name.Peter Collingbourne
It is possible for two modules to have the same name if they are archive members with the same name, or if we are doing LTO (in which case all modules will have the name "lto.tmp"). Differential Revision: https://reviews.llvm.org/D37589 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312744 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-02[llvm-pdbutil] Remove unused variables.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312395 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-01Fix broken test.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312359 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-01[llvm-pdbutil] Support dumping CodeView from object files.Zachary Turner
We have llvm-readobj for dumping CodeView from object files, and llvm-pdbutil has always been more focused on PDB. However, llvm-pdbutil has a lot of useful options for summarizing debug information in aggregate and presenting high level statistical views. Furthermore, it's arguably better as a testing tool since we don't have to write tests to conform to a state-machine like structure where you match multiple lines in succession, each depending on a previous match. llvm-pdbutil dumps much more concisely, so it's possible to use single-line matches in many cases where as with readobj tests you have to use multi-line matches with an implicit state machine. Because of this, I'm adding object file support to llvm-pdbutil. In fact, this mirrors the cvdump tool from Microsoft, which also supports both object files and pdb files. In the future we could perhaps rename this tool llvm-cvutil. In the meantime, this allows us to deep dive into object files the same way we already can with PDB files. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312358 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31Fix some size_t / uint32_t mismatched comparisons.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312278 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31[llvm-pdbutil] Print detailed S_UDT stats.Zachary Turner
This adds a new command line option, -udt-stats, which breaks down the stats of S_UDT records. These are one of the biggest contributors to the size of /DEBUG:FASTLINK PDBs, so they need some additional tools to be able to analyze their usage. This option will dig into each S_UDT record and determine what kind of record it points to, and then break down the statistics by the target type. The goal here is to identify how our object files differ from MSVC object files in S_UDT records, so that we can output fewer of them and reach size parity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312276 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-23Remove llvm-pdbutil/fuzzer.George Karpenkov
The code does not compile, is not maintained, and does not have a buildbot. Differential Revision: https://reviews.llvm.org/D37032 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-21[llvm-pdbutil] Add support for dumping detailed module stats.Zachary Turner
This adds support for dumping a summary of module symbols and CodeView debug chunks. This option prints a table for each module of all of the symbols that occurred in the module and the number of times it occurred and total byte size. Then at the end it prints the totals for the entire file. Additionally, this patch adds the -jmc (just my code) option, which suppresses modules which are from external libraries or linker imports, so that you can focus only on the object files and libraries that originate from your own source code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311338 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-18Remove useless default case in switchVictor Leschuk
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311149 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-17Fix warning about covered switch default.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311129 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-17[llvm-pdbutil] Fix some dumping issues.Zachary Turner
When dumping, we were treating the S_INLINESITESYM as referring to a type record, when it actually refers to an id record. We had this correct in TypeIndexDiscovery, so our merging algorithm should be fine, but we had it wrong in the dumper, which means it would appear to work most of the time, unless the index was out of bounds in the type stream, when it would fail. Fixed this, and audited a few other cases to make them match the behavior in TypeIndexDiscovery. Also, I've now observed a new symbol record with kind 0x1168 which I have no clue what it is, so to avoid crashing we have to just print "Unknown Symbol Kind". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311117 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-17Fix a few minor issues when dumping symbols.Zachary Turner
1) We weren't handling symbol types that weren't able to parse, even if we knew what the leaf type was. This was triggering when trying to dump /DEBUG:FASTLINK PDBs, where we expect a certain symbol to show up, but we just don't know how to parse it. 2) We lost the code for dumping record bytes, so this was added back. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311116 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-11Output S_SECTION symbols to the Linker module.Zachary Turner
PDBs need to contain 1 module for each object file/compiland, and a special one synthesized by the linker. This one contains a symbol record for each output section in the executable with its address information. This patch adds such symbols to the linker module. Note that we also are supposed to add an S_COFFGROUP symbol for what appears to be each input section that contributes to each output section, but it's not entirely clear how to generate these yet, so I'm leaving that for a separate patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310754 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09[PDB] Fix an issue writing the publics stream.Zachary Turner
In the refactor to merge the publics and globals stream, a bug was introduced that wrote the wrong value for one of the fields of the PublicsStreamHeader. This caused debugging in WinDbg to break. We had no way of dumping any of these fields, so in addition to fixing the bug I've added dumping support for them along with a test that verifies the correct value is written. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310439 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-08[PDB] Fix linking of function symbols and local variables.Zachary Turner
The compiler outputs PROC32_ID symbols into the object files for functions, and these symbols have an embedded type index which, when copied to the PDB, refer to the IPI stream. However, the symbols themselves are also converted into regular symbols (e.g. S_GPROC32_ID -> S_GPROC32), and type indices in the regular symbol records refer to the TPI stream. So this patch applies two fixes to function records. 1. It converts ID symbols to the proper non-ID record type. 2. After remapping the type index from the object file's index space to the PDB file/IPI stream's index space, it then remaps that index to the TPI stream's index space by. Besides functions, during the remapping process we were also discarding symbol record types which we did not recognize. In particular, we were discarding S_BPREL32 records, which is what MSVC uses to describe local variables on the stack. So this patch fixes that as well by copying them to the PDB. Differential Revision: https://reviews.llvm.org/D36426 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310394 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-07[llvm-pdbutil] Don't crash when a section contrib's isect is invalid.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310298 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04Enable llvm-pdbutil to list enumerations using native PDB readerAdrian McCarthy
This extends the native reader to enable llvm-pdbutil to list the enums in a PDB and it includes a simple test. It does not yet list the values in the enumerations, which requires an actual implementation of NativeEnumSymbol::FindChildren. To exercise this code, use a command like: llvm-pdbutil pretty -native -enums foo.pdb Differential Revision: https://reviews.llvm.org/D35738 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310144 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04[pdbutil] When dumping section contribs, show the section name.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310128 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04[llvm-pdbutil] Dump image section headers.Zachary Turner
Image section headers are stored in the DBI stream, but we had no way to dump them. This patch adds dumping support, along with some tests that LLD actually dumps them correctly. Differential Revision: https://reviews.llvm.org/D36332 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310107 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-03[llvm-pdbutil] Add an option to only dump specific module indices.Zachary Turner
Often something interesting (like a symbol) is in a particular module, and you don't want to dump symbols from all other 300 modules to see the one you want. This adds a -modi option so that we only dump the specified module. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310000 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-03[llvm-pdbutil] Allow diff to force module equivalencies.Zachary Turner
Sometimes the normal module equivalence detection algorithm doesn't quite work. For example, you might build the same program with MSVC and clang-cl, outputting to different object files, exes, and PDBs, then compare them. If the object files have different names though, then they won't be treated as equivalent. This way we can force specific module indices to be treated as equivalent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309983 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02[pdbutil] Add a command to dump the FPM.Zachary Turner
Recently problems have been discovered in the way we write the FPM (free page map). In order to fix this, we first need to establish a baseline about what a correct FPM looks like using an MSVC generated PDB, so that we can then make our own generated PDBs match. And in order to do this, the dumper needs a mode where it can dump an FPM so that we can write tests for it. This patch adds a command to dump the FPM, as well as a test against a known-good PDB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309894 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-27[llvm-pdbutil] Clean up ExitOnError usage to add ": " to our errorsReid Kleckner
The banner parameter is supposed to end in a separator, like ": ". Otherwise, we get ugly errors like: Error while reading publics streamNative error: blah blah git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309332 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-26[PDB] Improve GSI hash table dumping for publics and globalsReid Kleckner
The PDB "symbol stream" actually contains symbol records for the publics and the globals stream. The globals and publics streams are essentially hash tables that point into a single stream of records. In order to match cvdump's behavior, we need to only dump symbol records referenced from the hash table. This patch implements that, and then implements global stream dumping, since it's just a subset of public stream dumping. Now we shouldn't see S_PROCREF or S_GDATA32 records when dumping publics, and instead we should see those record in the globals stream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309066 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-24[codeview] Emit 'D' as the cv source language for D codeReid Kleckner
This matches DMD: https://github.com/dlang/dmd/blob/522263965cf3a27ed16b31f3c3562db86cdeabec/src/ddmd/backend/cv8.c#L199 Fixes PR33899. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308890 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-21[PDB] Dump extra info about the publics streamReid Kleckner
This includes the hash table, the address map, and the thunk table and section offset table. The last two are only used for incremental linking, which LLD doesn't support, so they are less interesting. The hash table is particularly important to get right, since this is the one of the streams that debuggers use to translate addresses to symbols. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308764 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-20[COFF, ARM64, CodeView] Add support to emit CodeView debug info for ARM64 COFFMandeep Singh Grang
Reviewers: compnerd, ruiu, rnk, zturner Reviewed By: rnk Subscribers: majnemer, aemerson, aprantl, javed.absar, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D35518 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308665 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-18[PDB] Finish and simplify TPI hashingReid Kleckner
Summary: This removes the CVTypeVisitor updater and verifier classes. They were made dead by the minimal type dumping refactoring. Replace them with a single function that takes a type record and produces a hash. Call this from the minimal type dumper and compare the hash. I also noticed that the microsoft-pdb reference repository uses a basic CRC32 for records that aren't special. We already have an implementation of that CRC ready to use, because it's used in COFF for ICF. I'll make LLD call this hashing utility in a follow-up change. We might also consider using this same hash in type stream merging, so that we don't have to hash our records twice. Reviewers: inglorion, ruiu Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D35515 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308240 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17[codeview] Fix YAML for LF_TYPESERVER2 by hoisting PDB_UniqueIdReid Kleckner
Summary: We were treating the GUIDs in TypeServer2Record as strings, and the non-ASCII bytes in the GUID would not round-trip through YAML. We already had the PDB_UniqueId type portably represent a Windows GUID, but we need to hoist that up to the DebugInfo/CodeView library so that we can use it in the TypeServer2Record as well as in PDB parsing code. Reviewers: inglorion, amccarth Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D35495 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308234 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17[codeview] Remove TypeServerHandler and PDBTypeServerHandlerReid Kleckner
Summary: Instead of wiring these through the CVTypeVisitor interface, clients should inspect the CVTypeArray before visiting it and potentially load up the type server's TPI stream if they need it. No tests relied on this functionality because LLD was the only client. Reviewers: ruiu Subscribers: mgorny, hiraditya, zturner, llvm-commits Differential Revision: https://reviews.llvm.org/D35394 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308212 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-15[CodeView] Dump BuildInfoSym and ProcSym type indicesReid Kleckner
I need to print the type index in hex so that I can match it in FileCheck for a test I'm writing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308107 91177308-0d34-0410-b5e6-96231b3b80d8
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-10Build fixes for pdb-diff test.Zachary Turner
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307556 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