1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
Commit Graph

72 Commits

Author SHA1 Message Date
Jonas Devlieghere
0ee72e1062 [dsymutil] Improve error reporting when we cannot create output file.
Before this patch we were returning an empty string in case we couldn't
create the output file. Now we return an expected string so we can
return and print the proper issue. We now return errors instead of bools
and defer printing to the call site.

llvm-svn: 344983
2018-10-23 00:32:22 +00:00
Jonas Devlieghere
a35775300e [dsymutil] Simplify temporary file handling.
Dsymutil's update functionality was broken on Windows because we tried
to rename a file while we're holding open handles to that file. TempFile
provides a solution for this through its keep(Twine) method. This patch
changes dsymutil to make use of that functionality.

Differential revision: https://reviews.llvm.org/D49860

llvm-svn: 338216
2018-07-29 14:56:15 +00:00
Jonas Devlieghere
8dc3169d33 [dsymutil] Add support for generating DWARF5 accelerator tables.
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
2018-07-25 23:01:38 +00:00
Jonas Devlieghere
9ad77aa4ad [dsymutil] Add support for outputting assembly
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
2018-07-09 16:58:48 +00:00
Jonas Devlieghere
59f7e40dac [dsymutil] Make the CachedBinaryHolder the default
Replaces all uses of the old binary holder with its cached variant.

Differential revision: https://reviews.llvm.org/D48770

llvm-svn: 335991
2018-06-29 16:51:52 +00:00
Jonas Devlieghere
077fd2e850 [dsymutil] Introduce a new CachedBinaryHolder
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
2018-06-29 16:50:41 +00:00
Jonas Devlieghere
f589dab5bf [dsymutil] Move abstractions into separate files (NFC)
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
2018-06-27 16:13:40 +00:00
Jonas Devlieghere
8ea2cd2814 [ADT] Make escaping fn conform to coding guidelines
As noted by Adrian on llvm-commits, PrintHTMLEscaped and PrintEscaped in
StringExtras did not conform to the LLVM coding guidelines. This commit
rectifies that.

llvm-svn: 333669
2018-05-31 17:01:42 +00:00
Jonas Devlieghere
562ffd5cb3 [dsymutil] Escape HTML special characters in plist.
When printing string in the Plist, we weren't escaping the characters
which lead to invalid XML. This patch adds the escape logic to
StringExtras.

rdar://39785334

llvm-svn: 333565
2018-05-30 17:47:11 +00:00
Jonas Devlieghere
b1ad6ad40e [Support] Add color cl category.
This commit adds a color category so tools can document this option and
enables it for dwarfdump and dsymuttil.

rdar://problem/40498996

llvm-svn: 333176
2018-05-24 11:36:57 +00:00
Jonas Devlieghere
a8b81f545c [Support] Add convenience functions to WithColor. NFC.
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
2018-04-14 21:36:42 +00:00
Rui Ueyama
04fb9911c5 Define InitLLVM to do common initialization all at once.
We have a few functions that virtually all command wants to run on
process startup/shutdown. This patch adds InitLLVM class to do that
all at once, so that we don't need to copy-n-paste boilerplate code
to each llvm command's main() function.

Differential Revision: https://reviews.llvm.org/D45602

llvm-svn: 330046
2018-04-13 18:26:06 +00:00
Jonas Devlieghere
3351ebfb30 [dsymutil] Apply recursion workaround for threading
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
2018-04-03 18:01:18 +00:00
Jonas Devlieghere
c0997f81d5 [dsymutil] Upstream emitting of papertrail warnings.
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
2018-04-02 10:40:43 +00:00
Jonas Devlieghere
7aa3e9822f [dsymutil] Unify error handling outside DwarfLinker.
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
2018-03-13 15:47:38 +00:00
Jonas Devlieghere
e7334c5b3d [dsymutil] Embed toolchain in dSYM bundle
Allow us to embed the (Xcode) toolchain in the dSYM bundle's property
list.

Differential revision: https://reviews.llvm.org/D44151

llvm-svn: 326994
2018-03-08 10:39:12 +00:00
Jonas Devlieghere
8de40b8f47 [dsymutil] Use llvm::sys::path to join bundle path.
When processing a dSYM bundle, use llvm::sys::path to join the different
path components instead of using a string with hard coded forward
slashes as separators.

llvm-svn: 324622
2018-02-08 16:31:42 +00:00
Jonas Devlieghere
bfe7f62e6b Re-land [dsymutil] Upstream update feature
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
2018-02-08 10:48:54 +00:00
Jonas Devlieghere
6d4147311f Revert dsymutil -update commits
Revert "[dsymutil][test] Check the updated dSYM instead of companion file."
Revert "[dsymutil] Upstream update feature."

llvm-svn: 324493
2018-02-07 17:35:27 +00:00
Jonas Devlieghere
09c78f3176 [dsymutil] Upstream update feature.
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
2018-02-07 13:51:29 +00:00
Jonas Devlieghere
7aeeea08b8 [dsymutil] Enable -minimize feature.
Passing -minimize to dsymutil prevents the emission of .debug_inlines,
.debug_pubnames, and .debug_pubtypes in favor of the Apple accelerator
tables.

