]> granicus.if.org Git - llvm/commitdiff
[dsymutil] Improve verbose output (NFC)
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 8 Oct 2019 22:03:13 +0000 (22:03 +0000)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 8 Oct 2019 22:03:13 +0000 (22:03 +0000)
The verbose output for finding relocations assumed that we'd always dump
the DIE after (which starts with a newline) and therefore didn't include
one itself. However, this isn't always true, leading to garbled output.

This patch adds a newline to the verbose output and adds a line that
says that the DIE is being kept (which isn't obvious otherwise). It also
adds a 0x prefix to the relocations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374123 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/dsymutil/basic-linking.test
tools/dsymutil/DwarfLinker.cpp

index 1c235312d1c733a0a0e7d05807812bcbd6195568..023538ea55653b325eeabf8f7b09126cb9ab5655 100644 (file)
@@ -25,36 +25,44 @@ CHECK-NOT: TAG
 CHECK: AT_name {{.*}}basic3.c
 
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _main      0000000000000000 => 0000000100000ea0
+CHECK: Found valid debug map entry: _main      0x0000000000000000 => 0x0000000100000ea0
+CHECK-NEXT: Keeping subprogram DIE:
 CHECK-NEXT: DW_TAG_subprogram
 CHECK-NEXT:   DW_AT_name{{.*}}"main"
 
-CHECK: Found valid debug map entry: _private_int       0000000000000560 => 0000000100001008
+CHECK: Found valid debug map entry: _private_int       0x0000000000000560 => 0x0000000100001008
+CHECK-NEXT: Keeping variable DIE:
 CHECK-NEXT: DW_TAG_variable
 CHECK-NEXT:   DW_AT_name {{.*}}"private_int"
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _baz       0000000000000310 => 0000000100001000
+CHECK: Found valid debug map entry: _baz       0x0000000000000310 => 0x0000000100001000
+CHECK-NEXT: Keeping variable DIE:
 CHECK-NEXT: DW_TAG_variable
 CHECK-NEXT:   DW_AT_name {{.*}}"baz"
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _foo       0000000000000020 => 0000000100000ed0
+CHECK: Found valid debug map entry: _foo       0x0000000000000020 => 0x0000000100000ed0
+CHECK-NEXT: Keeping subprogram DIE:
 CHECK-NEXT: DW_TAG_subprogram
 CHECK-NEXT:   DW_AT_name {{.*}}"foo"
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _inc       0000000000000070 => 0000000100000f20
+CHECK: Found valid debug map entry: _inc       0x0000000000000070 => 0x0000000100000f20
+CHECK-NEXT: Keeping subprogram DIE:
 CHECK-NEXT: DW_TAG_subprogram
 CHECK-NEXT:   DW_AT_name {{.*}}"inc"
 
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _val       ffffffffffffffff => 0000000100001004
+CHECK: Found valid debug map entry: _val       0xffffffffffffffff => 0x0000000100001004
+CHECK-NEXT: Keeping variable DIE:
 CHECK-NEXT: DW_TAG_variable
 CHECK-NEXT:   DW_AT_name {{.*}}"val"
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _bar       0000000000000020 => 0000000100000f40
+CHECK: Found valid debug map entry: _bar       0x0000000000000020 => 0x0000000100000f40
+CHECK-NEXT: Keeping subprogram DIE:
 CHECK-NEXT: DW_TAG_subprogram
 CHECK-NEXT:   DW_AT_name {{.*}}"bar"
 CHECK-NOT: Found valid debug map entry
-CHECK: Found valid debug map entry: _inc       0000000000000070 => 0000000100000f90
+CHECK: Found valid debug map entry: _inc       0x0000000000000070 => 0x0000000100000f90
+CHECK-NEXT: Keeping subprogram DIE:
 CHECK-NEXT: DW_TAG_subprogram
 CHECK-NEXT:   DW_AT_name {{.*}}"inc")
 
@@ -75,27 +83,33 @@ CHECK-LTO-NOT: TAG
 CHECK-LTO: AT_name {{.*}}basic3.c
 
 CHECK-LTO-NOT: Found valid debug map entry
