[llvm] r216413 - [MCJIT] Dump section memory both before and after relocations are applied.

Lang Hames lhames at gmail.com
Mon Aug 25 15:19:14 PDT 2014


Author: lhames
Date: Mon Aug 25 17:19:14 2014
New Revision: 216413

URL: http://llvm.org/viewvc/llvm-project?rev=216413&view=rev
Log:
[MCJIT] Dump section memory both before and after relocations are applied.

Also switch section memory dump format from 8 to 16 columns.


Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=216413&r1=216412&r2=216413&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Aug 25 17:19:14 2014
@@ -41,8 +41,10 @@ void RuntimeDyldImpl::registerEHFrames()
 
 void RuntimeDyldImpl::deregisterEHFrames() {}
 
-static void dumpSectionMemory(const SectionEntry &S) {
-  dbgs() << "----- Contents of section " << S.Name << " -----";
+static void dumpSectionMemory(const SectionEntry &S, StringRef State) {
+  dbgs() << "----- Contents of section " << S.Name << " " << State << " -----";
+
+  const unsigned ColsPerRow = 16;
 
   uint8_t *DataAddr = S.Address;
   uint64_t LoadAddr = S.LoadAddress;
@@ -51,13 +53,13 @@ static void dumpSectionMemory(const Sect
   unsigned BytesRemaining = S.Size;
 
   if (StartPadding) {
-    dbgs() << "\n" << format("0x%08x", LoadAddr & ~7) << ":";
+    dbgs() << "\n" << format("0x%08x", LoadAddr & ~(ColsPerRow - 1)) << ":";
     while (StartPadding--)
       dbgs() << "   ";
   }
 
   while (BytesRemaining > 0) {
-    if ((LoadAddr & 7) == 0)
+    if ((LoadAddr & (ColsPerRow - 1)) == 0)
       dbgs() << "\n" << format("0x%08x", LoadAddr) << ":";
 
     dbgs() << " " << format("%02x", *DataAddr);
@@ -86,8 +88,9 @@ void RuntimeDyldImpl::resolveRelocations
     uint64_t Addr = Sections[i].LoadAddress;
     DEBUG(dbgs() << "Resolving relocations Section #" << i << "\t"
                  << format("0x%x", Addr) << "\n");
-    DEBUG(dumpSectionMemory(Sections[i]));
+    DEBUG(dumpSectionMemory(Sections[i], "before relocations"));
     resolveRelocationList(Relocations[i], Addr);
+    DEBUG(dumpSectionMemory(Sections[i], "after relocations"));
     Relocations.erase(i);
   }
 }





More information about the llvm-commits mailing list