Save name of dll in constant, use tab instead of spaces
authorAmy Yu <amycmyu@gmail.com>
Tue, 19 Jun 2018 18:22:03 +0000 (11:22 -0700)
committerAmy Yu <amycmyu@gmail.com>
Tue, 19 Jun 2018 18:22:03 +0000 (11:22 -0700)
Commit migrated from https://github.com/dotnet/coreclr/commit/a5c843564c4dd8301b0c424f6041fada2921b1ab

src/coreclr/src/tools/r2rdump/CoreDisTools.cs
src/coreclr/src/tools/r2rdump/GCInfo.cs
src/coreclr/src/tools/r2rdump/GCInfoTypes.cs
src/coreclr/src/tools/r2rdump/GCSlotTable.cs
src/coreclr/src/tools/r2rdump/UnwindInfo.cs

index ad3b7b45e4f2ba64344809369aa60ea00a0855bb..6070e43fd3909f3b4caac3675d66cb0473eb3d67 100644 (file)
@@ -12,6 +12,8 @@ namespace R2RDump
 {
     class CoreDisTools
     {
+        private const string _dll = "coredistools.dll";
+
         public enum TargetArch
         {
             Target_Host, // Target is the same as host architecture
@@ -21,23 +23,23 @@ namespace R2RDump
             Target_Arm64
         };
 
-        [DllImport("coredistools.dll")]
+        [DllImport(_dll)]
         public static extern IntPtr InitBufferedDisasm(TargetArch Target);
 
-        [DllImport("coredistools.dll")]
+        [DllImport(_dll)]
         public static extern void DumpCodeBlock(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
 
-        [DllImport("coredistools.dll")]
+        [DllImport(_dll)]
         [return: MarshalAs(UnmanagedType.I4)]
         public static extern int DumpInstruction(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size);
 
-        [DllImport("coredistools.dll")]
+        [DllImport(_dll)]
         public static extern IntPtr GetOutputBuffer();
 
-        [DllImport("coredistools.dll")]
+        [DllImport(_dll)]
         public static extern void ClearOutputBuffer();
 
-        [DllImport("coredistools.dll")]
+        [DllImport(_dll)]
         public static extern void FinishDisasm(IntPtr Disasm);
 
         public unsafe static string GetCodeBlock(IntPtr Disasm, RuntimeFunction rtf, int imageOffset, byte[] image)
index 04422862e35a6be6712213711358e1c4761dfb3d..cf57db62ac97ed2a9f4413cc5448db1d7171a68a 100644 (file)
@@ -59,13 +59,12 @@ namespace R2RDump
             public override string ToString()
             {
                 StringBuilder sb = new StringBuilder();
-                string tab2 = new string(' ', 8);
 
-                sb.AppendLine($"{tab2}CodeOffset: {CodeOffset}");
-                sb.AppendLine($"{tab2}SlotId: {SlotId}");
-                sb.AppendLine($"{tab2}IsLive: {IsLive}");
-                sb.AppendLine($"{tab2}ChunkId: {ChunkId}");
-                sb.Append($"{tab2}--------------------");
+                sb.AppendLine($"\t\tCodeOffset: {CodeOffset}");
+                sb.AppendLine($"\t\tSlotId: {SlotId}");
+                sb.AppendLine($"\t\tIsLive: {IsLive}");
+                sb.AppendLine($"\t\tChunkId: {ChunkId}");
+                sb.Append($"\t\t--------------------");
 
                 return sb.ToString();
             }
@@ -237,19 +236,18 @@ namespace R2RDump
         public override string ToString()
         {
             StringBuilder sb = new StringBuilder();
-            string tab = "    ";
 
-            sb.AppendLine($"{tab}Version: {Version}");
-            sb.AppendLine($"{tab}CodeLength: {CodeLength}");
-            sb.AppendLine($"{tab}ReturnKind: {Enum.GetName(typeof(ReturnKinds), ReturnKind)}");
-            sb.AppendLine($"{tab}ValidRangeStart: {ValidRangeStart}");
-            sb.AppendLine($"{tab}ValidRangeEnd: {ValidRangeEnd}");
+            sb.AppendLine($"\tVersion: {Version}");
+            sb.AppendLine($"\tCodeLength: {CodeLength}");
+            sb.AppendLine($"\tReturnKind: {Enum.GetName(typeof(ReturnKinds), ReturnKind)}");
+            sb.AppendLine($"\tValidRangeStart: {ValidRangeStart}");
+            sb.AppendLine($"\tValidRangeEnd: {ValidRangeEnd}");
             if (SecurityObjectStackSlot != -1)
-                sb.AppendLine($"{tab}SecurityObjectStackSlot: caller.sp{SecurityObjectStackSlot:+#;-#;+0}");
+                sb.AppendLine($"\tSecurityObjectStackSlot: caller.sp{SecurityObjectStackSlot:+#;-#;+0}");
 
             if (GSCookieStackSlot != -1)
             {
-                sb.AppendLine($"{tab}GSCookieStackSlot: caller.sp{GSCookieStackSlot:+#;-#;+0}");
+                sb.AppendLine($"\tGSCookieStackSlot: caller.sp{GSCookieStackSlot:+#;-#;+0}");
                 sb.AppendLine($"GS cookie valid range: [{ValidRangeStart};{ValidRangeEnd})");
             }
 
@@ -257,55 +255,55 @@ namespace R2RDump
             {
                 if (_machine == Machine.Amd64)
                 {
-                    sb.AppendLine($"{tab}PSPSymStackSlot: initial.sp{PSPSymStackSlot:+#;-#;+0}");
+                    sb.AppendLine($"\tPSPSymStackSlot: initial.sp{PSPSymStackSlot:+#;-#;+0}");
                 }
                 else
                 {
-                    sb.AppendLine($"{tab}PSPSymStackSlot: caller.sp{PSPSymStackSlot:+#;-#;+0}");
+                    sb.AppendLine($"\tPSPSymStackSlot: caller.sp{PSPSymStackSlot:+#;-#;+0}");
                 }
             }
 
             if (GenericsInstContextStackSlot != -1)
             {
-                sb.AppendLine($"{tab}GenericsInstContextStackSlot: caller.sp{GenericsInstContextStackSlot:+#;-#;+0}");
+                sb.AppendLine($"\tGenericsInstContextStackSlot: caller.sp{GenericsInstContextStackSlot:+#;-#;+0}");
             }
 
             if (StackBaseRegister != 0xffffffff)
-                sb.AppendLine($"{tab}StackBaseRegister: {(Amd64Registers)StackBaseRegister}");
+                sb.AppendLine($"\tStackBaseRegister: {(Amd64Registers)StackBaseRegister}");
             if (_machine == Machine.Amd64)
             {
-                sb.AppendLine($"{tab}Wants Report Only Leaf: {_wantsReportOnlyLeaf}");
+                sb.AppendLine($"\tWants Report Only Leaf: {_wantsReportOnlyLeaf}");
             }
             else if (_machine == Machine.Arm || _machine == Machine.Arm64)
             {
-                sb.AppendLine($"{tab}Has Tailcalls: {_wantsReportOnlyLeaf}");
+                sb.AppendLine($"\tHas Tailcalls: {_wantsReportOnlyLeaf}");
             }
 
-            sb.AppendLine($"{tab}Size of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
+            sb.AppendLine($"\tSize of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}");
             if (SizeOfEditAndContinuePreservedArea != 0xffffffff)
-                sb.AppendLine($"{tab}SizeOfEditAndContinuePreservedArea: 0x{SizeOfEditAndContinuePreservedArea:X}");
+                sb.AppendLine($"\tSizeOfEditAndContinuePreservedArea: 0x{SizeOfEditAndContinuePreservedArea:X}");
             if (ReversePInvokeFrameStackSlot != -1)
-                sb.AppendLine($"{tab}ReversePInvokeFrameStackSlot: {ReversePInvokeFrameStackSlot}");
-            sb.AppendLine($"{tab}NumSafePoints: {NumSafePoints}");
-            sb.AppendLine($"{tab}NumInterruptibleRanges: {NumInterruptibleRanges}");
-            sb.AppendLine($"{tab}SafePointOffsets:");
+                sb.AppendLine($"\tReversePInvokeFrameStackSlot: {ReversePInvokeFrameStackSlot}");
+            sb.AppendLine($"\tNumSafePoints: {NumSafePoints}");
+            sb.AppendLine($"\tNumInterruptibleRanges: {NumInterruptibleRanges}");
+            sb.AppendLine($"\tSafePointOffsets:");
             foreach (uint offset in SafePointOffsets)
             {
-                sb.AppendLine($"{tab}{tab}{offset}");
+                sb.AppendLine($"\t\t{offset}");
             }
-            sb.AppendLine($"{tab}InterruptibleRanges:");
+            sb.AppendLine($"\tInterruptibleRanges:");
             foreach (InterruptibleRange range in InterruptibleRanges)
             {
-                sb.AppendLine($"{tab}{tab}start:{range.StartOffset}, end:{range.StopOffset}");
+                sb.AppendLine($"\t\tstart:{range.StartOffset}, end:{range.StopOffset}");
             }
-            sb.AppendLine($"{tab}SlotTable:");
+            sb.AppendLine($"\tSlotTable:");
             sb.Append(SlotTable.ToString());
-            sb.AppendLine($"{tab}Transitions:");
+            sb.AppendLine($"\tTransitions:");
             foreach (GcTransition trans in Transitions.Values)
             {
                 sb.AppendLine(trans.ToString());
             }
-            sb.AppendLine($"{tab}Size: {Size} bytes");
+            sb.AppendLine($"\tSize: {Size} bytes");
 
             return sb.ToString();
         }
index b8e981f26a99147e739edf7b3677c5d94d2a2778..9b44a595a8eea34368386b5882d582b99631d915 100644 (file)
@@ -207,10 +207,9 @@ namespace R2RDump
         public override string ToString()
         {
             StringBuilder sb = new StringBuilder();
-            string tab4 = new string(' ', 16);
 
-            sb.AppendLine($"{tab4}SpOffset: {SpOffset}");
-            sb.Append($"{tab4}Base: {Enum.GetName(typeof(GcStackSlotBase), Base)}");
+            sb.AppendLine($"\t\t\t\tSpOffset: {SpOffset}");
+            sb.Append($"\t\t\t\tBase: {Enum.GetName(typeof(GcStackSlotBase), Base)}");
 
             return sb.ToString();
         }
index df2c310a6dc74e2403c4c23679abb262480ea527..f2ebf414c68814e5257ec37fd9b89f0eadb9fd92 100644 (file)
@@ -34,18 +34,17 @@ namespace R2RDump
             public override string ToString()
             {
                 StringBuilder sb = new StringBuilder();
-                string tab3 = new string(' ', 12);
 
                 if (StackSlot != null)
                 {
-                    sb.AppendLine($"{tab3}Stack:");
+                    sb.AppendLine($"\t\t\tStack:");
                     sb.AppendLine(StackSlot.ToString());
                 }
                 else
                 {
-                    sb.AppendLine($"{tab3}RegisterNumber: {RegisterNumber}");
+                    sb.AppendLine($"\t\t\tRegisterNumber: {RegisterNumber}");
                 }
-                sb.AppendLine($"{tab3}Flags: {Flags}");
+                sb.AppendLine($"\t\t\tFlags: {Flags}");
 
                 return sb.ToString();
             }
@@ -88,16 +87,14 @@ namespace R2RDump
         public override string ToString()
         {
             StringBuilder sb = new StringBuilder();
-            string tab2 = new string(' ', 8);
-            string tab3 = new string(' ', 12);
 
-            sb.AppendLine($"{tab2}NumSlots({NumSlots}) = NumRegisters({NumRegisters}) + NumStackSlots({NumStackSlots}) + NumUntracked({NumUntracked})");
-            sb.AppendLine($"{tab2}GcSlots:");
-            sb.AppendLine($"{tab3}-------------------------");
+            sb.AppendLine($"\t\tNumSlots({NumSlots}) = NumRegisters({NumRegisters}) + NumStackSlots({NumStackSlots}) + NumUntracked({NumUntracked})");
+            sb.AppendLine($"\t\tGcSlots:");
+            sb.AppendLine($"\t\t\t-------------------------");
             foreach (GcSlot slot in GcSlots)
             {
                 sb.Append(slot.ToString());
-                sb.AppendLine($"{tab3}-------------------------");
+                sb.AppendLine($"\t\t\t-------------------------");
             }
 
             return sb.ToString();
index 9742aa0944b091cc94529ecd8c6ba2aedb150feb..da12f4f498d375def7d4de56a9619f632f7fa6df 100644 (file)
@@ -34,21 +34,19 @@ namespace R2RDump
         public override string ToString()
         {
             StringBuilder sb = new StringBuilder();
-            string tab2 = new string(' ', 8);
-            string tab3 = new string(' ', 12);
-
-            sb.AppendLine($"{tab2}{{");
-            sb.AppendLine($"{tab3}CodeOffset: {CodeOffset}");
-            sb.AppendLine($"{tab3}UnwindOp: {UnwindOp}");
-            sb.AppendLine($"{tab3}OpInfo: {OpInfo}");
-            sb.AppendLine($"{tab2}}}");
-            sb.AppendLine($"{tab2}{{");
-            sb.AppendLine($"{tab3}OffsetLow: {OffsetLow}");
-            sb.AppendLine($"{tab3}UnwindOp: {UnwindOp}");
-            sb.AppendLine($"{tab3}OffsetHigh: {OffsetHigh}");
-            sb.AppendLine($"{tab2}}}");
-            sb.AppendLine($"{tab2}FrameOffset: {FrameOffset}");
-            sb.AppendLine($"{tab2}------------------");
+
+            sb.AppendLine($"\t\t{{");
+            sb.AppendLine($"\t\t\tCodeOffset: {CodeOffset}");
+            sb.AppendLine($"\t\t\tUnwindOp: {UnwindOp}");
+            sb.AppendLine($"\t\t\tOpInfo: {OpInfo}");
+            sb.AppendLine($"\t\t}}");
+            sb.AppendLine($"\t\t{{");
+            sb.AppendLine($"\t\t\tOffsetLow: {OffsetLow}");
+            sb.AppendLine($"\t\t\tUnwindOp: {UnwindOp}");
+            sb.AppendLine($"\t\t\tOffsetHigh: {OffsetHigh}");
+            sb.AppendLine($"\t\t}}");
+            sb.AppendLine($"\t\tFrameOffset: {FrameOffset}");
+            sb.AppendLine($"\t\t------------------");
 
             return sb.ToString();
         }
@@ -96,22 +94,21 @@ namespace R2RDump
         public override string ToString()
         {
             StringBuilder sb = new StringBuilder();
-            string tab = "    ";
-
-            sb.AppendLine($"{tab}Version: {Version}");
-            sb.AppendLine($"{tab}Flags: 0x{Flags:X8}");
-            sb.AppendLine($"{tab}SizeOfProlog: {SizeOfProlog}");
-            sb.AppendLine($"{tab}CountOfUnwindCodes: {CountOfUnwindCodes}");
-            sb.AppendLine($"{tab}FrameRegister: {FrameRegister}");
-            sb.AppendLine($"{tab}FrameOffset: {FrameOffset}");
-            sb.AppendLine($"{tab}Unwind Codes:");
-            sb.AppendLine($"{tab}{tab}------------------");
+
+            sb.AppendLine($"\tVersion: {Version}");
+            sb.AppendLine($"\tFlags: 0x{Flags:X8}");
+            sb.AppendLine($"\tSizeOfProlog: {SizeOfProlog}");
+            sb.AppendLine($"\tCountOfUnwindCodes: {CountOfUnwindCodes}");
+            sb.AppendLine($"\tFrameRegister: {FrameRegister}");
+            sb.AppendLine($"\tFrameOffset: {FrameOffset}");
+            sb.AppendLine($"\tUnwind Codes:");
+            sb.AppendLine($"\t\t------------------");
             for (int i = 0; i < CountOfUnwindCodes; i++)
             {
                 sb.Append(UnwindCode[i].ToString());
             }
-            sb.AppendLine($"{tab}PersonalityRoutineRVA: 0x{PersonalityRoutineRVA:X8}");
-            sb.AppendLine($"{tab}Size: {Size} bytes");
+            sb.AppendLine($"\tPersonalityRoutineRVA: 0x{PersonalityRoutineRVA:X8}");
+            sb.AppendLine($"\tSize: {Size} bytes");
 
             return sb.ToString();
         }