[llvm-branch-commits] [llvm] 5bb28fa - [JITLink][ELF] Reformat/add debug logging in ELF_x86_64.cpp.

Lang Hames via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 9 23:51:46 PST 2020


Author: Lang Hames
Date: 2020-12-10T18:46:44+11:00
New Revision: 5bb28fa0f51e94522644fe5633877b441b9ad8d3

URL: https://github.com/llvm/llvm-project/commit/5bb28fa0f51e94522644fe5633877b441b9ad8d3
DIFF: https://github.com/llvm/llvm-project/commit/5bb28fa0f51e94522644fe5633877b441b9ad8d3.diff

LOG: [JITLink][ELF] Reformat/add debug logging in ELF_x86_64.cpp.

Moves symbol name to the end of the output and makes other columns fixed width
so that they line up.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index a0f944db7943..20504b861155 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -286,17 +286,13 @@ class ELFLinkGraphBuilder_x86_64 {
           return NameOrErr.takeError();
 
         LLVM_DEBUG({
-          dbgs() << "  ";
-          if (!Name)
-            dbgs() << "<anonymous symbol>";
-          else
-            dbgs() << *Name;
-          dbgs() << ": value = " << formatv("{0:x16}", SymRef.getValue())
+          dbgs() << "  value = " << formatv("{0:x16}", SymRef.getValue())
                  << ", type = " << formatv("{0:x2}", SymRef.getType())
-                 << ", binding = " << SymRef.getBinding()
-                 << ", size =" << SymRef.st_size
-                 << ", info =" << SymRef.st_info;
-          dbgs() << "\n";
+                 << ", binding = " << formatv("{0:x2}", SymRef.getBinding())
+                 << ", size = "
+                 << formatv("{0:x16}", static_cast<uint64_t>(SymRef.st_size))
+                 << ", info = " << formatv("{0:x2}", SymRef.st_info)
+                 << " :" << (Name ? *Name : "<anonymous symbol>") << "\n";
         });
       }
     }
@@ -333,7 +329,7 @@ class ELFLinkGraphBuilder_x86_64 {
       LLVM_DEBUG({
         dbgs() << "  " << *Name << ": " << formatv("{0:x16}", Address) << " -- "
                << formatv("{0:x16}", Address + Size) << ", align: " << Alignment
-               << " Flags:" << Flags << "\n";
+               << " Flags: " << formatv("{0:x}", Flags) << "\n";
       });
 
       if (SecRef.sh_type != ELF::SHT_NOBITS) {
@@ -418,8 +414,8 @@ class ELFLinkGraphBuilder_x86_64 {
         if (!TargetSymbol) {
           return make_error<llvm::StringError>(
               "Could not find symbol at given index, did you add it to "
-              "JITSymbolTable? index: " +
-                  std::to_string((*Symbol)->st_shndx) +
+              "JITSymbolTable? index: " + std::to_string(SymbolIndex)
+              + ", shndx: " + std::to_string((*Symbol)->st_shndx) +
                   " Size of table: " + std::to_string(JITSymbolTable.size()),
               llvm::inconvertibleErrorCode());
         }
@@ -546,7 +542,7 @@ class ELFLinkGraphBuilder_x86_64 {
                 "Section has no block", llvm::inconvertibleErrorCode());
 
           auto B = *bs.begin();
-          LLVM_DEBUG({ dbgs() << "  " << *Name << ": "; });
+          LLVM_DEBUG({ dbgs() << "  " << *Name << " at index " << SymbolIndex << "\n"; });
           if (SymRef.getType() == ELF::STT_SECTION)
             *Name = *sectName;
           auto &S = G->addDefinedSymbol(
@@ -556,7 +552,12 @@ class ELFLinkGraphBuilder_x86_64 {
         } else if (SymRef.isUndefined() && SymRef.isExternal()) {
           auto &S = G->addExternalSymbol(*Name, SymRef.st_size, bindings.first);
           JITSymbolTable[SymbolIndex] = &S;
-        }
+        } else
+          LLVM_DEBUG({
+              dbgs()
+                << "Not creating graph symbol for normalized symbol at index "
+                << SymbolIndex << ", \"" << *Name << "\"\n";
+            });
 
         // TODO: The following has to be implmented.
         // leaving commented out to save time for future patchs


        


More information about the llvm-branch-commits mailing list