summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-pdbutil
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix MSVC "not all control paths return a value" warning.Simon Pilgrim2018-01-171-0/+1
| | | | llvm-svn: 322719
* Fix build error - 'default label in switch which covers all enumeration values'Aaron Smith2018-01-171-2/+0
| | | | llvm-svn: 322610
* Fix pretty printing the unspecified param of a variadic functionAaron Smith2018-01-172-0/+4
| | | | | | | | | | | | | | | | | | | | | | | Summary: - Fix a bug in PrettyBuiltinDumper that returns "void" as the name for an unspecified builtin type. Since the unspecified param of a variadic function is considered a builtin of unspecified type in PDBs, we set "..." for its name. - Provide a method to determine if a PDBSymbolFunc is variadic in PrettyFunctionDumper since PDBSymbolFunc::getArgument() doesn't return the last unspecified-type param. - Add a pretty-func-dumper.test to test pretty dumping of variadic functions. Reviewers: zturner, llvm-commits Reviewed By: zturner Differential Revision: https://reviews.llvm.org/D41801 llvm-svn: 322608
* [PDB] Correctly link S_FILESTATIC records.Zachary Turner2018-01-054-10/+59
| | | | | | | | | | | | | | | | | This is not a record type that clang currently generates, but it is a record that is encountered in object files generated by cl. This record is unusual in that it refers directly to the string table instead of indirectly to the string table via the FileChecksums table. Because of this, it was previously overlooked and we weren't remapping the string indices at all. This would lead to crashes in MSVC when trying to display a variable whose debug info involved an S_FILESTATIC. Original bug report by Alexander Ganea Differential Revision: https://reviews.llvm.org/D41718 llvm-svn: 321883
* Don't crash in llvm-pdbutil when dumping TypeIndexes with high bit set.Zachary Turner2017-12-151-1/+1
| | | | | | | | | 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. llvm-svn: 320775
* Recover some overzealously removed includes.Michael Zolotukhin2017-12-131-0/+1
| | | | llvm-svn: 320648
* Remove redundant includes from tools.Michael Zolotukhin2017-12-138-29/+0
| | | | llvm-svn: 320631
* Fix error in llvm-pdbutil.Zachary Turner2017-12-061-6/+7
| | | | | | | A recent change made this print the wrong value, breaking some tests. This is now fixed. llvm-svn: 319862
* Teach llvm-pdbutil to dump types from object files.Zachary Turner2017-12-052-22/+80
| | | | llvm-svn: 319859
* Split TypeTableBuilder into two classes.Zachary Turner2017-11-301-4/+5
| | | | llvm-svn: 319456
* Make TypeTableBuilder inherit from TypeCollection.Zachary Turner2017-11-291-4/+4
| | | | | | | | | | | | | | 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. llvm-svn: 319345
* Fix line endings in llvm-pdbutil.cppZachary Turner2017-11-291-11/+11
| | | | llvm-svn: 319340
* [CodeView] Refactor / Rewrite TypeSerializer and TypeTableBuilder.Zachary Turner2017-11-282-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 319198
* Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman2017-11-031-14/+11
| | | | | | of it in some cases where it is a more clear alternative to std::for_each. llvm-svn: 317356
* [PDB] Handle an empty globals hash table with no bucketsReid Kleckner2017-10-271-2/+4
| | | | llvm-svn: 316722
* [codeview] Fix handling of S_HEAPALLOCSITEReid Kleckner2017-10-241-1/+1
| | | | | | | | | | 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. llvm-svn: 316461
* Fix -Wcovered-switch-default warnings from r314821Hans Wennborg2017-10-031-2/+1
| | | | llvm-svn: 314826
* CodeView: Provide a .def file with the register idsHans Wennborg2017-10-031-50/+5
| | | | | | | | | | | | | | 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 llvm-svn: 314821
* COFF: PDB: Allow multiple modules with the same name.Peter Collingbourne2017-09-071-1/+1
| | | | | | | | | | 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 llvm-svn: 312744
* [llvm-pdbutil] Remove unused variables.Zachary Turner2017-09-021-2/+2
| | | | llvm-svn: 312395
* Fix broken test.Zachary Turner2017-09-011-2/+6
| | | | llvm-svn: 312359
* [llvm-pdbutil] Support dumping CodeView from object files.Zachary Turner2017-09-018-334/+988
| | | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 312358
* Fix some size_t / uint32_t mismatched comparisons.Zachary Turner2017-08-311-4/+4
| | | | llvm-svn: 312278
* [llvm-pdbutil] Print detailed S_UDT stats.Zachary Turner2017-08-317-33/+197
| | | | | | | | | | | | | | 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. llvm-svn: 312276
* Remove llvm-pdbutil/fuzzer.George Karpenkov2017-08-233-124/+0
| | | | | | | | The code does not compile, is not maintained, and does not have a buildbot. Differential Revision: https://reviews.llvm.org/D37032 llvm-svn: 311512
* [llvm-pdbutil] Add support for dumping detailed module stats.Zachary Turner2017-08-2112-138/+398
| | | | | | | | | | | | | | | 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. llvm-svn: 311338
* Remove useless default case in switchVictor Leschuk2017-08-181-3/+0
| | | | llvm-svn: 311149
* Fix warning about covered switch default.Zachary Turner2017-08-171-1/+1
| | | | llvm-svn: 311129
* [llvm-pdbutil] Fix some dumping issues.Zachary Turner2017-08-171-6/+7
| | | | | | | | | | | | | | | | | 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". llvm-svn: 311117
* Fix a few minor issues when dumping symbols.Zachary Turner2017-08-172-1/+7
| | | | | | | | | | | | 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. llvm-svn: 311116
* Output S_SECTION symbols to the Linker module.Zachary Turner2017-08-114-73/+108
| | | | | | | | | | | | | | 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. llvm-svn: 310754
* [PDB] Fix an issue writing the publics stream.Zachary Turner2017-08-091-18/+37
| | | | | | | | | | | | | 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. llvm-svn: 310439
* [PDB] Fix linking of function symbols and local variables.Zachary Turner2017-08-083-7/+38
| | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 310394
* [llvm-pdbutil] Don't crash when a section contrib's isect is invalid.Zachary Turner2017-08-071-2/+6
| | | | llvm-svn: 310298
* Enable llvm-pdbutil to list enumerations using native PDB readerAdrian McCarthy2017-08-041-14/+18
| | | | | | | | | | | | | | | 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 llvm-svn: 310144
* [pdbutil] When dumping section contribs, show the section name.Zachary Turner2017-08-041-40/+75
| | | | llvm-svn: 310128
* [llvm-pdbutil] Dump image section headers.Zachary Turner2017-08-044-7/+96
| | | | | | | | | | 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 llvm-svn: 310107
* [llvm-pdbutil] Add an option to only dump specific module indices.Zachary Turner2017-08-033-45/+56
| | | | | | | | | 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. llvm-svn: 310000
* [llvm-pdbutil] Allow diff to force module equivalencies.Zachary Turner2017-08-033-21/+83
| | | | | | | | | | | 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. llvm-svn: 309983
* [pdbutil] Add a command to dump the FPM.Zachary Turner2017-08-026-1/+43
| | | | | | | | | | | | | | 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. llvm-svn: 309894
* [llvm-pdbutil] Clean up ExitOnError usage to add ": " to our errorsReid Kleckner2017-07-271-12/+12
| | | | | | | | | 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 llvm-svn: 309332
* [PDB] Improve GSI hash table dumping for publics and globalsReid Kleckner2017-07-264-38/+85
| | | | | | | | | | | | | | | 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. llvm-svn: 309066
* [codeview] Emit 'D' as the cv source language for D codeReid Kleckner2017-07-241-0/+1
| | | | | | | | | This matches DMD: https://github.com/dlang/dmd/blob/522263965cf3a27ed16b31f3c3562db86cdeabec/src/ddmd/backend/cv8.c#L199 Fixes PR33899. llvm-svn: 308890
* [PDB] Dump extra info about the publics streamReid Kleckner2017-07-213-0/+50
| | | | | | | | | | 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. llvm-svn: 308764
* [COFF, ARM64, CodeView] Add support to emit CodeView debug info for ARM64 COFFMandeep Singh Grang2017-07-201-0/+1
| | | | | | | | | | | | 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 llvm-svn: 308665
* [PDB] Finish and simplify TPI hashingReid Kleckner2017-07-183-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 308240
* [codeview] Fix YAML for LF_TYPESERVER2 by hoisting PDB_UniqueIdReid Kleckner2017-07-173-38/+2
| | | | | | | | | | | | | | | | | | 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 llvm-svn: 308234
* [codeview] Remove TypeServerHandler and PDBTypeServerHandlerReid Kleckner2017-07-171-2/+2
| | | | | | | | | | | | | | | | | 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 llvm-svn: 308212
* [CodeView] Dump BuildInfoSym and ProcSym type indicesReid Kleckner2017-07-151-2/+3
| | | | | | | I need to print the type index in hex so that I can match it in FileCheck for a test I'm writing. llvm-svn: 308107
* Resubmit "Add pdb-diff test."Zachary Turner2017-07-107-147/+289
| | | | | | | | | | | | | | | | | | | | | | | | 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). llvm-svn: 307571
OpenPOWER on IntegriCloud