summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-readobj/COFFDumper.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Delete some dead code.Rafael Espindola2016-06-211-16/+0
| | | | | | Found by gcc 6. llvm-svn: 273303
* Resubmit "[pdb] Change type visitor pattern to be dynamic."Zachary Turner2016-06-161-4/+4
| | | | | | | There was a regression introduced during type stream merging when visiting a field list record. This has been fixed in this patch. llvm-svn: 272929
* Revert "[pdb] Change type visitor pattern to be dynamic."Zachary Turner2016-06-161-2/+2
| | | | | | | | This reverts commit fb0dd311e1ad945827b8ffd5354f4810e2be1579. This breaks some llvm-readobj tests. llvm-svn: 272927
* [pdb] Change type visitor pattern to be dynamic.Zachary Turner2016-06-161-2/+2
| | | | | | | | | | | | | | | This allows better catching of compiler errors since we can use the override keyword to verify that methods are actually overridden. Also in this patch I've changed from storing a boolean Error code everywhere to returning an llvm::Error, to propagate richer error information up the call stack. Reviewed By: ruiu, rnk Differential Revision: http://reviews.llvm.org/D21410 llvm-svn: 272926
* Add support for writing through StreamInterface.Zachary Turner2016-06-101-2/+2
| | | | | | | | | | | This adds method and tests for writing to a PDB stream. With this, even a PDB stream which is discontiguous can be treated as a sequential stream of bytes for the purposes of writing. Reviewed By: ruiu Differential Revision: http://reviews.llvm.org/D21157 llvm-svn: 272369
* [codeview] Dump line number and column information.Zachary Turner2016-06-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | To facilitate this, a couple of changes had to be made: 1. `ModuleSubstream` got moved from `DebugInfo/PDB` to `DebugInfo/CodeView`, and various codeview related types are defined there. It turns out `DebugInfo/CodeView/Line.h` already defines many of these structures, but this is really old code that is not endian aware, doesn't interact well with `StreamInterface` and not very helpful for getting stuff out of a PDB. Eventually we should migrate the old readobj `COFFDumper` code to these new structures, or at least merge their functionality somehow. 2. A `ModuleSubstream` visitor is introduced. Depending on where your module substream array comes from, different subsets of record types can be expected. We are already hand parsing these substream arrays in many places especially in `COFFDumper.cpp`. In the future we can migrate these paths to the visitor as well, which should reduce a lot of code in `COFFDumper.cpp`. Differential Revision: http://reviews.llvm.org/D20936 Reviewed By: ruiu, majnemer llvm-svn: 271621
* Rename IMAGE_DEBUG_TYPE_NO_TIMESTAMP to IMAGE_DEBUG_TYPE_REPRODavid Majnemer2016-06-021-1/+2
| | | | | | This matches the COFF spec llvm-svn: 271549
* [COFF] Expose the PE debug data directory and dump itReid Kleckner2016-06-021-1/+55
| | | | | | | | | | | | This directory is used to find if there is a PDB associated with an executable. I plan to use this functionality to teach llvm-symbolizer whether it should use DIA or DWARF to symbolize a given DLL. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D20885 llvm-svn: 271539
* [codeview] Improve readability of type record assemblyReid Kleckner2016-05-311-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds the method MCStreamer::EmitBinaryData, which is usually an alias for EmitBytes. In the MCAsmStreamer case, it is overridden to emit hex dump output like this: .byte 0x0e, 0x00, 0x08, 0x10 .byte 0x03, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x10, 0x00, 0x00 Also, when verbose asm comments are enabled, this patch prints the dump output for each comment before its record, like this: # ArgList (0x1000) { # TypeLeafKind: LF_ARGLIST (0x1201) # NumArgs: 0 # Arguments [ # ] # } .byte 0x06, 0x00, 0x01, 0x12 .byte 0x00, 0x00, 0x00, 0x00 This should make debugging easier and testing more convenient. Reviewers: aaboud Subscribers: majnemer, zturner, amccarth, aaboud, llvm-commits Differential Revision: http://reviews.llvm.org/D20711 llvm-svn: 271313
* [codeview] Add a CVTypeDumper::dump(ArrayRef<uint8_t>) overloadReid Kleckner2016-05-311-24/+2
| | | | | | | This is a convenient wrapper when the type record is already laid out as bytes in memory. llvm-svn: 271309
* Don't dereference a symbol iterator before checking for the end caseDavid Majnemer2016-05-291-3/+7
| | | | llvm-svn: 271173
* [COFFDumper] Validate that the next offset is not too largeDavid Majnemer2016-05-281-0/+2
| | | | llvm-svn: 271147
* [COFFDumper] Make sure there is sufficient padding left in the string tableDavid Majnemer2016-05-281-1/+4
| | | | llvm-svn: 271146
* [COFFDumper] Make sure there is sufficient padding left in the checksumDavid Majnemer2016-05-281-0/+2
| | | | llvm-svn: 271143
* [llvm-readobj] Validate the string table offset before using itDavid Majnemer2016-05-281-2/+8
| | | | llvm-svn: 271139
* Use consume instead of manually using drop_frontDavid Majnemer2016-05-281-2/+2
| | | | llvm-svn: 271137
* [pdb] Finish conversion to zero copy pdb access.Zachary Turner2016-05-281-5/+40
| | | | | | | | | | | | | | This converts remaining uses of ByteStream, which was still left in the symbol stream and type stream, to using the new StreamInterface zero-copy classes. RecordIterator is finally deleted, so this is the only way left now. Additionally, more error checking is added when iterating the various streams. With this, the transition to zero copy pdb access is complete. llvm-svn: 271101
* Remove unused global variable.Zachary Turner2016-05-241-11/+0
| | | | llvm-svn: 270610
* Remove unused variable breaking -Werror builds.Zachary Turner2016-05-241-2/+1
| | | | llvm-svn: 270529
* Make a symbol visitor and use it to dump CV symbols.Zachary Turner2016-05-231-732/+51
| | | | | | | Differential Revision: http://reviews.llvm.org/D20534 Reviewed By: rnk llvm-svn: 270511
* [codeview] Refactor symbol records to use same pattern as types.Zachary Turner2016-05-231-274/+325
| | | | | | | | | | | This will pave the way to introduce a full fledged symbol visitor similar to how we have a type visitor, thus allowing the same dumping code to be used in llvm-readobj and llvm-pdbdump. Differential Revision: http://reviews.llvm.org/D20384 Reviewed By: rnk llvm-svn: 270475
* Delete default in fully covered switch.Rafael Espindola2016-05-181-1/+0
| | | | llvm-svn: 269872
* [codeview] Some cleanup of Symbol Records.Zachary Turner2016-05-171-62/+63
| | | | | | | | | | | | | | * Reworks the CVSymbolTypes.def to work similarly to TypeRecords.def. * Moves some enums from SymbolRecords.h to CodeView.h to maintain consistency with how we do type records. * Generalize a few simple things like the record prefix * Define the leaf enum and the kind enum similar to how we do with tyep records. Differential Revision: http://reviews.llvm.org/D20342 Reviewed By: amccarth, rnk llvm-svn: 269867
* [codeview] Add type stream merging prototypeReid Kleckner2016-05-141-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This code is intended to be used as part of LLD's PDB writing. Until that exists, this is exposed via llvm-readobj for testing purposes. Type stream merging uses the following algorithm: - Begin with a new empty stream, and a new empty hash table that maps from type record contents to new type index. - For each new type stream, maintain a map from source type index to destination type index. - For each record, copy it and rewrite its type indices to be valid in the destination type stream. - If the new type record is not already present in the destination stream hash table, append it to the destination type stream, assign it the next type index, and update the two hash tables. - If the type record already exists in the destination stream, discard it and update the type index map to forward the source type index to the existing destination type index. Reviewers: zturner, ruiu Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D20122 llvm-svn: 269521
* Make CodeView record serialization more generic.Zachary Turner2016-05-121-12/+13
| | | | | | | | | | | This introduces a variadic template and some helper macros to safely and correctly deserialize many types of common record fields while maintaining error checking. Differential Revision: http://reviews.llvm.org/D20183 Reviewed By: rnk, amccarth llvm-svn: 269315
* [codeview] Move dumper into lib/DebugInfo/CodeViewReid Kleckner2016-05-051-811/+8
| | | | | | So that we can call it from llvm-pdbdump. llvm-svn: 268580
* [codeview] Add a type visitor to help abstract away type stream handlingReid Kleckner2016-05-041-485/+448
| | | | | | | | | | | | | | | | | | Summary: Port the dumper in llvm-readobj over to it. I'm planning to use this visitor to power type stream merging. While we're at it, try to switch from StringRef to ArrayRef<uint8_t> in some places. Reviewers: zturner, amccarth Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D19899 llvm-svn: 268535
* Move CodeViewTypeStream to DebugInfo/CodeViewZachary Turner2016-05-031-137/+14
| | | | | | | | | | | | | Ability to parse codeview type streams is also needed by DebugInfoPDB for parsing PDBs, so moving this into a library gives us this option. Since DebugInfoPDB had already hand rolled some code to do this, that code is now convereted over to using this common abstraction. Differential Revision: http://reviews.llvm.org/D19887 Reviewed By: dblaikie, amccarth llvm-svn: 268454
* [codeview] Maintain the type enum-to-classname mapping in the .def fileReid Kleckner2016-05-031-23/+5
| | | | | | This way it will be easy to stamp out something like a type visitor. llvm-svn: 268347
* Move llvm-readobj/StreamWriter to Support.Zachary Turner2016-05-031-7/+7
| | | | | | | | | We wish to re-use this from llvm-pdbdump, and it provides a nice way to print structured data in scoped format that could prove useful for many other dumping tools as well. Moving to support and changing name to ScopedPrinter to better reflect its purpose. llvm-svn: 268342
* NFC: An iterator for stepping through CodeView type stream in llvm-readobjAdrian McCarthy2016-05-021-39/+125
| | | | | | | | | | | | This is a small refactoring step toward moving CodeView type stream logic from llvm-readobj to a library. It abstracts the logic of stepping through the stream into an iterator class and updates llvm-readobj to use that iterator. This has no functional change; llvm-readobj produces identical output. The next step is to abstract the parsing of the different leaf types and then move that and the iterator into a library. Since this is my first contrib outside LLDB, please let me know if I'm messing up on any of the LLVM style guidelines, idioms, or patterns. Differential Revision: http://reviews.llvm.org/D19746 llvm-svn: 268334
* [codeview] Isolate type dumping from object file stateReid Kleckner2016-05-021-18/+38
| | | | | | | | | | | | | | This isolates the state we use for type dumping from the knowledge of object files. We can use CVTypeDumper to dump types from anywhere in memory now. NFC Reviewers: zturner Differential Revision: http://reviews.llvm.org/D19824 llvm-svn: 268300
* [codeview] Don't dump type stream bytes unless asked toReid Kleckner2016-05-021-1/+2
| | | | llvm-svn: 268271
* Thread Expected<...> up from libObject’s getName() for symbols to allow ↵Kevin Enderby2016-04-201-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | llvm-objdump to produce a good error message. Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 266919
* [codeview] Dump char16_t and char32_t simple typesReid Kleckner2016-04-151-0/+2
| | | | llvm-svn: 266465
* Revert "Fix Clang-tidy modernize-deprecated-headers warnings in remaining ↵Duncan P. N. Exon Smith2016-04-051-87/+51
| | | | | | | | | | files; other minor fixes." This reverts commit r265454 since it broke the build. E.g.: http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/22413/ llvm-svn: 265459
* Fix Clang-tidy modernize-deprecated-headers warnings in remaining files; ↵Eugene Zelenko2016-04-051-51/+87
| | | | | | | | | | | | other minor fixes. Some Include What You Use suggestions were used too. Use anonymous namespaces in source files. Differential revision: http://reviews.llvm.org/D18778 llvm-svn: 265454
* [codeview] Dump def range lengths in hexReid Kleckner2016-02-111-3/+3
| | | | | | | It makes it easier to correlate with assembly dumps, which are typically given with hex offsets. llvm-svn: 260619
* [codeview] Dump a missing field and change its signednessReid Kleckner2016-02-051-0/+2
| | | | llvm-svn: 259904
* Correctly handle {Always,Never}StepIntoLineDavid Majnemer2016-02-041-8/+9
| | | | llvm-svn: 259806
* Add support for S_DEFRANGE and S_DEFRANGE_SUBFIELDDavid Majnemer2016-02-041-2/+27
| | | | llvm-svn: 259805
* Make the dumper's output for variable ranges easier to readDavid Majnemer2016-02-041-24/+14
| | | | llvm-svn: 259804
* Print the OffsetStart field's relocationDavid Majnemer2016-02-031-8/+15
| | | | llvm-svn: 259723
* [llvm-readobj] Add support for dumping S_DEFRANGE symbolsDavid Majnemer2016-02-031-1/+84
| | | | llvm-svn: 259719
* [codeview] Wire up the .cv_inline_linetable directiveReid Kleckner2016-02-021-1/+1
| | | | | | | | This directive emits the binary annotations that describe line and code deltas in inlined call sites. Single-stepping through inlined frames in windbg now works. llvm-svn: 259535
* [CodeView] Fix dumping the is_stmt bit from the line tableReid Kleckner2016-01-291-1/+1
| | | | | | Bug pointed out by George Rimar. llvm-svn: 259205
* Reland "[CodeView] Use assembler directives for line tables"Reid Kleckner2016-01-291-6/+5
| | | | | | | | This reverts commit r259126 and relands r259117. This time with updated library dependencies. llvm-svn: 259130
* Revert "[CodeView] Use assembler directives for line tables"Reid Kleckner2016-01-291-5/+6
| | | | | | | | | This reverts commit r259117. The LineInfo constructor is defined in the codeview library and we have to link against it now. Doing that isn't trivial, so reverting for now. llvm-svn: 259126
* [CodeView] Use assembler directives for line tablesReid Kleckner2016-01-281-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a new family of .cv_* directives to LLVM's variant of GAS syntax: - .cv_file: Similar to DWARF .file directives - .cv_loc: Similar to the DWARF .loc directive, but starts with a function id. CodeView line tables are emitted by function instead of by compilation unit, so we needed an extra field to communicate this. Rather than overloading the .loc direction further, we decided it was better to have our own directive. - .cv_stringtable: Emits the codeview string table at the current position. Currently this just contains the filenames as null-terminated strings. - .cv_filechecksums: Emits the file checksum table for all files used with .cv_file so far. There is currently no support for emitting actual checksums, just filenames. This moves the line table emission code down into the assembler. This is in preparation for implementing the inlined call site line table format. The inline line table format encoding algorithm requires knowing the absolute code offsets, so it must run after the assembler has laid out the code. David Majnemer collaborated on this patch. llvm-svn: 259117
* [readobj] Print CodeOffset first, it's easier to readReid Kleckner2016-01-201-5/+5
| | | | llvm-svn: 258368
OpenPOWER on IntegriCloud