From d387b452a5f57982c13332fa8540ec21e3779ff2 Mon Sep 17 00:00:00 2001 From: Amy Yu Date: Tue, 19 Jun 2018 11:22:03 -0700 Subject: [PATCH] Save name of dll in constant, use tab instead of spaces Commit migrated from https://github.com/dotnet/coreclr/commit/a5c843564c4dd8301b0c424f6041fada2921b1ab --- src/coreclr/src/tools/r2rdump/CoreDisTools.cs | 14 +++--- src/coreclr/src/tools/r2rdump/GCInfo.cs | 62 +++++++++++++-------------- src/coreclr/src/tools/r2rdump/GCInfoTypes.cs | 5 +-- src/coreclr/src/tools/r2rdump/GCSlotTable.cs | 17 +++----- src/coreclr/src/tools/r2rdump/UnwindInfo.cs | 51 +++++++++++----------- 5 files changed, 71 insertions(+), 78 deletions(-) diff --git a/src/coreclr/src/tools/r2rdump/CoreDisTools.cs b/src/coreclr/src/tools/r2rdump/CoreDisTools.cs index ad3b7b4..6070e43 100644 --- a/src/coreclr/src/tools/r2rdump/CoreDisTools.cs +++ b/src/coreclr/src/tools/r2rdump/CoreDisTools.cs @@ -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) diff --git a/src/coreclr/src/tools/r2rdump/GCInfo.cs b/src/coreclr/src/tools/r2rdump/GCInfo.cs index 0442286..cf57db6 100644 --- a/src/coreclr/src/tools/r2rdump/GCInfo.cs +++ b/src/coreclr/src/tools/r2rdump/GCInfo.cs @@ -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(); } diff --git a/src/coreclr/src/tools/r2rdump/GCInfoTypes.cs b/src/coreclr/src/tools/r2rdump/GCInfoTypes.cs index b8e981f..9b44a59 100644 --- a/src/coreclr/src/tools/r2rdump/GCInfoTypes.cs +++ b/src/coreclr/src/tools/r2rdump/GCInfoTypes.cs @@ -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(); } diff --git a/src/coreclr/src/tools/r2rdump/GCSlotTable.cs b/src/coreclr/src/tools/r2rdump/GCSlotTable.cs index df2c310..f2ebf41 100644 --- a/src/coreclr/src/tools/r2rdump/GCSlotTable.cs +++ b/src/coreclr/src/tools/r2rdump/GCSlotTable.cs @@ -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(); diff --git a/src/coreclr/src/tools/r2rdump/UnwindInfo.cs b/src/coreclr/src/tools/r2rdump/UnwindInfo.cs index 9742aa0..da12f4f 100644 --- a/src/coreclr/src/tools/r2rdump/UnwindInfo.cs +++ b/src/coreclr/src/tools/r2rdump/UnwindInfo.cs @@ -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(); } -- 2.7.4