summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-dwp/llvm-dwp.cpp
Commit message (Collapse)AuthorAgeFilesLines
* MC: Change the streamer ctors to take an object writer instead of a stream. ↵Peter Collingbourne2018-05-181-3/+4
| | | | | | | | | | | | | | NFCI. The idea is that a client that wants split dwarf would create a specific kind of object writer that creates two files, and use it to create the streamer. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47050 llvm-svn: 332749
* [llvm-dwp] Define InitLLVM.Fangrui Song2018-05-061-0/+2
| | | | llvm-svn: 331610
* Rename *CommandFlags.def to *CommandFlags.incDavid Blaikie2018-04-111-1/+1
| | | | | | | | These aren't the .def style files used in LLVM that require a macro defined before their inclusion - they're just basic non-modular includes to stamp out command line flag variables. llvm-svn: 329840
* DWARF: Unify form size handling codePavel Labath2018-03-141-1/+1
| | | | | | | | | | | | | | | | | Summary: This patch replaces the two switches which are deducing the size of various forms with a single implementation. I have put the new implementation into BinaryFormat, to avoid introducing dependencies between the two independent libraries (DebugInfo and CodeGen) that need this functionality. Reviewers: aprantl, JDevlieghere, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44418 llvm-svn: 327486
* Thread MCSubtargetInfo through Target::createMCAsmBackendAlex Bradbury2018-01-031-6/+6
| | | | | | | | | | | | | | | | | | | | | Currently it's not possible to access MCSubtargetInfo from a TgtMCAsmBackend. D20830 threaded an MCSubtargetInfo reference through MCAsmBackend::relaxInstruction, but this isn't the only function that would benefit from access. This patch removes the Triple and CPUString arguments from createMCAsmBackend and replaces them with MCSubtargetInfo. This patch just changes the interface without making any intentional functional changes. Once in, several cleanups are possible: * Get rid of the awkward MCSubtargetInfo handling in ARMAsmBackend * Support 16-bit instructions when valid in MipsAsmBackend::writeNopData * Get rid of the CPU string parsing in X86AsmBackend and just use a SubtargetFeature for HasNopl * Emit 16-bit nops in RISCVAsmBackend::writeNopData if the compressed instruction set extension is enabled (see D41221) This change initially exposed PR35686, which has since been resolved in r321026. Differential Revision: https://reviews.llvm.org/D41349 llvm-svn: 321692
* Remove redundant includes from tools.Michael Zolotukhin2017-12-131-9/+0
| | | | llvm-svn: 320631
* Rename MCTargetOptionsCommandFlags.h to .def as it is not a normal/modular ↵David Blaikie2017-11-271-1/+1
| | | | | | header as much as it is for stamping out some global/static variables llvm-svn: 319086
* [MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames2017-10-111-2/+4
| | | | | | | | MCObjectStreamer owns its MCCodeEmitter -- this fixes the types to reflect that, and allows us to remove the last instance of MCObjectStreamer's weird "holding ownership via someone else's reference" trick. llvm-svn: 315531
* [MC] Have MCObjectStreamer take its MCAsmBackend argument via unique_ptr.Lang Hames2017-10-111-2/+3
| | | | | | | | MCObjectStreamer owns its MCAsmBackend -- this fixes the types to reflect that, and allows us to remove another instance of MCObjectStreamer's weird "holding ownership via someone else's reference" trick. llvm-svn: 315410
* [llvm-dwp] Implement -e optionAlexander Shaposhnikov2017-09-021-3/+51
| | | | | | | | | | | | | | | The binutils utility dwp has an option "-e" https://gcc.gnu.org/wiki/DebugFissionDWP to specify an executable/library to get the list of *.dwo files from it. This option is particularly useful when someone runs the tool manually outside of a build system. This diff adds an implementation of "-e" to llvm-dwp. Test plan: make check-all Differential revision: https://reviews.llvm.org/D37371 llvm-svn: 312409
* Don't pass the code model to MCRafael Espindola2017-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I was surprised to see the code model being passed to MC. After all, it assembles code, it doesn't create it. The one place it is used is in the expansion of .cfi directives to handle .eh_frame being more that 2gb away from the code. As far as I can tell, gnu assembler doesn't even have an option to enable this. Compiling a c file with gcc -mcmodel=large produces a regular looking .eh_frame. This is probably because in practice linker parse and recreate .eh_frames. In llvm this is used because the JIT can place the code and .eh_frame very far apart. Ideally we would fix the jit and delete this option. This is hard. Apart from confusion another problem with the current interface is that most callers pass CodeModel::Default, which is bad since MC has no way to map it to the target default if it actually needed to. This patch then replaces the argument with a boolean with a default value. The vast majority of users don't ever need to look at it. In fact, only CodeGen and llvm-mc use it and llvm-mc just to enable more testing. llvm-svn: 309884
* [DWARF] NFC: Collect info used by DWARFFormValue into a helper.Paul Robinson2017-06-261-2/+2
| | | | | | | | | | | Some forms have sizes that depend on the DWARF version, DWARF format (32/64-bit), or the size of an address. Collect these into a struct to simplify passing them around. Require callers to provide one when they query a form's size. Differential Revision: http://reviews.llvm.org/D34570 llvm-svn: 306315
* [lib/Object] - Minor API update for llvm::Decompressor.George Rimar2017-05-181-1/+1
| | | | | | | | | | | | | | | | | I revisited Decompressor API (issue with it was triggered during D32865 review) and found it is probably provides more then we really need. Issue was about next method's signature: Error decompress(SmallString<32> &Out); It is too strict. At first I wanted to change it to decompress(SmallVectorImpl<char> &Out), but then found it is still not flexible because sticks to SmallVector. During reviews was suggested to use templating to simplify code. Patch do that. Differential revision: https://reviews.llvm.org/D33200 llvm-svn: 303331
* [llvm-dwp] - Reuse object::Decompressor classGeorge Rimar2017-01-131-31/+24
| | | | | | | | One more place where Decompressor class can be reused. Differential revision: https://reviews.llvm.org/D28679 llvm-svn: 291906
* Clean up DWARFFormValue by reducing duplicated code and removing ↵Greg Clayton2016-11-111-2/+10
| | | | | | | | | | | | | | | | | | | | | DWARFFormValue::getFixedFormSizes() In preparation for a follow on patch that improves DWARF parsing speed, clean up DWARFFormValue so that we have can get the fixed byte size of a form value given a DWARFUnit or given the version, address byte size and dwarf32/64. This patch cleans up code so that everyone is using one of the new DWARFFormValue functions: static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFUnit *U = nullptr); static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version, uint8_t AddrSize, bool Dwarf32); This patch changes DWARFFormValue::skipValue() to rely on the output of DWARFFormValue::getFixedByteSize(...) instead of duplicating the code in each function. This will reduce the number of changes we need to make to DWARF to fewer places in DWARFFormValue when we add support for new form. This patch also starts to support DWARF64 so that we can get correct byte sizes for forms that vary according the DWARF 32/64. To reduce the code duplication a new FormSizeHelper pure virtual class was created that can be created as a FormSizeHelperDWARFUnit when you have a DWARFUnit, or FormSizeHelperManual where you manually specify the DWARF version, address byte size and DWARF32/DWARF64. There is now a single implementation of a function that gets the fixed byte size (instead of two where one took a DWARFUnit and one took the DWARF version, address byte size and DWARFFormat enum) and one function to skip the form values. https://reviews.llvm.org/D26526 llvm-svn: 286597
* Make the Error class constructor protectedMehdi Amini2016-11-111-7/+7
| | | | | | | | | This is forcing to use Error::success(), which is in a wide majority of cases a lot more readable. Differential Revision: https://reviews.llvm.org/D26481 llvm-svn: 286561
* Switch all DWARF variables for tags, attributes and forms over to use the ↵Greg Clayton2016-10-271-5/+5
| | | | | | | | llvm::dwarf enumerations instead of using raw uint16_t values. This allows easier debugging as users can see the values of the enumerations in the variables view that will show the enumeration string instead of just a number. https://reviews.llvm.org/D26013 llvm-svn: 285309
* MC] Provide an MCTargetOptions to implementors of MCAsmBackendCtorTy, NFCJoel Jones2016-07-251-1/+2
| | | | | | | | | | | | | | | Some targets, notably AArch64 for ILP32, have different relocation encodings based upon the ABI. This is an enabling change, so a future patch can use the ABIName from MCTargetOptions to chose which relocations to use. Tested using check-llvm. The corresponding change to clang is in: http://reviews.llvm.org/D16538 Patch by: Joel Jones Differential Revision: https://reviews.llvm.org/D16213 llvm-svn: 276654
* llvm-dwp: Ensure uncompressed sections are not relocated during processing ↵David Blaikie2016-05-251-3/+4
| | | | | | | | | | | | | | | | | | | | of later inputs Richard Smith identified this in post commit review of r270466. The string sections in particular (in the future, possibly all sections - so I'm not going to bother pulling out just the string sections for the extra lifetime handling right now) need to remain valid during processing of all inputs so that elements of the DWPStringPool can be looked up repeatedly without having to make in-memory copies of string contents in the noncompressed case (more common in dwp+dwp merge steps where the memory is a bigger problem because the files are larger). Using the SmallVector (or any vector) a reallocation on push_back could cause any of the nested SmallStrings in small mode to move in memory and invalid pointers to their contents. Using a deque the SmallStrings will never move around since no elements are removed from the container. llvm-svn: 270797
* llvm-dwp: Reduce indentationDavid Blaikie2016-05-231-48/+47
| | | | llvm-svn: 270507
* llvm-dwp: Split out processing of input sections to improve readabilityDavid Blaikie2016-05-231-61/+84
| | | | llvm-svn: 270503
* llvm-dwp: Pull out compression handling helperDavid Blaikie2016-05-231-15/+22
| | | | llvm-svn: 270496
* llvm-dwp: More error handling around invalid compressed sectionsDavid Blaikie2016-05-231-7/+4
| | | | llvm-svn: 270466
* llvm-dwp: Ensure compressed sections are preserved long enough for use in ↵David Blaikie2016-05-231-2/+2
| | | | | | | | | | | | | | | | the string pool Now that the string pool is referential rather than maintaining its own copy of string data, compressed sections (well, technically only the debug_str section*) need to be preserved for the lifetime of the pool to match. * I'm not currently optimizing for memory footprint with compressed input - the major memory limit I'm hitting is on dwp+dwp merge steps and we aren't currently compressing contents in dwp files, just in the .dwo inputs. llvm-svn: 270462
* llvm-dwp: Add an abstraction for the DWP string poolDavid Blaikie2016-05-231-30/+28
| | | | | | | Also reference strings in the memory mapped file, reduces memory usage on a large test case by 18.5%. llvm-svn: 270449
* Don't pass a Reloc::Model to MC.Rafael Espindola2016-05-181-1/+1
| | | | | | | | | | | | MC only needs to know if the output is PIC or not. It never has to decide about creating GOTs and PLTs for example. The only thing that MC itself uses this information for is expanding "macros" in sparc and mips. The rest I am pretty sure could be moved to CodeGen. This is a cleanup and isolates the code from future changes to Reloc::Model. llvm-svn: 269909
* llvm-dwp: remove some unused error handlingDavid Blaikie2016-05-171-8/+5
| | | | llvm-svn: 269866
* llvm-dwp: Move error handling code closer to useDavid Blaikie2016-05-171-6/+6
| | | | llvm-svn: 269864
* llvm-dwp: Add error handling for multiple type sections in a dwp file.David Blaikie2016-05-171-1/+3
| | | | llvm-svn: 269851
* llvm-dwp: Simplify duplicate DWO ID error handlingDavid Blaikie2016-05-171-9/+9
| | | | llvm-svn: 269805
* llvm-dwp: Provide error handling for invalid string field formsDavid Blaikie2016-05-171-8/+16
| | | | | | | | | | This diagnostic could be improved by adding the name of the input file containing the invalid data and/or some information about how to identify the specific offending attribute/tag in the input. But that's not an immediate priority as these corner cases of invalid input shouldn't come up too often. llvm-svn: 269727
* llvm-dwp: Add error handling for invalid (non-CU) top level tag in ↵David Blaikie2016-05-161-8/+14
| | | | | | | | | | debug_info.dwo The diagnostic could be improved a bit to include information about which input file had the mistake (& which unit (counted, since the name of the unit won't be accessible) within the input). llvm-svn: 269723
* llvm-dwp: Streamline duplicate DWO ID diagnostic handlingDavid Blaikie2016-05-161-24/+27
| | | | | | | | Actually use the error return path rather than printing the duplicate information then a separate error. But also just tidy up/deduplicate some of the code for generating the diagnostic text. llvm-svn: 269692
* llvm-dwp: Use llvm::Error to improve diagnostic quality/error handling in ↵David Blaikie2016-05-121-20/+24
| | | | | | llvm-dwp llvm-svn: 269339
* [NFC] Header cleanupMehdi Amini2016-04-181-2/+0
| | | | | | | | | | | | | | Removed some unused headers, replaced some headers with forward class declarations. Found using simple scripts like this one: clear && ack --cpp -l '#include "llvm/ADT/IndexedMap.h"' | xargs grep -L 'IndexedMap[<]' | xargs grep -n --color=auto 'IndexedMap' Patch by Eugene Kosov <claprix@yandex.ru> Differential Revision: http://reviews.llvm.org/D19219 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266595
* llvm-dwp: Add assert textDavid Blaikie2016-04-131-1/+3
| | | | | | Post-commit feedback from Eric Christopher on r265452. llvm-svn: 266225
* Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby2016-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to produce a real error message Produce the first specific error message for a malformed Mach-O file describing the problem instead of the generic message for object_error::parse_failed of "Invalid data was encountered while parsing the file”.  Many more good error messages will follow after this first one. This is built on Lang Hames’ great work of adding the ’Error' class for structured error handling and threading Error through MachOObjectFile construction. And making createMachOObjectFile return Expected<...> . So to to get the error to the llvm-obdump tool, I changed the stack of these methods to also return Expected<...> : object::ObjectFile::createObjectFile() object::SymbolicFile::createSymbolicFile() object::createBinary() Then finally in ParseInputMachO() in MachODump.cpp the error can be reported and the specific error message can be printed in llvm-objdump and can be seen in the existing test case for the existing malformed binary but with the updated error message. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now use of errorToErrorCode() and errorOrToExpected() are used where the callers are yet to be converted. 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(ObjOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there is one fix also needed to lld/COFF/InputFiles.cpp 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: 265606
* llvm-dwp: Handle GCC's use of multiple debug_types.dwo sections in a single ↵David Blaikie2016-04-051-31/+32
| | | | | | | | .dwo file (also includes the .test file missing from my previous commit, r265452) llvm-svn: 265457
* llvm-dwp: Handle dwo files produced by GCCDavid Blaikie2016-04-051-4/+8
| | | | | | | To start with, handle DW_FORM_string names. Follow up commit will handle the interesting quirk with type units I was originally aiming for here. llvm-svn: 265452
* llvm-dwp: Simplify hashing code a bitDavid Blaikie2016-04-051-1/+2
| | | | llvm-svn: 265426
* llvm-dwp: Include the dwo name (if available) when diagnosing duplicate CU ↵David Blaikie2016-03-261-20/+41
| | | | | | | | | | | | IDs from dwp input files If you're building dwps from other dwps, it can be hard to track down a duplicate CU ID if it comes from two compilations of the same file in different modes, etc. By including the .dwo path (which is hopefully more unique than the file path) it can help track down where the duplicates came from. llvm-svn: 264520
* llvm-dwp: Coalesce code for reading the CU's DW_AT_GNU_dwo_id and DW_AT_nameDavid Blaikie2016-03-241-51/+36
| | | | | | | | Going to be reading the DW_AT_GNU_dwo_name shortly as well, and there was already enough duplication here that it was worth refactoring rather than adding even more. llvm-svn: 264350
* llvm-dwp: Add missing copyright notice to llvm-dwp.cppDavid Blaikie2016-03-011-0/+13
| | | | | | Addressing feedback on IRC by Sean Silva. llvm-svn: 262416
* Revert "llvm-dwp: Keep ObjectFiles alive until object emission their ↵David Blaikie2016-03-011-10/+8
| | | | | | | | | | contents can be referenced directly rather than copied" Accidentally committed. This reverts commit r262389. llvm-svn: 262395
* llvm-dwp: Keep ObjectFiles alive until object emission their contents can be ↵David Blaikie2016-03-011-8/+10
| | | | | | referenced directly rather than copied llvm-svn: 262389
* llvm-dwp: provide diagnostics for duplicate DWO IDsDavid Blaikie2016-02-261-3/+75
| | | | | | | | | | | | | | These diagnostics aren't perfect - in the case of merging several dwos into dwps and those dwps into more dwps - just getting the message about the original source file name might not be much help (since it's the same in both dwos, by definition - but doesn't tell you which chain of dwps to backtrack) It might be worth adding the DW_AT_dwo_id to the split debug info to improve the diagnostic experience - might help track down the duplicates better. llvm-svn: 261988
* llvm-dwp: Support empty .dwo filesDavid Blaikie2016-02-261-9/+11
| | | | | | | | | Though a bit odd, this is handy for a few reasons - for example, in a build system that wants consistent input/output of build steps, but where split-dwarf might be overriden/disabled by the user on a per-file basis. llvm-svn: 261987
* llvm-dwp: Improve performance (N^2 to amortized N) by using a MapVector ↵David Blaikie2016-02-191-39/+35
| | | | | | | | | | | | | | | instead of linear searches through a vector Figured this would be a problem, but didn't want to jump the gun - large inputs demonstrate it pretty easily (mostly for type units, but might as well do the same for CUs too). A random sample 6m27s -> 27s change. Also, by checking this up-front for CUs (rather than when building the cu_index) we can probably provide better error messages (see FIXMEs), hopefully providing the name of the CUs rather than just their signature. llvm-svn: 261364
* llvm-dwp: Don't test compression when zlib isn't availableDavid Blaikie2016-02-191-1/+1
| | | | llvm-svn: 261298
* llvm-dwp: Support compressed inputDavid Blaikie2016-02-191-5/+45
| | | | llvm-svn: 261296
OpenPOWER on IntegriCloud