-CHECK-LTO: Found valid debug map entry: _main  0000000000000000 => 0000000100000f40
+CHECK-LTO: Found valid debug map entry: _main  0x0000000000000000 => 0x0000000100000f40
+CHECK-LTO-NEXT: Keeping subprogram DIE:
 CHECK-LTO-NEXT: DW_TAG_subprogram
 CHECK-LTO-NEXT:   DW_AT_name {{.*}}"main"
 CHECK-LTO-NOT: Found valid debug map entry
-CHECK-LTO: Found valid debug map entry: _private_int   00000000000008e8 => 0000000100001008
+CHECK-LTO: Found valid debug map entry: _private_int   0x00000000000008e8 => 0x0000000100001008
+CHECK-LTO-NEXT: Keeping variable DIE:
 CHECK-LTO-NEXT: DW_TAG_variable
 CHECK-LTO-NEXT:   DW_AT_name {{.*}}"private_int"
 CHECK-LTO-NOT: Found valid debug map entry
-CHECK-LTO: Found valid debug map entry: _baz   0000000000000658 => 0000000100001000
+CHECK-LTO: Found valid debug map entry: _baz   0x0000000000000658 => 0x0000000100001000
+CHECK-LTO-NEXT: Keeping variable DIE:
 CHECK-LTO-NEXT: DW_TAG_variable
 CHECK-LTO-NEXT:   DW_AT_name {{.*}} "baz"
 CHECK-LTO-NOT: Found valid debug map entry
-CHECK-LTO: Found valid debug map entry: _foo   0000000000000010 => 0000000100000f50
+CHECK-LTO: Found valid debug map entry: _foo   0x0000000000000010 => 0x0000000100000f50
+CHECK-LTO-NEXT: Keeping subprogram DIE:
 CHECK-LTO-NEXT: DW_TAG_subprogram
 CHECK-LTO-NEXT:   DW_AT_name {{.*}}"foo"
 CHECK-LTO-NOT: Found valid debug map entry
-CHECK-LTO: Found valid debug map entry: _val   00000000000008ec => 0000000100001004
+CHECK-LTO: Found valid debug map entry: _val   0x00000000000008ec => 0x0000000100001004
+CHECK-LTO-NEXT: Keeping variable DIE:
 CHECK-LTO-NEXT: DW_TAG_variable
 CHECK-LTO-NEXT:   DW_AT_name {{.*}}"val"
 CHECK-LTO-NOT: Found valid debug map entry
-CHECK-LTO: Found valid debug map entry: _bar   0000000000000050 => 0000000100000f90
+CHECK-LTO: Found valid debug map entry: _bar   0x0000000000000050 => 0x0000000100000f90
+CHECK-LTO-NEXT: Keeping subprogram DIE:
 CHECK-LTO-NEXT: DW_TAG_subprogram
 CHECK-LTO-NEXT:   DW_AT_name {{.*}}"bar"
 
@@ -120,36 +134,44 @@ CHECK-ARCHIVE-NOT: TAG
 CHECK-ARCHIVE: AT_name {{.*}}basic3.c
 
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _main      0000000000000000 => 0000000100000ea0
+CHECK-ARCHIVE: Found valid debug map entry: _main      0x0000000000000000 => 0x0000000100000ea0
+CHECK-ARCHIVE-NEXT: Keeping subprogram DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_subprogram
 CHECK-ARCHIVE-NEXT:   DW_AT_name{{.*}}"main"
 
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _private_int       0000000000000560 => 0000000100001004
+CHECK-ARCHIVE: Found valid debug map entry: _private_int       0x0000000000000560 => 0x0000000100001004
+CHECK-ARCHIVE-NEXT: Keeping variable DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_variable
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"private_int"
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _baz       0000000000000310 => 0000000100001000
+CHECK-ARCHIVE: Found valid debug map entry: _baz       0x0000000000000310 => 0x0000000100001000
+CHECK-ARCHIVE-NEXT: Keeping variable DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_variable
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"baz"
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _foo       0000000000000020 => 0000000100000ed0
+CHECK-ARCHIVE: Found valid debug map entry: _foo       0x0000000000000020 => 0x0000000100000ed0
+CHECK-ARCHIVE-NEXT: Keeping subprogram DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_subprogram
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"foo"
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _inc       0000000000000070 => 0000000100000f20
+CHECK-ARCHIVE: Found valid debug map entry: _inc       0x0000000000000070 => 0x0000000100000f20
+CHECK-ARCHIVE-NEXT: Keeping subprogram DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_subprogram
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"inc"
 
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _val       ffffffffffffffff => 0000000100001008
+CHECK-ARCHIVE: Found valid debug map entry: _val       0xffffffffffffffff => 0x0000000100001008
+CHECK-ARCHIVE-NEXT: Keeping variable DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_variable
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"val"
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _bar       0000000000000020 => 0000000100000f40
+CHECK-ARCHIVE: Found valid debug map entry: _bar       0x0000000000000020 => 0x0000000100000f40
+CHECK-ARCHIVE-NEXT: Keeping subprogram DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_subprogram
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"bar"
 CHECK-ARCHIVE-NOT: Found valid debug map entry
