Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
[dsymutil] Upstream update feature.
Browse files Browse the repository at this point in the history
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@324480 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
JDevlieghere committed Feb 7, 2018
1 parent 5065b0d commit 87dba15
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 45 deletions.
10 changes: 9 additions & 1 deletion docs/CommandGuide/dsymutil.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ OPTIONS

When used when creating a dSYM file, this option will suppress the emission of
the .debug_inlines, .debug_pubnames, and .debug_pubtypes sections since
dsymutil currently has better equivalents: .apple_names and .apple_types.
dsymutil currently has better equivalents: .apple_names and .apple_types. When
used in conjunction with --update option, this option will cause redundant
accelerator tables to be removed.

.. option:: --no-odr

Expand Down Expand Up @@ -72,6 +74,12 @@ OPTIONS

Dumps the symbol table found in *executable* or object file(s) and exits.

.. option:: -u, --update

Update an existing dSYM file to contain the latest accelerator tables and
other DWARF optimizations. This option will rebuild the '.apple_names' and
'.apple_types' hashed accelerator tables.

.. option:: -v, --verbose

Display verbose information when linking.
Expand Down
15 changes: 15 additions & 0 deletions test/tools/dsymutil/X86/basic-linking-x86.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ RUN: llvm-dsymutil -f -o - -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.ma
RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic.macho.x86_64 | llvm-dsymutil -f -y -o - - | llvm-dwarfdump -a - | FileCheck %s --check-prefix=CHECK --check-prefix=BASIC
RUN: llvm-dsymutil -dump-debug-map -oso-prepend-path=%p/.. %p/../Inputs/basic-archive.macho.x86_64 | llvm-dsymutil -f -o - -y - | llvm-dwarfdump -a - | FileCheck %s --check-prefix=CHECK --check-prefix=ARCHIVE

# Update tests
RUN: rm -rf %t.dir
RUN: mkdir -p %t.dir
RUN: cat %p/../Inputs/basic.macho.x86_64 > %t.dir/basic
RUN: llvm-dsymutil -oso-prepend-path=%p/.. %t.dir/basic
RUN: llvm-dwarfdump -a %t.dir/basic.dSYM/Contents/Resources/DWARF/basic | FileCheck %s
RUN: llvm-dsymutil --update %t.dir/basic.dSYM
RUN: llvm-dwarfdump -a %t.dir/basic.dSYM/Contents/Resources/DWARF/basic | FileCheck %s
RUN: llvm-dsymutil -u %t.dir/basic.dSYM
RUN: llvm-dwarfdump -a %t.dir/basic.dSYM/Contents/Resources/DWARF/basic | FileCheck %s
RUN: llvm-dsymutil --update %t.dir/basic.dSYM -o %t.dir/updated.dSYM
RUN: llvm-dwarfdump -a %t.dir/updated.dSYM/Contents/Resources/DWARF/basic | FileCheck %s
RUN: llvm-dsymutil -f -u %t2 -o %t3
RUN: llvm-dwarfdump -a %t3 | FileCheck %s

CHECK: file format Mach-O 64-bit x86-64

CHECK: debug_info contents
Expand Down
35 changes: 35 additions & 0 deletions test/tools/dsymutil/X86/update-one-CU.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
RUN: llvm-dsymutil -oso-prepend-path=%p/.. %p/../Inputs/objc.macho.x86_64 -o %t.dSYM
RUN: llvm-dsymutil -update %t.dSYM
RUN: llvm-dwarfdump -apple-types -apple-objc %t.dSYM/Contents/Resources/DWARF/objc.macho.x86_64 | FileCheck %s

CHECK: .apple_types contents:
CHECK: Hash 0x2b5e6 [
CHECK-NEXT: Name@0x145 {
CHECK-NEXT: String: 0x00000066 "A"
CHECK-NEXT: Data 0 [
CHECK-NEXT: Atom[0]: 0x0000012d
CHECK-NEXT: Atom[1]: 0x0013
CHECK-NEXT: Atom[2]: 0x02
CHECK-NEXT: Atom[3]: 0x0b87b15a
CHECK-NEXT: ]
CHECK-NEXT: }
CHECK-NEXT: ]

CHECK: .apple_objc contents:
CHECK: Hash 0x2b5e6
CHECK-NEXT: Name@0x38 {
CHECK-NEXT: String: 0x00000066 "A"
CHECK-NEXT: Data 0 [
CHECK-NEXT: Atom[0]: 0x00000027
CHECK-NEXT: ]
CHECK-NEXT: Data 1 [
CHECK-NEXT: Atom[0]: 0x0000007a
CHECK-NEXT: ]
CHECK-NEXT: }
CHECK: Hash 0x3fa0f4b5
CHECK-NEXT: Name@0x4c {
CHECK-NEXT: String: 0x0000009d "A(Category)"
CHECK-NEXT: Data 0 [
CHECK-NEXT: Atom[0]: 0x0000007a
CHECK-NEXT: ]
CHECK-NEXT: }
1 change: 1 addition & 0 deletions test/tools/dsymutil/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ HELP: -num-threads=<n>
HELP: -o=<filename>
HELP: -oso-prepend-path=<path>
HELP: -symtab
HELP: -update
HELP: -verbose
HELP: -verify
HELP: -y
Expand Down
3 changes: 2 additions & 1 deletion tools/dsymutil/DebugMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Object/MachO.h"
#include "llvm/Support/Chrono.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/YAMLTraits.h"
Expand Down Expand Up @@ -107,7 +108,7 @@ class DebugMap {
DebugMapObject &
addDebugMapObject(StringRef ObjectFilePath,
sys::TimePoint<std::chrono::seconds> Timestamp,
uint8_t Type);
uint8_t Type = llvm::MachO::N_OSO);

const Triple &getTriple() const { return BinaryTriple; }

Expand Down

6 comments on commit 87dba15

@copumpkin
Copy link

@copumpkin copumpkin commented on 87dba15 Feb 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JDevlieghere is this bringing llvm-dsymutil back in sync with the Apple dsymutil? Seeing the word upstream here gets me excited 😄

@JDevlieghere
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copumpkin Yes! I'm pretty close at this point, there are only a few more thing left that should make it upstream in the near future.

@copumpkin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh awesome! I've been eagerly keeping an eye on this work and it's very exciting to see it finally get ported over 😄 thank you so much!

@copumpkin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JDevlieghere any idea which LLVM release should have a "fully functional llvm-dsymutil"? Trying to figure out at what point I can start using it interchangeably with the official Apple one and it's hard to gauge feature parity by watching commits 😄

@JDevlieghere
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copumpkin I believe only support for BCSymbolFiles is missing upstream. I'm working on a patch for this but it's pretty low on my priorities list... We've also renamed the tool upstream to reflect this (it's just dsymutil now) and switched the LLDB test suite to use the one from llvm. So unless you're embedding bitcode, you should be able to switch between the two transparently.

@copumpkin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for all the great work! So it seems like 7.0 is the first version with the rename: https://github.com/llvm-mirror/llvm/blob/release_70/tools/dsymutil/LLVMBuild.txt#L20

So excited!

Please sign in to comment.