Dump bytes with offset instead of rva
authorAmy Yu <amycmyu@gmail.com>
Fri, 8 Jun 2018 23:16:23 +0000 (16:16 -0700)
committerAmy Yu <amycmyu@gmail.com>
Tue, 19 Jun 2018 20:26:02 +0000 (13:26 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/b85874d6ac7c82e03434aee01ef9b32da64a3096

src/coreclr/src/tools/r2rdump/R2RDump.cs

index 65d72be..6a5cc34 100644 (file)
@@ -170,7 +170,7 @@ namespace R2RDump
                 _writer.Write(method.GcInfo);
                 if (_raw)
                 {
-                    DumpBytes(r2r, method.GcInfo.Offset, (uint)method.GcInfo.Size);
+                    DumpBytes(r2r, method.GcInfo.Offset, (uint)method.GcInfo.Size, false);
                 }
             }
             _writer.WriteLine();
@@ -212,9 +212,11 @@ namespace R2RDump
         /// <summary>
         /// Prints a formatted string containing a block of bytes from the relative virtual address and size
         /// </summary>
-        public void DumpBytes(R2RReader r2r, int rva, uint size)
+        public void DumpBytes(R2RReader r2r, int rva, uint size, bool convertToOffset = true)
         {
-            uint start = (uint)r2r.GetOffset(rva);
+            int start = rva;
+            if (convertToOffset)
+                start = r2r.GetOffset(rva);
             if (start > r2r.Image.Length || start + size > r2r.Image.Length)
             {
                 throw new IndexOutOfRangeException();