From 113c0a04d6042575315bd6a828d8bd354161832b Mon Sep 17 00:00:00 2001 From: Amy Date: Sat, 25 Aug 2018 20:55:04 -0700 Subject: [PATCH] R2RDump - Check disassembler support (dotnet/coreclr#19664) * Determine if disasm is supported on architectures instead of match * Readme changes Commit migrated from https://github.com/dotnet/coreclr/commit/d2b76e093c71f471b0eb59192c3f0b0d409410b1 --- src/coreclr/src/tools/r2rdump/R2RDump.cs | 7 ++----- src/coreclr/src/tools/r2rdump/R2RReader.cs | 24 ++++++++++-------------- src/coreclr/src/tools/r2rdump/README.md | 6 +++--- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/coreclr/src/tools/r2rdump/R2RDump.cs b/src/coreclr/src/tools/r2rdump/R2RDump.cs index c374050..e83931c 100644 --- a/src/coreclr/src/tools/r2rdump/R2RDump.cs +++ b/src/coreclr/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/coreclr/src/tools/r2rdump/R2RReader.cs b/src/coreclr/src/tools/r2rdump/R2RReader.cs index d6b39a9..2a6c410 100644 --- a/src/coreclr/src/tools/r2rdump/R2RReader.cs +++ b/src/coreclr/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/coreclr/src/tools/r2rdump/README.md b/src/coreclr/src/tools/r2rdump/README.md index 5f022aa..d83b68d 100644 --- a/src/coreclr/src/tools/r2rdump/README.md +++ b/src/coreclr/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) -- 2.7.4