The actual check in the DWARF linker was added in r323655. This patch
simply enables it.

Differential revision: https://reviews.llvm.org/D42688

llvm-svn: 323812
2018-01-30 19:54:16 +00:00
Jonas Devlieghere
450adf5051 [dsymutil] Re-enable threading
Threading was disabled in r317263 because it broke a test in combination
with `-DLLVM_ENABLE_THREADS=OFF`. This was because a ThreadPool warning
was piped to llvm-dwarfdump which was expecting to read an object from
stdin.

This patch re-enables threading and fixes the offending test.
Unfortunately this required more than just moving the ThreadPool out of
the for loop because of the TempFile refactoring that took place in the
meantime.

Differential revision: https://reviews.llvm.org/D41180

llvm-svn: 320601
2017-12-13 18:03:04 +00:00
Jonas Devlieghere
8898008ab6 [dsymutil] Add -verify option to run DWARF verifier after linking.
This patch adds support for running the DWARF verifier on the linked
debug info files. If the -verify options is specified and verification
fails, dsymutil exists with abort with non-zero exit code. This behavior
is *not* enabled by default.

Differential revision: https://reviews.llvm.org/D40777

llvm-svn: 320033
2017-12-07 11:17:19 +00:00
Jonas Devlieghere
acf1b692f3 [dsymutil] Upstream getBundleInfo implementation
This patch implements `getBundleInfo`, which uses CoreFoundation to
obtain information about the CFBundle. This information is needed to
populate the Plist in the dSYM bundle.

This change only applies to darwin and is an NFC as far as other
platforms are concerned.

Differential revision: https://reviews.llvm.org/D40244

llvm-svn: 319416
2017-11-30 10:25:28 +00:00
Rafael Espindola
b6d62dc785 Try to fix the windows build.
llvm-svn: 318535
2017-11-17 17:46:39 +00:00
Rafael Espindola
be32765f46 Use TempFile in dsymutil.
I don't think there is any functionality change, but the code is
easier to understand IMHO.

llvm-svn: 318534
2017-11-17 17:33:09 +00:00
Rafael Espindola
7b14da3b51 make exitDsymutil static.
The objective is to remove it completelly.

This first patch removes the last use outside dsymutil.cpp and makes
it static.

llvm-svn: 318429
2017-11-16 17:46:43 +00:00
Rafael Espindola
df81e5d550 Simplify file handling in dsymutil.
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
2017-11-15 20:55:53 +00:00
Hans Wennborg
f6e1ddbde1 Fix llvm-dsymutil test in -DLLVM_ENABLE_THREADS=OFF mode
After r316999, tools/dsymutil/X86/alias.test started failing in builds
that have threading disabled.

llvm-svn: 317263
2017-11-02 20:22:03 +00:00
Jonas Devlieghere
fc1af3e0f8 [dsymutil][doc] Improve wording in manpage and rename file.
- Improve wording
 - Rename llvm-dsymutil to dsymutil
 - Name -arch=<arch> argument

Differential revision: https://reviews.llvm.org/D39561

llvm-svn: 317226
2017-11-02 18:44:54 +00:00
Eugene Zelenko
0d3ac016c2 [dsymutil, llvm-objcopy] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 317123
2017-11-01 21:16:06 +00:00
Jonas Devlieghere
88741fa2a0 [dsymutil][NFC} Rename thread related command line options
This makes the command line options consistent with llvm-cov and
llvm-profdata, which both use `-num-threads` and `-j`.

This also addresses the conflict reported after landing D39355.

Differential revision: https://reviews.llvm.org/D39496

llvm-svn: 317104
2017-11-01 17:15:29 +00:00
Jonas Devlieghere
17ac392c74 [dsymutil] Implement the --threads option
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
2017-10-31 13:54:15 +00:00
Jonas Devlieghere
4d22ee666b Re-land "[dsymutil] Timestmap verification for __swift_ast"
This patch adds timestamp verification for swiftmodule files. A new flag
is provided to allows us to disable this check in order to allow testing
of this feature.

Differential revision: https://reviews.llvm.org/D38686

llvm-svn: 315684
2017-10-13 14:41:23 +00:00
Jonas Devlieghere
bb2f966aec Revert "[dsymutil] Timestmap verification for __swift_ast"
This reverts commit r315456.