-CHECK-ARCHIVE: Found valid debug map entry: _inc       0000000000000070 => 0000000100000f90
+CHECK-ARCHIVE: Found valid debug map entry: _inc       0x0000000000000070 => 0x0000000100000f90
+CHECK-ARCHIVE-NEXT: Keeping subprogram DIE:
 CHECK-ARCHIVE-NEXT: DW_TAG_subprogram
 CHECK-ARCHIVE-NEXT:   DW_AT_name {{.*}}"inc")
index 18dbf6b87ef4a81fb84622068e7450353521349c..3313f6a1539e81905292800b3f8c5922922c9b64 100644 (file)
@@ -578,16 +578,17 @@ bool DwarfLinker::RelocationManager::hasValidRelocation(
 
   const auto &ValidReloc = ValidRelocs[NextValidReloc++];
   const auto &Mapping = ValidReloc.Mapping->getValue();
-  uint64_t ObjectAddress = Mapping.ObjectAddress
-                               ? uint64_t(*Mapping.ObjectAddress)
-                               : std::numeric_limits<uint64_t>::max();
+  const uint64_t BinaryAddress = Mapping.BinaryAddress;
+  const uint64_t ObjectAddress = Mapping.ObjectAddress
+                                     ? uint64_t(*Mapping.ObjectAddress)
+                                     : std::numeric_limits<uint64_t>::max();
   if (Linker.Options.Verbose)
     outs() << "Found valid debug map entry: " << ValidReloc.Mapping->getKey()
-           << " "
-           << format("\t%016" PRIx64 " => %016" PRIx64, ObjectAddress,
-                     uint64_t(Mapping.BinaryAddress));
+           << "\t"
+           << format("0x%016" PRIx64 " => 0x%016" PRIx64 "\n", ObjectAddress,
+                     BinaryAddress);
 
-  Info.AddrAdjust = int64_t(Mapping.BinaryAddress) + ValidReloc.Addend;
+  Info.AddrAdjust = BinaryAddress + ValidReloc.Addend;
   if (Mapping.ObjectAddress)
     Info.AddrAdjust -= ObjectAddress;
   Info.InDebugMap = true;
@@ -644,7 +645,7 @@ unsigned DwarfLinker::shouldKeepVariableDIE(RelocationManager &RelocMgr,
 
   // See if there is a relocation to a valid debug map entry inside
   // this variable's location. The order is important here. We want to
-  // always check in the variable has a valid relocation, so that the
+  // always check if the variable has a valid relocation, so that the
   // DIEInfo is filled. However, we don't want a static variable in a
   // function to force us to keep the enclosing function.
   if (!RelocMgr.hasValidRelocation(LocationOffset, LocationEndOffset, MyInfo) ||
@@ -652,6 +653,7 @@ unsigned DwarfLinker::shouldKeepVariableDIE(RelocationManager &RelocMgr,
     return Flags;
 
   if (Options.Verbose) {
+    outs() << "Keeping variable DIE:";
     DIDumpOptions DumpOpts;
     DumpOpts.ChildRecurseDepth = 0;
     DumpOpts.Verbose = Options.Verbose;
@@ -688,6 +690,7 @@ unsigned DwarfLinker::shouldKeepSubprogramDIE(
     return Flags;
 
   if (Options.Verbose) {
+    outs() << "Keeping subprogram DIE:";
     DIDumpOptions DumpOpts;
     DumpOpts.ChildRecurseDepth = 0;
     DumpOpts.Verbose = Options.Verbose;