Update Microsoft.NETCore.CoreDisTools to version 1.0.1-prerelease-00005 (dotnet/corec...
authorZach Montoya <zamont@microsoft.com>
Mon, 20 Aug 2018 21:08:41 +0000 (14:08 -0700)
committerGitHub <noreply@github.com>
Mon, 20 Aug 2018 21:08:41 +0000 (14:08 -0700)
* Update Microsoft.NETCore.CoreDisTools to version 1.0.1-prerelease-00005. Temporarily add a direct reference to the win-x64 and win-x86 runtime packages

* Change Microsoft.NETCore.CoreDisTools package references to the identity package.

Improve formatting of R2RDump.csproj properties.

* Add an ArgumentException to explain the currently faulty behavior where disassembling an R2R image whose architecture is different than the coredistools.dll architecture.

* Add Issue dotnet/coreclr#19564 to the R2RDump.cs Disassembler comment

Commit migrated from https://github.com/dotnet/coreclr/commit/ab8023d9e2d70072d0017191eacca449c4e1c33b

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

index 6fa93b8..1beeaf6 100644 (file)
@@ -114,8 +114,6 @@ namespace R2RDump
                 _sectionContents = true;
             }
 
-            _disasm = false; // TODO: this requires the coredistools nuget package with the most recent changes
-
             return argSyntax;
         }
 
@@ -405,7 +403,17 @@ namespace R2RDump
 
                     if (_disasm)
                     {
-                        disassembler = new Disassembler(r2r.Image, r2r.Machine);
+                        // 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())
+                        {
+                            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()}");
+                        }
                     }
 
                     if (_xml)
index b0ad5a3..026e4a5 100644 (file)
@@ -1,5 +1,5 @@
-<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
 
   <PropertyGroup>
     <AssemblyName>R2RDump</AssemblyName>
@@ -7,18 +7,20 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <OutputType>Exe</OutputType>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-       <AssemblyKey>Open</AssemblyKey>
-       <IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
-       <TargetFramework>netcoreapp2.0</TargetFramework>
-       <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
-       <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
-       <CLSCompliant>false</CLSCompliant>
-       <NoWarn>8002,NU1701</NoWarn>
+    <AssemblyKey>Open</AssemblyKey>
+    <IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+    <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
+    <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
+    <CLSCompliant>false</CLSCompliant>
+    <NoWarn>8002,NU1701</NoWarn>
+    <RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
   </PropertyGroup>
 
+
   <ItemGroup>
     <PackageReference Include="Microsoft.NETCore.CoreDisTools">
-      <Version>1.0.1-prerelease-00003</Version>
+      <Version>1.0.1-prerelease-00005</Version>
     </PackageReference>
     <PackageReference Include="System.CommandLine">
       <Version>0.1.0-e160119-1</Version>
index f0177cf..fedc68e 100644 (file)
@@ -174,6 +174,24 @@ namespace R2RDump
             }
         }
 
+        public bool InputArchitectureMatchesDisassemblerArchitecture()
+        {
+            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;
+            }
+        }
+
         /// <summary>
         /// Each runtime function entry has 3 fields for Amd64 machines (StartAddress, EndAddress, UnwindRVA), otherwise 2 fields (StartAddress, UnwindRVA)
         /// </summary>