summaryrefslogtreecommitdiffstats
path: root/llvm/tools/dsymutil/DwarfLinker.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [DWARF] Unify warning callbacks. NFC.Victor Leschuk2018-08-231-2/+2
| | | | | | | | | | | | | | | | | Both DWARFDebugLine and DWARFDebugAddr used the same callback mechanism for handling recoverable errors. They both implemented similar warn() function to be used as such callbacks. In this revision we get rid of code duplication and move this warn() function to DWARFContext as DWARFContext::dumpWarning(). Reviewers: lhames, jhenderson, aprantl, probinson, dblaikie, JDevlieghere Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D51033 llvm-svn: 340528
* [dsymutil] Convert recursion in lookForDIEsToKeep into worklist.Jonas Devlieghere2018-08-011-47/+113
| | | | | | | | | | | | | | | | | | | | The functions `lookForDIEsToKeep` and `keepDIEAndDependencies` can have some very deep recursion. This tackles part of this problem by removing the recursion from `lookForDIEsToKeep` by turning it into a worklist. The difficulty in doing so is the computation of incompleteness, which depends on the incompleteness of its children. To compute this, we insert "continuation markers" into the worklist. This informs the work loop to (re)compute the incompleteness property of the DIE associated with it (i.e. the parent of the previously processed DIE). This patch should generate byte-identical output. Unfortunately it also has some impact of performance, regressing by about 4% when processing clang on my machine. Differential revision: https://reviews.llvm.org/D48899 llvm-svn: 338536
* [dsymutil] Add support for generating DWARF5 accelerator tables.Jonas Devlieghere2018-07-251-11/+85
| | | | | | | | | | | | | | | | | | This patch add support for emitting DWARF5 accelerator tables (.debug_names) from dsymutil. Just as with the Apple style accelerator tables, it's possible to update existing dSYMs. This patch includes a test that show how you can convert back and forth between the two types. If no kind of table is specified, dsymutil will default to generating Apple-style accelerator tables whenever it finds those in its input. The same is true when there are no accelerator tables at all. Finally, in the remaining case, where there's at least one DWARF v5 table and no Apple ones, the output will contains a DWARF accelerator tables (.debug_names). Differential revision: https://reviews.llvm.org/D49137 llvm-svn: 337980
* [dsymutil] Add support for outputting assemblyJonas Devlieghere2018-07-091-2/+2
| | | | | | | | | | | | | When implementing the DWARF accelerator tables in dsymutil I ran into an assertion in the assembler. Debugging these kind of issues is a lot easier when looking at the assembly instead of debugging the assembler itself. Since it's only a matter of creating an AsmStreamer instead of a MCObjectStreamer it made sense to turn this into a (hidden) dsymutil feature. Differential revision: https://reviews.llvm.org/D49079 llvm-svn: 336561
* [dsymutil] Make the CachedBinaryHolder the defaultJonas Devlieghere2018-06-291-1/+1
| | | | | | | | Replaces all uses of the old binary holder with its cached variant. Differential revision: https://reviews.llvm.org/D48770 llvm-svn: 335991
* [dsymutil] Introduce a new CachedBinaryHolderJonas Devlieghere2018-06-291-18/+26
| | | | | | | | | | | | | | | | | | | | | | | | The original binary holder has an optimization where it caches a static library (archive) between consecutive calls to GetObjects. However, the actual memory buffer wasn't cached between calls. This made sense when dsymutil was processing objects one after each other, but when processing them in parallel, several binaries have to be in memory at the same time. For this reason, every link context contained a binary holder. Having one binary holder per context is problematic, because the same static archive was cached for every object file. Luckily, when the file is mmap'ed, this was only costing us virtual memory. This patch introduces a new BinaryHolder variant that is fully cached, for all the object files it load, as well as the static archives. This way, we don't have to give up on this optimization of bypassing the file system. Differential revision: https://reviews.llvm.org/D48501 llvm-svn: 335990
* [dsymutil] Use UnitListTy consistently (NFC)Jonas Devlieghere2018-06-281-16/+13
| | | | | | | Use the UnitListTy typedef consistently throughout the Dwarf linker and pass it by const reference where possible. llvm-svn: 335860
* [dsymutil] Move abstractions into separate files (NFC)Jonas Devlieghere2018-06-271-1983/+4
| | | | | | | | | | | This patch splits off some abstractions used by dsymutil's dwarf linker and moves them into separate header and implementation files. This almost halves the number of LOC in DwarfLinker.cpp and makes it a lot easier to understand what functionality lives where. Differential revision: https://reviews.llvm.org/D48647 llvm-svn: 335749
* [DWARF] Improved error reporting for range lists. Wolfgang Pieb2018-06-201-1/+5
| | | | | | | | | | | Errors found processing the DW_AT_ranges attribute are propagated by lower level routines and reported by their callers. Reviewer: JDevlieghere Differential Revision: https://reviews.llvm.org/D48344 llvm-svn: 335188
* [DWARF] Refactor callback usage for .debug_line error handlingJames Henderson2018-05-211-1/+1
| | | | | | | | | | | Change the "recoverable" error callback to take an Error instaed of a string. Reviewed by: JDevlieghere Differential Revision: https://reviews.llvm.org/D46831 llvm-svn: 332845
* 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
* [DWARF] Rework debug line parsing to use llvm::Error and callbacksJames Henderson2018-05-101-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reviewed by: dblaikie, JDevlieghere, espindola Differential Revision: https://reviews.llvm.org/D44560 Summary: The .debug_line parser previously reported errors by printing to stderr and return false. This is not particularly helpful for clients of the library code, as it prevents them from handling the errors in a manner based on the calling context. This change switches to using llvm::Error and callbacks to indicate what problems were detected during parsing, and has updated clients to handle the errors in a location-specific manner. In general, this means that they continue to do the same thing to external users. Below, I have outlined what the known behaviour changes are, relating to this change. There are two levels of "errors" in the new error mechanism, to broadly distinguish between different fail states of the parser, since not every failure will prevent parsing of the unit, or of subsequent unit. Malformed table errors that prevent reading the remainder of the table (reported by returning them) and other minor issues representing problems with parsing that do not prevent attempting to continue reading the table (reported by calling a specified callback funciton). The only example of this currently is when the last sequence of a unit is unterminated. However, I think it would be good to change the handling of unrecognised opcodes to report as minor issues as well, rather than just printing to the stream if --verbose is used (this would be a subsequent change however). I have substantially extended the DwarfGenerator to be able to handle custom-crafted .debug_line sections, allowing for comprehensive unit-testing of the parser code. For now, I am just adding unit tests to cover the basic error reporting, and positive cases, and do not currently intend to test every part of the parser, although the framework should be sufficient to do so at a later point. Known behaviour changes: - The dump function in DWARFContext now does not attempt to read subsequent tables when searching for a specific offset, if the unit length field of a table before the specified offset is a reserved value. - getOrParseLineTable now returns a useful Error if an invalid offset is encountered, rather than simply a nullptr. - The parse functions no longer use `WithColor::warning` directly to report errors, allowing LLD to call its own warning function. - The existing parse error messages have been updated to not specifically include "warning" in their message, allowing consumers to determine what severity the problem is. - If the line table version field appears to have a value less than 2, an informative error is returned, instead of just false. - If the line table unit length field uses a reserved value, an informative error is returned, instead of just false. - Dumping of .debug_line.dwo sections is now implemented the same as regular .debug_line sections. - Verbose dumping of .debug_line[.dwo] sections now prints the prologue, if there is a prologue error, just like non-verbose dumping. As a helper for the generator code, I have re-added emitInt64 to the AsmPrinter code. This previously existed, but was removed way back in r100296, presumably because it was dead at the time. This change also requires a change to LLD, which will be committed separately. llvm-svn: 331971
* [Support] Add convenience functions to WithColor. NFC.Jonas Devlieghere2018-04-141-19/+20
| | | | | | | | | Create convenience functions for printing error, warning and note to stdout. Previously we had similar functions being used in dsymutil, but given that this pattern is so common it makes sense to make it available globally. llvm-svn: 330091
* 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
* [dsymutil] Remove trailing colon. NFCJonas Devlieghere2018-04-091-2/+2
| | | | llvm-svn: 329554
* [dsymutil] Don't try to load Swift ASTs as objects.Jonas Devlieghere2018-04-091-0/+5
| | | | | | | | | | | | | | | | With the threading refactoring, loading of object files happens before checking whether we're dealing with a swift AST. While that's not an issue per se, it causes a warning to be printed: warning: /path/to/a.swiftmodule: The file was not recognized as a valid object file note: while processing /path/to/a.swiftmodule This suppresses the warning by checking for a Swift AST before attempting to load is as an object file. rdar://39240444 llvm-svn: 329553
* [dsymutil] Don't crash on empty CUJonas Devlieghere2018-04-081-1/+15
| | | | | | Add some additional checks so we don't crash on empty compile units. llvm-svn: 329537
* [dsymutil] Apply recursion workaround for threadingJonas Devlieghere2018-04-031-7/+16
| | | | | | | | | | | | The DwarfLinker can have some very deep recursion that can max out the (significantly smaller) stack when using threads. We don't want this limitation when we only have a single thread. We already have this workaround for the architecture-related threading. This patch applies the same workaround to the parallel analysis and cloning. Differential revision: https://reviews.llvm.org/D45172 llvm-svn: 329093
* [dsymutil] Upstream emitting of papertrail warnings.Jonas Devlieghere2018-04-021-1/+70
| | | | | | | | | | When running dsymutil as part of your build system, it can be desirable for warnings to be part of the end product, rather than just being emitted to the output stream. This patch upstreams that functionality. Differential revision: https://reviews.llvm.org/D44639 llvm-svn: 328965
* [tools] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. Reviewers: JDevlieghere, zturner, echristo, dberris, friss Reviewed By: echristo Subscribers: gbedwell, llvm-commits Differential Revision: https://reviews.llvm.org/D45141 llvm-svn: 328943
* Style update. NFC.Rafael Espindola2018-03-291-15/+15
| | | | | | | Rename 3 functions to start with lowercase letters. Don't repeat the name in the comments. llvm-svn: 328848
* typoAdrian Prantl2018-03-211-1/+1
| | | | llvm-svn: 328141
* [dsymutil] Unify error handling outside DwarfLinker.Jonas Devlieghere2018-03-131-17/+5
| | | | | | | | This is a follow-up to r327137 where we unified error handling for the DwarfLinker. This replaces calls to errs() and outs() with the appropriate ostream wrapper everywhere in dsymutil. llvm-svn: 327411
* [dsymutil] Remove old error/warn functions. NFC.Jonas Devlieghere2018-03-131-11/+0
| | | | | | | This removes the old error and warn functions that were still present in the dwarf linker. llvm-svn: 327400
* [dsymutil] Perform analyzeContextInfo and CloneDIEs in parallelJonas Devlieghere2018-03-131-51/+117
| | | | | | | | | | | | | | | | | | This patch makes dsymutil perform analyzeContextInfo and CloneDIEs in parallel. For the same object file, there is a dependency between the two. However, we can do analyzeContextInfo for the next object file while cloning DIEs for the current. This is exactly the approach taken in this patch. For WebCore, this leads to a performance improvement of 29% and for clang we see similar results with at 32% improvement. A big thanks to Pete Cooper who came up with the original idea and the PoC. Differential revision: https://reviews.llvm.org/D43945 llvm-svn: 327399
* [dsymutil] Unbreak non-Darwin bots.Jonas Devlieghere2018-03-131-3/+3
| | | | | | BinaryHolder -> BinHolder llvm-svn: 327384
* [dsymutil] Introduce LinkContext. NFC.Jonas Devlieghere2018-03-131-219/+336
| | | | | | | | This patch introduces the LinkContext which is necessary to have dsymutil perform analysis and cloning of DIEs in parallel. As requested in D43945, I'm landing this as two separate commits. llvm-svn: 327382
* [dsymutil] Unify error handling and add colorJonas Devlieghere2018-03-091-15/+42
| | | | | | | | | We improved the handling of errors and warnings in dwarfdump's verifier in rL314498. This patch does the same thing for dsymutil. Differential revision: https://reviews.llvm.org/D44052 llvm-svn: 327137
* [dsymutil] Move string pool into its own implementatino file. NFC.Jonas Devlieghere2018-03-011-43/+0
| | | | | | | | The DwarfLinker implementation is already relatively large with over 4k LOC. This commit moves the implementation of NonRelocatableStringpool into a separate cpp file. llvm-svn: 326425
* [dsymutil] Skip DW_AT_sibling attributes.Jonas Devlieghere2018-02-271-2/+3
| | | | | | | | | | Following DW_AT_sibling attributes completely defeats the pruning pass. Although clang doesn't generate the DW_AT_sibling attribute we should still handle it correctly. Differential revision: https://reviews.llvm.org/D43439 llvm-svn: 326231
* [dsymutil] Fix typos and formatting. NFC.Jonas Devlieghere2018-02-221-209/+194
| | | | | | | Some over-due gardening: this fixes a bunch of typos and makes the formatting consistent with LLVM's style guide. llvm-svn: 325768
* [dsymutil] Replace PATH_MAX in SmallString with fixed value.Jonas Devlieghere2018-02-221-3/+3
| | | | | | | | | | | Apparently the Windows bots don't know this define, so just going with a sensible default. Failing builds: http://lab.llvm.org:8011/builders/lldb-x86-windows-msvc2015/builds/19179 http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/19263 llvm-svn: 325762
* [dsymutil] Be smarter in caching calls to realpathJonas Devlieghere2018-02-221-17/+44
| | | | | | | | | | | | | | | | | | | Calling realpath is expensive but necessary to perform the uniqueing in dsymutil. Although we already cached the results for every individual file in the line table, we had reports of it taking 40 seconds of a 3.5 minute link. This patch adds a second level of caching. When we do have to call realpath, we cache its result for its parents path. We didn't replace the existing caching, because it's fast (indexed) and saves us from reading the line table for entries we've already seen. For WebkitCore this results in a decrease of 11% in linking time: from 85.79 to 76.11 seconds (average over 3 runs). Differential revision: https://reviews.llvm.org/D43511 llvm-svn: 325757
* [dsymutil] Correctly handle DW_TAG_labelJonas Devlieghere2018-02-201-1/+28
| | | | | | | | | This patch contains logic for handling DW_TAG_label that's present in darwin's dsymutil implementation, but not yet upstream. Differential revision: https://reviews.llvm.org/D43438 llvm-svn: 325600
* [CodeGen] Refactor AppleAccelTablePavel Labath2018-02-191-21/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit separates the abstract accelerator table data structure from the code for writing out an on-disk representation of a specific accelerator table format. The idea is that former (now called AccelTable<T>) can be reused for the DWARF v5 accelerator tables as-is, without any further customizations. Some bits of the emission code (now living in the EmissionContext class) can be reused for DWARF v5 as well, but the subtle differences in the layout of various subtables mean the sharing is not always possible. (Also, the individual emit*** functions are fairly simple so there's a tradeoff between making a bigger general-purpose function, and two smaller targeted functions.) Another advantage of this setup is that more of the serialization logic can be hidden in the .cpp file -- I have moved declarations of the header and all the emission functions there. Reviewers: JDevlieghere, aprantl, probinson, dblaikie Subscribers: echristo, clayborg, vleschuk, llvm-commits Differential Revision: https://reviews.llvm.org/D43285 llvm-svn: 325516
* Re-land [dsymutil] Upstream update featureJonas Devlieghere2018-02-081-28/+160
| | | | | | | | | | This commit attempts to re-land the r324480 which was reverted in r324493 because it broke the Windows bots. For now I disabled the two update tests on Windows until I'm able to debug this. Differential revision: https://reviews.llvm.org/D42880 llvm-svn: 324592
* Revert dsymutil -update commitsJonas Devlieghere2018-02-071-160/+28
| | | | | | | Revert "[dsymutil][test] Check the updated dSYM instead of companion file." Revert "[dsymutil] Upstream update feature." llvm-svn: 324493
* [dsymutil] Upstream update feature.Jonas Devlieghere2018-02-071-28/+160
| | | | | | | | | | | Now that dsymutil can generate accelerator tables, we can upstream the update logic that, as the name implies, updates the accelerator tables in an existing dSYM bundle. In combination with `-minimize` this can be used to remove redundant .debug_(inlines|pubtypes|pubnames). Differential revision: https://reviews.llvm.org/D42880 llvm-svn: 324480
* [NFC] 'DWARFv5' -> 'DWARF v5'Jonas Devlieghere2018-02-011-1/+1
| | | | llvm-svn: 323950
* [DWARFv5] Re-enable dumping a line table with no CU.Paul Robinson2018-01-291-1/+1
| | | | | | | | | | | r323476 added support for DW_FORM_line_strp, and incorrectly made that depend on having a DWARFUnit available. We shouldn't be tracking .debug_line_str in DWARFUnit after all. After this patch, I can do an NFC follow up and undo a bunch of the "plumbing" part of r323476. Differential Revision: https://reviews.llvm.org/D42609 llvm-svn: 323691
* [dsymutil] Generate Apple accelerator tablesJonas Devlieghere2018-01-291-48/+318
| | | | | | | | | | | This patch adds support for generating accelerator tables in dsymutil. This feature was already present in our internal repository but not yet upstreamed because it requires changes to the Apple accelerator table implementation. Differential revision: https://reviews.llvm.org/D42501 llvm-svn: 323655
* [dsymutil] Make NonRelocatableStringPool a wrapper around ↵Jonas Devlieghere2018-01-241-23/+35
| | | | | | | | | | | DwarfStringPoolEntry. NFC This is needed in order to use our StringPool entries in the Apple accelerator tables. As this is NFC we rely on the existing tests for correctness. llvm-svn: 323339
* Thread MCSubtargetInfo through Target::createMCAsmBackendAlex Bradbury2018-01-031-5/+5
| | | | | | | | | | | | | | | | | | | | | 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
* [dsymutil] Accept line tables up to DWARFv5.Jonas Devlieghere2017-12-121-3/+8
| | | | | | | | | | | This patch removes the hard-coded check for DWARFv2 line tables. Now dsymutil accepts line tables for DWARF versions 2 to 5 (inclusive). Differential revision: https://reviews.llvm.org/D41084 rdar://35968319 llvm-svn: 320469
* 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
* make exitDsymutil static.Rafael Espindola2017-11-161-12/+20
| | | | | | | | | The objective is to remove it completelly. This first patch removes the last use outside dsymutil.cpp and makes it static. llvm-svn: 318429
* Simplify file handling in dsymutil.Rafael Espindola2017-11-151-31/+16
| | | | | | | | | | | This moves the file handling out of DwarfLinker.cpp. This fixes what is at least an oddity if not a bug. DwarfLinker.cpp was using ToolOutputFile, which uses RemoveFileOnSignal. The issue is that dsymutil.cpp uses that too. It is now clear from the interface that only dsymutil.cpp is responsible for creating and deleting files. llvm-svn: 318334
* [DWARFv5] Support DW_FORM_strp in the .debug_line header.Paul Robinson2017-11-071-3/+3
| | | | | | | | Supporting this form in .debug_line.dwo will be done as a follow-up. Differential Revision: https://reviews.llvm.org/D33155 llvm-svn: 317607
* [dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You ↵Eugene Zelenko2017-11-011-56/+160
| | | | | | Use warnings; other minor fixes (NFC). llvm-svn: 317123
* [dsymutil] Implement the --threads optionJonas Devlieghere2017-10-311-6/+12
| | | | | | | | | | | | | | This patch adds the --threads option to dsymutil to process architectures in parallel. The feature is already present in the version distributed with Xcode, but was not yet upstreamed. This is NFC as far as the linking behavior is concerned. As threads are used automatically, the current tests cover the change in implementation. Differential revision: https://reviews.llvm.org/D39355 llvm-svn: 316999
OpenPOWER on IntegriCloud