llvm-svn: 315458
2017-10-11 13:51:30 +00:00
Jonas Devlieghere
1e74cc6b31 [dsymutil] Timestmap verification for __swift_ast
This patch adds timestamp verification for swiftmodule files.

 - A new flag is provided to allows us to continue testing of the code
   for embedding the__swift_ast. (git doesn't maintain timestamps)
 - Adds a new test for fat (arm) binaries.

Differential revision: https://reviews.llvm.org/D38686

llvm-svn: 315456
2017-10-11 13:34:52 +00:00
Rafael Espindola
4f9f7452be Don't call exit from cl::PrintHelpMessage.
Most callers were not expecting the exit(0) and trying to exit with a
different value.

This also adds back the call to cl::PrintHelpMessage in llvm-ar.

llvm-svn: 312761
2017-09-07 23:30:48 +00:00
Richard Smith
f7f711ffaa Search for llvm-symbolizer binary in the same directory as argv[0], before
looking for it along $PATH. This allows installs of LLVM tools outside of
$PATH to find the symbolizer and produce pretty backtraces if they crash.

llvm-svn: 272232
2016-06-09 00:53:21 +00:00
Frederic Riss
bf4e97e3be [dsymutil] Create the temporary files in the system temp directory.
llvm-dsymutil used to create the temporary files in the output directory.
This works fine except when the output directory contains a '%' char, which
is then replaced by llvm::sys::fs::createUniqueFile() generating an invalid
path.
Just use the default temp dir for those files.

llvm-svn: 268304
2016-05-02 21:06:14 +00:00
Frederic Riss
ea240ae260 [dsymutil] Prevent warning
llvm-svn: 249836
2015-10-09 15:04:05 +00:00
Frederic Riss
2c8b47f4cc [dsymutil] Try to find lipo first besides dsymutil before looking up the PATH.
Even if we don't have it in PATH, lipo should usually exist in the same directory
as dsymutil. Keep the fallback looking up the PATH, it's very useful when
testing a non-installed executable.

llvm-svn: 249762
2015-10-08 22:35:53 +00:00
Adrian Prantl
9f6d56f4ae dsymutil: Make -oso-prepend-path available to DwarfLinker.
NFC

llvm-svn: 248312
2015-09-22 18:51:01 +00:00
Frederic Riss
e4c25bb014 [dsymutil] Implement -symtab/-s option.
This option dumps the STAB entries that define the debug map(s)
stored in the input binaries, and then exits.

llvm-svn: 246403
2015-08-31 00:29:09 +00:00
Frederic Riss
f7cdc109f3 [dsymutil] Reapply r245960.
There was an issue in the test setup because the test requires an arch that
wasn't filtered by the lit.local.cfg, but given the set of bots that failed,
I'm not confident this is the (only) issue. So this commit also adds more
output to the test to help me track down the failure if it happens again.

Original commit message:
[dsymutil] Rewrite thumb triple names in user visible messages.

We autodetect triples from the input file(s) while reading the mach-o debug map.
As we need to create a Target from those triples, we always chose the thumb
variant (because the arm variant might not be 'instantiable' eg armv7m). The
user visible architecture names should still be 'arm' and not 'thumb' variants
though.

llvm-svn: 245988
2015-08-25 23:15:26 +00:00
Frederic Riss
0d55393ca3 Revert "[dsymutil] Rewrite thumb triple names in user visible messages."
This reverts commit r245960.

Multiple bots are failing on the new test. It seemd like llvm-dsymutil exits with an error. Investigating.

llvm-svn: 245964
2015-08-25 18:43:11 +00:00
Frederic Riss
16713145e7 [dsymutil] Rewrite thumb triple names in user visible messages.
We autodetect triples from the input file(s) while reading the mach-o debug map.
As we need to create a Target from those triples, we always chose the thumb
variant (because the arm variant might not be 'instantiable' eg armv7m). The
user visible architecture names should still be 'arm' and not 'thumb' variants
though.

llvm-svn: 245960
2015-08-25 18:19:48 +00:00
Frederic Riss
c80ee6a7d0 [dsymutil] Not finding any debug info is not a fatal error
llvm-svn: 245959
2015-08-25 18:19:43 +00:00
Frederic Riss
71ba5895ea [dsymutil] Implement dSYM bundle creation
A dSYM bundle is a file hierarchy that looks slike this:
 <bundle name>.dSYM/
     Contents/
        Info.plist
        Resources/
           DWARF/
              <DWARF file(s)>

This is the default output mode of dsymutil.

llvm-svn: 244270
2015-08-06 21:05:06 +00:00
Frederic Riss
6f453bc7af [dsymutil] Add (unimplemented) --flat option
dsymutil should by default generate dSYM bundles which are filesystem
hierarchies containing the debug info and an additional Info.plist.
Currently llvm-dsymutil emits raw binaries containing the debug info.
This is what we call the 'flat mode'. Add a -f/-flat option that is
supposed to enable that flat mode, but don't wire it for now, only
pass it to the tests that will need it to stay functional once we
do bundle generation by default.
This basically makes this commit NFC and removes the noise from the
actual commit that adds support for bundle generation.

llvm-svn: 244269
2015-08-06 21:05:01 +00:00
Frederic Riss
b41419e201 [dsymutil] Do not create temporary files in -no-output mode.
The files were never written to and then deleted, but they were created
nonetheless. To prevent that, create a wrapper around the 2 variants of
createUniqueFile and use the one that only does an access(Exists) call
to check for name unicity in -no-output mode.

llvm-svn: 244172
2015-08-05 23:33:50 +00:00