From: Amy Date: Sun, 26 Aug 2018 03:55:04 +0000 (-0700) Subject: R2RDump - Check disassembler support (#19664) X-Git-Tag: accepted/tizen/unified/20190422.045933~1354 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2b76e093c71f471b0eb59192c3f0b0d409410b1;p=platform%2Fupstream%2Fcoreclr.git R2RDump - Check disassembler support (#19664) * Determine if disasm is supported on architectures instead of match * Readme changes --- diff --git a/src/tools/r2rdump/R2RDump.cs b/src/tools/r2rdump/R2RDump.cs index c374050..e83931c 100644 --- a/src/tools/r2rdump/R2RDump.cs +++ b/src/tools/r2rdump/R2RDump.cs @@ -403,16 +403,13 @@ namespace R2RDump if (_disasm) { - // TODO: Fix R2RDump issue where an x64 R2R image cannot be dissassembled with the x86 CoreDisTools - // For the short term, we want to error out with a decent message explaining the unexpected error - // Issue #19564: https://github.com/dotnet/coreclr/issues/19564 - if (r2r.InputArchitectureMatchesDisassemblerArchitecture()) + if (r2r.InputArchitectureSupported() && r2r.DisassemblerArchitectureSupported()) { disassembler = new Disassembler(r2r.Image, r2r.Machine); } else { - throw new ArgumentException($"The architecture of input file {filename} is {r2r.Machine.ToString()} and does not match the architecture of the disassembler tools {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString()}"); + throw new ArgumentException($"The architecture of input file {filename} ({r2r.Machine.ToString()}) or the architecture of the disassembler tools ({System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString()}) is not supported."); } } diff --git a/src/tools/r2rdump/R2RReader.cs b/src/tools/r2rdump/R2RReader.cs index d6b39a9..2a6c410 100644 --- a/src/tools/r2rdump/R2RReader.cs +++ b/src/tools/r2rdump/R2RReader.cs @@ -174,22 +174,18 @@ namespace R2RDump } } - public bool InputArchitectureMatchesDisassemblerArchitecture() + public bool InputArchitectureSupported() + { + return Machine != Machine.ArmThumb2; // CoreDisTools often fails to decode when disassembling ARM images (see https://github.com/dotnet/coreclr/issues/19637) + } + + // TODO: Fix R2RDump issue where an R2R image cannot be dissassembled with the x86 CoreDisTools + // For the short term, we want to error out with a decent message explaining the unexpected error + // Issue #19564: https://github.com/dotnet/coreclr/issues/19564 + public bool DisassemblerArchitectureSupported() { System.Runtime.InteropServices.Architecture val = System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture; - switch (Machine) - { - case Machine.Amd64: - return val == System.Runtime.InteropServices.Architecture.X64; - case Machine.I386: - return val == System.Runtime.InteropServices.Architecture.X86; - case Machine.Arm64: - return val == System.Runtime.InteropServices.Architecture.Arm64; - case Machine.ArmThumb2: - return val == System.Runtime.InteropServices.Architecture.Arm; - default: - return false; - } + return val != System.Runtime.InteropServices.Architecture.X86; } /// diff --git a/src/tools/r2rdump/README.md b/src/tools/r2rdump/README.md index 5f022aa..d83b68d 100644 --- a/src/tools/r2rdump/README.md +++ b/src/tools/r2rdump/README.md @@ -107,10 +107,10 @@ In x64/Arm/Arm64, GcTransitions are grouped into chunks where each chunk covers * Support R2RDump on ARM and ARM64 (https://github.com/dotnet/coreclr/issues/19089) -* Fix issue with invalid machine type in COFF header (https://github.com/dotnet/coreclr/issues/19592) - * Parse R2RSections: READYTORUN_SECTION_EXCEPTION_INFO, READYTORUN_SECTION_DEBUG_INFO, READYTORUN_SECTION_DELAYLOAD_METHODCALL_THUNKS, READYTORUN_SECTION_INLINING_INFO, READYTORUN_SECTION_PROFILEDATA_INFO (https://github.com/dotnet/coreclr/issues/19616) * Reenable R2RDumpTests after making it less fragile -* Fix issue with disasm on Arm (https://github.com/dotnet/coreclr/issues/19637) +* Fix issues with disasm on Arm (https://github.com/dotnet/coreclr/issues/19637) and disasm using x86 coredistools (https://github.com/dotnet/coreclr/issues/19564) + +* Test R2RDump on more test cases to make sure it runs reliably and verify that the output is accurate (list of failing inputs: https://github.com/dotnet/coreclr/issues/19642)