Use PEFile instead of clrmd's PEImage (#2769)
authorMike McLaughlin <mikem@microsoft.com>
Wed, 8 Dec 2021 01:24:32 +0000 (17:24 -0800)
committerGitHub <noreply@github.com>
Wed, 8 Dec 2021 01:24:32 +0000 (01:24 +0000)
* Use PEFile instead of clrmd's PEImage

Fix various problems with figuring out the file/loaded layout of a module.

Add some help scripts to rebuild existing test asset packages (xml files).

* Fix test.sh

* Log full exception stack

* Code review feedback

29 files changed:
eng/testassets/rebuild/TestAssets.Linux.arm64.3.1.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Linux.arm64.5.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Linux.arm64.6.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Linux.x64.3.1.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Linux.x64.5.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Linux.x64.6.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Windows.x64.3.1.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Windows.x64.5.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Windows.x64.6.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Windows.x86.3.1.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Windows.x86.5.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/TestAssets.Windows.x86.6.0.nuspec [new file with mode: 0644]
eng/testassets/rebuild/pack.csproj [new file with mode: 0644]
eng/testassets/rebuild/package.cmd [new file with mode: 0644]
eng/testassets/rebuild/rewritexml.cmd [new file with mode: 0644]
src/Microsoft.Diagnostics.DebugServices.Implementation/MetadataMappingMemoryService.cs
src/Microsoft.Diagnostics.DebugServices.Implementation/Module.cs
src/Microsoft.Diagnostics.DebugServices.Implementation/ModuleService.cs
src/Microsoft.Diagnostics.DebugServices.Implementation/Utilities.cs
src/Microsoft.Diagnostics.DebugServices/IModule.cs
src/Microsoft.Diagnostics.DebugServices/PdbFileInfo.cs
src/Microsoft.Diagnostics.ExtensionCommands/ClrModulesCommand.cs
src/Microsoft.Diagnostics.ExtensionCommands/Host/ModulesCommand.cs
src/Microsoft.Diagnostics.Repl/Console/ConsoleProvider.cs
src/SOS/SOS.Extensions/ModuleServiceFromDebuggerServices.cs
src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/DebugServicesTests.cs
src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/Microsoft.Diagnostics.DebugServices.UnitTests.csproj
src/tests/Microsoft.Diagnostics.DebugServices.UnitTests/TestDataWriter.cs
test.sh

diff --git a/eng/testassets/rebuild/TestAssets.Linux.arm64.3.1.nuspec b/eng/testassets/rebuild/TestAssets.Linux.arm64.3.1.nuspec
new file mode 100644 (file)
index 0000000..67f1b7d
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Linux.arm64.3.1</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Linux.arm64.3.1</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Linux arm64 on .NET 3.1.18 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Linux.arm64.3.1\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Linux.arm64.5.0.nuspec b/eng/testassets/rebuild/TestAssets.Linux.arm64.5.0.nuspec
new file mode 100644 (file)
index 0000000..2bddf3a
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Linux.arm64.5.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Linux.arm64.5.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Linux arm64 on .NET 5.0.9 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Linux.arm64.5.0\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+    <file src="TestAssets.Linux.arm64.5.0\1.0.246501\content\LineNums\*.*" target="content/LineNums" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Linux.arm64.6.0.nuspec b/eng/testassets/rebuild/TestAssets.Linux.arm64.6.0.nuspec
new file mode 100644 (file)
index 0000000..14af24c
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Linux.arm64.6.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Linux.arm64.6.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Linux arm64 on .NET 6.0.0 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Linux.arm64.6.0\1.0.246501\content\DivZero\*.*" target="content/DivZero" />
+    <file src="TestAssets.Linux.arm64.6.0\1.0.246501\content\WebApp3\*.*" target="content/WebApp3" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Linux.x64.3.1.nuspec b/eng/testassets/rebuild/TestAssets.Linux.x64.3.1.nuspec
new file mode 100644 (file)
index 0000000..ed962c4
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Linux.x64.3.1</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Linux.x64.3.1</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Linux x64 on .NET 3.1.18 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Linux.x64.3.1\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Linux.x64.5.0.nuspec b/eng/testassets/rebuild/TestAssets.Linux.x64.5.0.nuspec
new file mode 100644 (file)
index 0000000..1fffb4b
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Linux.x64.5.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Linux.x64.5.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Linux x64 on .NET 5.0.9 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Linux.x64.5.0\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+    <file src="TestAssets.Linux.x64.5.0\1.0.246501\content\LineNums\*.*" target="content/LineNums" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Linux.x64.6.0.nuspec b/eng/testassets/rebuild/TestAssets.Linux.x64.6.0.nuspec
new file mode 100644 (file)
index 0000000..1dc30e4
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Linux.x64.6.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Linux.x64.6.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Linux x64 on .NET 6.0.0 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Linux.x64.6.0\1.0.246501\content\DivZero\*.*" target="content/DivZero" />
+    <file src="TestAssets.Linux.x64.6.0\1.0.246501\content\WebApp3\*.*" target="content/WebApp3" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Windows.x64.3.1.nuspec b/eng/testassets/rebuild/TestAssets.Windows.x64.3.1.nuspec
new file mode 100644 (file)
index 0000000..8d98a46
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Windows.x64.3.1</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Windows.x64.3.1</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Windows x64 on .NET 3.1.18 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Windows.x64.3.1\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Windows.x64.5.0.nuspec b/eng/testassets/rebuild/TestAssets.Windows.x64.5.0.nuspec
new file mode 100644 (file)
index 0000000..4c3957a
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Windows.x64.5.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Windows.x64.5.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Windows x64 on .NET 5.0.9 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Windows.x64.5.0\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+    <file src="TestAssets.Windows.x64.5.0\1.0.246501\content\DualRuntimes\*.*" target="content/DualRuntimes" />
+    <file src="TestAssets.Windows.x64.5.0\1.0.246501\content\LineNums\*.*" target="content/LineNums" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Windows.x64.6.0.nuspec b/eng/testassets/rebuild/TestAssets.Windows.x64.6.0.nuspec
new file mode 100644 (file)
index 0000000..bcd07ee
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Windows.x64.6.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Windows.x64.6.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Windows x64 on .NET 6.0.0 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Windows.x64.6.0\1.0.246501\content\DivZero\*.*" target="content/DivZero" />
+    <file src="TestAssets.Windows.x64.6.0\1.0.246501\content\WebApp3\*.*" target="content/WebApp3" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Windows.x86.3.1.nuspec b/eng/testassets/rebuild/TestAssets.Windows.x86.3.1.nuspec
new file mode 100644 (file)
index 0000000..2a8a451
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Windows.x86.3.1</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Windows.x86.3.1</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Windows x86 on .NET 3.1.18 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Windows.x86.3.1\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Windows.x86.5.0.nuspec b/eng/testassets/rebuild/TestAssets.Windows.x86.5.0.nuspec
new file mode 100644 (file)
index 0000000..53c3894
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Windows.x86.5.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Windows.x86.5.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Windows x86 on .NET 5.0.9 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Windows.x86.5.0\1.0.246501\content\SymbolTestApp\*.*" target="content/SymbolTestApp" />
+    <file src="TestAssets.Windows.x86.5.0\1.0.246501\content\DualRuntimes\*.*" target="content/DualRuntimes" />
+    <file src="TestAssets.Windows.x86.5.0\1.0.246501\content\LineNums\*.*" target="content/LineNums" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/TestAssets.Windows.x86.6.0.nuspec b/eng/testassets/rebuild/TestAssets.Windows.x86.6.0.nuspec
new file mode 100644 (file)
index 0000000..e6b27c5
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<package >
+  <metadata>
+    <id>TestAssets.Windows.x86.6.0</id>
+    <version>1.0.0</version>
+    <title>TestAssets.Windows.x86.6.0</title>
+    <authors>Microsoft</authors>
+    <owners>Microsoft</owners>
+    <description>
+      Test assets for Windows x86 on .NET 6.0.0 runtime
+    </description>
+    <releaseNotes>
+    </releaseNotes>
+    <summary>
+      Test assets
+    </summary>
+    <language>en-US</language>
+    <projectUrl>https://github.com/dotnet/diagnostics.git</projectUrl>
+    <iconUrl>https://nuget.org/Content/Images/packageDefaultIcon-50x50.png</iconUrl>
+    <copyright>Copyright 2021</copyright>
+  </metadata>
+  <files>
+    <file src="TestAssets.Windows.x86.6.0\1.0.246501\content\DivZero\*.*" target="content/DivZero" />
+    <file src="TestAssets.Windows.x86.6.0\1.0.246501\content\WebApp3\*.*" target="content/WebApp3" />
+  </files>
+</package>
diff --git a/eng/testassets/rebuild/pack.csproj b/eng/testassets/rebuild/pack.csproj
new file mode 100644 (file)
index 0000000..5f08b4b
--- /dev/null
@@ -0,0 +1,15 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <TargetFramework>netstandard2.0</TargetFramework>
+    <IsPackable>true</IsPackable>
+    <IsShippingPackage>false</IsShippingPackage>
+    <PreReleaseVersionLabel></PreReleaseVersionLabel>
+    <VersionPrefix></VersionPrefix>
+    <DotNetUseShippingVersions>true</DotNetUseShippingVersions>
+    <NoPackageAnalysis>true</NoPackageAnalysis>
+    <NoBuild>true</NoBuild>
+    <IncludeBuildOutput>false</IncludeBuildOutput>
+    <NuspecProperties></NuspecProperties>
+    <NuspecBasePath>$(USERPROFILE)\.nuget\packages\</NuspecBasePath>
+  </PropertyGroup>
+</Project>
diff --git a/eng/testassets/rebuild/package.cmd b/eng/testassets/rebuild/package.cmd
new file mode 100644 (file)
index 0000000..26f5eb9
--- /dev/null
@@ -0,0 +1,14 @@
+setlocal
+set _REPOROOT_=%~dp0..\..\..
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Linux.arm64.3.1.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Linux.arm64.5.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Linux.arm64.6.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Linux.x64.3.1.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Linux.x64.5.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Linux.x64.6.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Windows.x64.3.1.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Windows.x64.5.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Windows.x64.6.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Windows.x86.3.1.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Windows.x86.5.0.nuspec
+%_REPOROOT_%\.dotnet\dotnet.exe pack pack.csproj -p:NuspecFile=TestAssets.Windows.x86.6.0.nuspec
diff --git a/eng/testassets/rebuild/rewritexml.cmd b/eng/testassets/rebuild/rewritexml.cmd
new file mode 100644 (file)
index 0000000..235aa32
--- /dev/null
@@ -0,0 +1,28 @@
+setlocal
+set ORIGINAL_VERSION=1.0.246501
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.arm64.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.linux.arm64.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.arm64.5.0\%ORIGINAL_VERSION%\content\LineNums\SOS.LineNums.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.linux.arm64.5.0\%ORIGINAL_VERSION%\content\LineNums
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.arm64.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.linux.arm64.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.arm64.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.linux.arm64.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.arm64.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Triage.dmp %USERPROFILE%\.nuget\packages\testassets.linux.arm64.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.arm64.6.0\%ORIGINAL_VERSION%\content\WebApp3\SOS.WebApp3.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.linux.arm64.6.0\%ORIGINAL_VERSION%\content\WebApp3
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.x64.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.linux.x64.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.x64.5.0\%ORIGINAL_VERSION%\content\LineNums\SOS.LineNums.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.linux.x64.5.0\%ORIGINAL_VERSION%\content\LineNums
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.x64.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.linux.x64.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.x64.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.linux.x64.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.x64.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Triage.dmp %USERPROFILE%\.nuget\packages\testassets.linux.x64.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.linux.x64.6.0\%ORIGINAL_VERSION%\content\WebApp3\SOS.WebApp3.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.linux.x64.6.0\%ORIGINAL_VERSION%\content\WebApp3
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.5.0\%ORIGINAL_VERSION%\content\DualRuntimes\SOS.DualRuntimes.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.5.0\%ORIGINAL_VERSION%\content\DualRuntimes
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.5.0\%ORIGINAL_VERSION%\content\LineNums\SOS.LineNums.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.5.0\%ORIGINAL_VERSION%\content\LineNums
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Triage.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x64.6.0\%ORIGINAL_VERSION%\content\WebApp3\SOS.WebApp3.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x64.6.0\%ORIGINAL_VERSION%\content\WebApp3
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.3.1\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.5.0\%ORIGINAL_VERSION%\content\DualRuntimes\SOS.DualRuntimes.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.5.0\%ORIGINAL_VERSION%\content\DualRuntimes
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.5.0\%ORIGINAL_VERSION%\content\LineNums\SOS.LineNums.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.5.0\%ORIGINAL_VERSION%\content\LineNums
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp\SOS.StackAndOtherTests.Heap.portable.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.5.0\%ORIGINAL_VERSION%\content\SymbolTestApp
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.6.0\%ORIGINAL_VERSION%\content\DivZero\SOS.DivZero.Triage.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.6.0\%ORIGINAL_VERSION%\content\DivZero
+call ..\writexml_x86.cmd %USERPROFILE%\.nuget\packages\testassets.windows.x86.6.0\%ORIGINAL_VERSION%\content\WebApp3\SOS.WebApp3.Heap.dmp %USERPROFILE%\.nuget\packages\testassets.windows.x86.6.0\%ORIGINAL_VERSION%\content\WebApp3
index 543f548b259d1b724c3b2adaa1c771a9655d0829..e2811bd58c3da72d3e090410c572321714e133d5 100644 (file)
@@ -4,6 +4,8 @@
 
 using Microsoft.Diagnostics.Runtime;
 using Microsoft.Diagnostics.Runtime.Utilities;
+using Microsoft.FileFormats;
+using Microsoft.FileFormats.PE;
 using System;
 using System.Collections.Immutable;
 using System.Diagnostics;
@@ -162,22 +164,18 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
             bool isVirtual = module.Layout != ModuleLayout.Flat;
             try
             {
-                ulong size = module.Size;
-                if (size == 0) {
-                    size = 4096;
-                }
-                Stream stream = _memoryService.CreateMemoryStream(module.ImageBase, size);
-                var peImage = new PEImage(stream, leaveOpen: false, isVirtual);
-                if (peImage.IsValid)
+                Stream stream = _memoryService.CreateMemoryStream(module.ImageBase, module.Size > 0 ? module.Size : 4096);
+                PEFile peFile = new(new StreamAddressSpace(stream), isVirtual);
+                if (peFile.IsValid())
                 {
-                    metadata = SymbolService.GetMetadata(module.Name, (uint)peImage.IndexTimeStamp, (uint)peImage.IndexFileSize);
+                    metadata = SymbolService.GetMetadata(module.Name, peFile.Timestamp, peFile.SizeOfImage);
                 }
                 else
                 {
                     Trace.TraceError($"GetMetaData: {module.ImageBase:X16} not valid PE");
                 }
             }
-            catch (Exception ex) when (ex is BadImageFormatException || ex is EndOfStreamException || ex is IOException)
+            catch (Exception ex) when (ex is InvalidVirtualAddressException || ex is BadInputFormatException)
             {
                 Trace.TraceError($"GetMetaData: loaded {module.ImageBase:X16} exception {ex.Message}");
             }
index b614a2fd56f3c3f7d41509cca6d20c916fa7ed0a..c38f459a568e8b369be191b1177d3cd074f5425c 100644 (file)
@@ -8,12 +8,12 @@ using Microsoft.FileFormats.ELF;
 using Microsoft.FileFormats.MachO;
 using Microsoft.FileFormats.PE;
 using System;
+using System.Collections.Generic;
 using System.Collections.Immutable;
 using System.Diagnostics;
 using System.IO;
 using System.Reflection.PortableExecutable;
 using System.Runtime.InteropServices;
-using FileVersionInfo = Microsoft.Diagnostics.Runtime.Utilities.FileVersionInfo;
 
 namespace Microsoft.Diagnostics.DebugServices.Implementation
 {
@@ -37,16 +37,16 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
 
         private readonly IDisposable _onChangeEvent;
         private Flags _flags;
-        private PdbFileInfo _pdbFileInfo;
+        private IEnumerable<PdbFileInfo> _pdbFileInfos;
         protected ImmutableArray<byte> _buildId;
-        private PEImage _peImage;
+        private PEFile _peFile;
 
         public readonly ServiceProvider ServiceProvider;
 
         public Module(ITarget target)
         {
             ServiceProvider = new ServiceProvider();
-            ServiceProvider.AddServiceFactoryWithNoCaching<PEImage>(() => GetPEInfo());
+            ServiceProvider.AddServiceFactoryWithNoCaching<PEFile>(() => GetPEInfo());
 
             ServiceProvider.AddServiceFactory<PEReader>(() => ModuleService.GetPEReader(this));
             if (target.OperatingSystem == OSPlatform.Linux) {
@@ -116,35 +116,31 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         {
             get
             {
-                // For Windows targets we can assume that the file layout is always "loaded". The
-                // ImageMappingMemoryService depends on no recursion memory access for this property
-                // i.e. calling GetPEInfo().
-                if (Target.OperatingSystem == OSPlatform.Windows)
+                GetPEInfo();
+                if ((_flags & Flags.IsFileLayout) != 0)
+                {
+                    return true;
+                }
+                if ((_flags & Flags.IsLoadedLayout) != 0)
                 {
                     return false;
                 }
-                else
+                // Native Windows dlls default to file layout
+                if ((_flags & Flags.IsManaged) == 0 && Target.OperatingSystem == OSPlatform.Windows)
                 {
-                    GetPEInfo();
-                    if ((_flags & Flags.IsFileLayout) != 0)
-                    {
-                        return true;
-                    }
-                    if ((_flags & Flags.IsLoadedLayout) != 0)
-                    {
-                        return false;
-                    }
-                    return null;
+                    return false;
                 }
+                return null;
             }
         }
 
-        public PdbFileInfo PdbFileInfo
+        public IEnumerable<PdbFileInfo> PdbFileInfos
         {
             get
             {
                 GetPEInfo();
-                return _pdbFileInfo;
+                Debug.Assert(_pdbFileInfos is not null);
+                return _pdbFileInfos;
             }
         }
 
@@ -229,13 +225,20 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         {
             VersionData versionData = null;
 
-            PEImage peImage = GetPEInfo();
-            if (peImage != null)
+            PEFile peFile = GetPEInfo();
+            if (peFile != null)
             {
-                FileVersionInfo fileVersionInfo = peImage.GetFileVersionInfo();
-                if (fileVersionInfo != null)
+                try
                 {
-                    versionData = fileVersionInfo.VersionInfo.ToVersionData();
+                    VsFixedFileInfo fileInfo = peFile.VersionInfo;
+                    if (fileInfo != null)
+                    {
+                        versionData = fileInfo.ToVersionData();
+                    }
+                }
+                catch (Exception ex) when (ex is InvalidVirtualAddressException || ex is BadInputFormatException)
+                {
+                    Trace.TraceError($"GetVersion: exception {ex.Message}");
                 }
             }
             else 
@@ -273,12 +276,13 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
             return versionData;
         }
 
-        protected PEImage GetPEInfo()
+        protected PEFile GetPEInfo()
         {
-            if (InitializeValue(Flags.InitializePEInfo)) {
-                _peImage = ModuleService.GetPEInfo(ImageBase, ImageSize, ref _pdbFileInfo, ref _flags);
+            if (InitializeValue(Flags.InitializePEInfo))
+            {
+                _peFile = ModuleService.GetPEInfo(ImageBase, ImageSize, out _pdbFileInfos, ref _flags);
             }
-            return _peImage;
+            return _peFile;
         }
 
         protected bool InitializeValue(Flags flag)
index 253a2be6e1a61a6de168705c7ef6a66852dc15cc..db9576604089ab33ce3c94fa744250961aba2a45 100644 (file)
@@ -2,7 +2,6 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
-using Microsoft.Diagnostics.Runtime.Utilities;
 using Microsoft.FileFormats;
 using Microsoft.FileFormats.ELF;
 using Microsoft.FileFormats.MachO;
@@ -204,62 +203,76 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         /// </summary>
         /// <param name="address">module base address</param>
         /// <param name="size">module size</param>
-        /// <param name="pdbFileInfo">the pdb record or null</param>
-        /// <param name="flags">module flags</param>
+        /// <param name="pdbFileInfos">the pdb records or null</param>
+        /// <param name="moduleFlags">module flags</param>
         /// <returns>PEImage instance or null</returns>
-        internal PEImage GetPEInfo(ulong address, ulong size, ref PdbFileInfo pdbFileInfo, ref Module.Flags flags)
+        internal PEFile GetPEInfo(ulong address, ulong size, out IEnumerable<PdbFileInfo> pdbFileInfos, ref Module.Flags moduleFlags)
         {
-            PEImage peImage = null;
+            PEFile peFile = null;
+
+            // Start off with no pdb infos and as a native non-PE non-managed module
+            pdbFileInfos = Array.Empty<PdbFileInfo>();
+            moduleFlags &= ~(Module.Flags.IsPEImage | Module.Flags.IsManaged | Module.Flags.IsLoadedLayout | Module.Flags.IsFileLayout);
 
             // None of the modules that lldb (on either Linux/MacOS) provides are PEs
             if (Target.Host.HostType != HostType.Lldb)
             {
-                // First try getting the PE info as load layout (native Windows DLLs and most managed PEs on Linux/MacOS).
-                peImage = GetPEInfo(isVirtual: true, address: address, size: size, pdbFileInfo: ref pdbFileInfo, flags: ref flags);
-                if (peImage == null)
+                // First try getting the PE info as loaded layout (native Windows DLLs and most managed PEs).
+                peFile = GetPEInfo(isVirtual: true, address, size, out List<PdbFileInfo> pdbs, out Module.Flags flags);
+                if (peFile is null || pdbs.Count == 0)
                 {
-                    if (Target.OperatingSystem != OSPlatform.Windows)
+                    // If PE file is invalid or there are no PDB records, try getting the PE info as file layout. No PDB records can mean
+                    // that either the layout is wrong or that there really no PDB records. If file layout doesn't have any pdb records
+                    // either default to loaded layout PEFile.
+                    PEFile peFileLayout = GetPEInfo(isVirtual: false, address, size, out List<PdbFileInfo> pdbsFileLayout, out Module.Flags flagsFileLayout);
+                    if (peFileLayout is not null && (peFile is null || pdbsFileLayout.Count > 0))
                     {
-                        // Then try getting the PE info as file layout (some managed PEs on Linux/MacOS).
-                        peImage = GetPEInfo(isVirtual: false, address: address, size: size, pdbFileInfo: ref pdbFileInfo, flags: ref flags);
+                        flags = flagsFileLayout;
+                        pdbs = pdbsFileLayout;
+                        peFile = peFileLayout;
                     }
                 }
+                if (peFile is not null)
+                {
+                    moduleFlags |= flags;
+                    pdbFileInfos = pdbs;
+                }
             }
-            return peImage;
+
+            return peFile;
         }
 
         /// <summary>
-        /// Returns information about the PE file.
+        /// Returns information about the PE file for a specific layout.
         /// </summary>
         /// <param name="isVirtual">the memory layout of the module</param>
         /// <param name="address">module base address</param>
         /// <param name="size">module size</param>
-        /// <param name="pdbFileInfo">the pdb record or null</param>
+        /// <param name="pdbs">pdb infos</param>
         /// <param name="flags">module flags</param>
-        /// 
-        /// <returns>PEImage instance or null</returns>
-        private PEImage GetPEInfo(bool isVirtual, ulong address, ulong size, ref PdbFileInfo pdbFileInfo, ref Module.Flags flags)
+        /// <returns>PEFile instance or null</returns>
+        private PEFile GetPEInfo(bool isVirtual, ulong address, ulong size, out List<PdbFileInfo> pdbs, out Module.Flags flags)
         {
-            Stream stream = RawMemoryService.CreateMemoryStream(address, size);
+            pdbs = null;
+            flags = 0;
             try
             {
-                stream.Position = 0;
-                var peImage = new PEImage(stream, leaveOpen: false, isVirtual);
-                if (peImage.IsValid)
+                Stream stream = RawMemoryService.CreateMemoryStream(address, size);
+                PEFile peFile = new(new StreamAddressSpace(stream), isVirtual);
+                if (peFile.IsValid())
                 {
                     flags |= Module.Flags.IsPEImage;
-                    flags |= peImage.IsManaged ? Module.Flags.IsManaged : Module.Flags.None;
-                    pdbFileInfo = peImage.DefaultPdb?.ToPdbFileInfo();
-                    flags &= ~(Module.Flags.IsLoadedLayout | Module.Flags.IsFileLayout);
+                    flags |= peFile.IsILImage ? Module.Flags.IsManaged : Module.Flags.None;
+                    pdbs = peFile.Pdbs.Select((pdb) => pdb.ToPdbFileInfo()).ToList();
                     flags |= isVirtual ? Module.Flags.IsLoadedLayout : Module.Flags.IsFileLayout;
-                    return peImage;
+                    return peFile;
                 }
                 else
                 {
                     Trace.TraceError($"GetPEInfo: PE invalid {address:X16} isVirtual {isVirtual}");
                 }
             }
-            catch (Exception ex) when (ex is BadImageFormatException || ex is EndOfStreamException || ex is IOException)
+            catch (Exception ex) when (ex is InvalidVirtualAddressException || ex is BadInputFormatException)
             {
                 Trace.TraceError($"GetPEInfo: {address:X16} isVirtual {isVirtual} exception {ex.Message}");
             }
@@ -626,9 +639,10 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         {
             byte[] buffer = new byte[s_versionString.Length];
 
-            if (_versionCache == null) {
+            if (_versionCache == null)
+            {
                 // We use the possibly mapped memory service to find the version string in case it isn't in the dump.
-                _versionCache = new ReadVirtualCache(Target.Services.GetService<IMemoryService>());
+                _versionCache = new ReadVirtualCache(MemoryService);
             }
             _versionCache.Clear();
 
index 9c0035cdbd3c69e35222745f59a91a56e4485b2c..081188214cc2f8595b5d4e489a53da33c2f9e591 100644 (file)
@@ -2,6 +2,8 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+using Microsoft.FileFormats.PE;
+
 namespace Microsoft.Diagnostics.DebugServices.Implementation
 {
     public static class Utilities
@@ -25,7 +27,15 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         }
 
         /// <summary>
-        /// Convert from CLRMD VersionInfo to DebugServices VersionData
+        /// Convert from symstore VsFixedFileInfo to DebugServices VersionData
+        /// </summary>
+        public static VersionData ToVersionData(this VsFixedFileInfo fileInfo)
+        { 
+            return new VersionData(fileInfo.FileVersionMajor, fileInfo.FileVersionMinor, fileInfo.FileVersionRevision, fileInfo.FileVersionBuild);
+        }
+
+        /// <summary>
+        /// Convert from clrmd VersionInfo to DebugServices VersionData
         /// </summary>
         public static VersionData ToVersionData(this Microsoft.Diagnostics.Runtime.VersionInfo versionInfo)
         { 
@@ -33,7 +43,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         }
 
         /// <summary>
-        /// Convert from DebugServices VersionData to CLRMD VersionInfo
+        /// Convert from DebugServices VersionData to clrmd VersionInfo
         /// </summary>
         public static Microsoft.Diagnostics.Runtime.VersionInfo ToVersionInfo(this VersionData versionData)
         { 
@@ -41,11 +51,11 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         }
 
         /// <summary>
-        /// Convert from CLRMD PdbInfo to DebugServices PdbFileInfo
+        /// Convert from symstore PEPdbRecord to DebugServices PdbFileInfo
         /// </summary>
-        public static PdbFileInfo ToPdbFileInfo(this Microsoft.Diagnostics.Runtime.PdbInfo pdbInfo)
+        public static PdbFileInfo ToPdbFileInfo(this PEPdbRecord pdbInfo)
         {
-            return new PdbFileInfo(pdbInfo.Path, pdbInfo.Guid, pdbInfo.Revision);
+            return new PdbFileInfo(pdbInfo.Path, pdbInfo.Signature, pdbInfo.Age, pdbInfo.IsPortablePDB);
         }
     }
 }
index da9ce58c9a82eb0ca1bd564e740241ec333b8b51..3f4746cd77a49fa79e0d7cc56ca8d40bce826247 100644 (file)
@@ -3,6 +3,7 @@
 // See the LICENSE file in the project root for more information.
 
 using System;
+using System.Collections.Generic;
 using System.Collections.Immutable;
 
 namespace Microsoft.Diagnostics.DebugServices
@@ -75,7 +76,7 @@ namespace Microsoft.Diagnostics.DebugServices
         /// <summary>
         /// PDB information for Windows PE modules (managed or native).
         /// </summary>
-        PdbFileInfo PdbFileInfo { get; }
+        IEnumerable<PdbFileInfo> PdbFileInfos { get; }
 
         /// <summary>
         /// Version information for Window PE modules (managed or native). 
index f538e05c7dce51de587ee4616e52eb0f37952cfe..56a25e868f26f16810a19e2b13d414567b8f13fd 100644 (file)
@@ -26,16 +26,22 @@ namespace Microsoft.Diagnostics.DebugServices
         /// </summary>
         public string Path { get; }
 
+        /// <summary>
+        /// True if portable PDB, false Windows
+        /// </summary>
+        public bool IsPortable { get; }
+
         /// <summary>
         /// Creates an instance of the PdbInfo with the corresponding properties initialized.
         /// </summary>
-        public PdbFileInfo(string path, Guid guid, int revision)
+        public PdbFileInfo(string path, Guid guid, int revision, bool isPortable)
         {
             Path = path;
             Guid = guid;
             Revision = revision;
+            IsPortable = isPortable;
         }
 
-        public override string ToString() => $"{Guid} {Revision} {Path}";
+        public override string ToString() => $"{Guid} {Revision} {(IsPortable ? "(portable) " : string.Empty)}{Path}";
     }
 }
index ed5547f60fb4af5f7dd925d3db817c5ac03f433f..194e1682537e0e51c62274ec6faa6f885be4b39d 100644 (file)
@@ -4,6 +4,8 @@
 
 using Microsoft.Diagnostics.DebugServices;
 using Microsoft.Diagnostics.Runtime;
+using System.IO;
+using System.Text.RegularExpressions;
 
 namespace Microsoft.Diagnostics.ExtensionCommands
 {
@@ -14,6 +16,9 @@ namespace Microsoft.Diagnostics.ExtensionCommands
 
         public IModuleService ModuleService { get; set; }
 
+        [Option(Name = "--name", Aliases = new string[] { "-n" }, Help = "RegEx filter on module name (path not included).")]
+        public string ModuleName { get; set; }
+
         [Option(Name = "--verbose", Aliases = new string[] { "-v" }, Help = "Displays detailed information about the modules.")]
         public bool Verbose { get; set; }
 
@@ -23,34 +28,38 @@ namespace Microsoft.Diagnostics.ExtensionCommands
             {
                 throw new DiagnosticsException("No CLR runtime set");
             }
+            Regex regex = ModuleName is not null ? new Regex(ModuleName, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) : null;
             foreach (ClrModule module in Runtime.EnumerateModules())
             {
-                if (Verbose)
+                if (regex is null || regex.IsMatch(Path.GetFileName(module.Name)))
                 {
-                    WriteLine("{0}{1}", module.Name, module.IsDynamic ? "(Dynamic)" : "");
-                    WriteLine("    AssemblyName:    {0}", module.AssemblyName);
-                    WriteLine("    ImageBase:       {0:X16}", module.ImageBase);
-                    WriteLine("    Size:            {0:X8}", module.Size);
-                    WriteLine("    Address:         {0:X16}", module.Address);
-                    WriteLine("    IsPEFile:        {0}", module.IsPEFile);
-                    WriteLine("    Layout:          {0}", module.Layout);
-                    WriteLine("    IsDynamic:       {0}", module.IsDynamic);
-                    WriteLine("    MetadataAddress: {0:X16}", module.MetadataAddress);
-                    WriteLine("    MetadataSize:    {0:X16}", module.MetadataLength);
-                    WriteLine("    PdbInfo:         {0}", module.Pdb?.ToString() ?? "<none>");
-                    VersionData version = null;
-                    try
+                    if (Verbose)
                     {
-                        version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).VersionData;
+                        WriteLine("{0}{1}", module.Name, module.IsDynamic ? "(Dynamic)" : "");
+                        WriteLine("    AssemblyName:    {0}", module.AssemblyName);
+                        WriteLine("    ImageBase:       {0:X16}", module.ImageBase);
+                        WriteLine("    Size:            {0:X8}", module.Size);
+                        WriteLine("    Address:         {0:X16}", module.Address);
+                        WriteLine("    IsPEFile:        {0}", module.IsPEFile);
+                        WriteLine("    Layout:          {0}", module.Layout);
+                        WriteLine("    IsDynamic:       {0}", module.IsDynamic);
+                        WriteLine("    MetadataAddress: {0:X16}", module.MetadataAddress);
+                        WriteLine("    MetadataSize:    {0:X16}", module.MetadataLength);
+                        WriteLine("    PdbInfo:         {0}", module.Pdb?.ToString() ?? "<none>");
+                        VersionData version = null;
+                        try
+                        {
+                            version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).VersionData;
+                        }
+                        catch (DiagnosticsException)
+                        {
+                        }
+                        WriteLine("    Version:         {0}", version?.ToString() ?? "<none>");
                     }
-                    catch (DiagnosticsException)
+                    else
                     {
+                        WriteLine("{0:X16} {1:X8} {2}{3}", module.ImageBase, module.Size, module.Name, module.IsDynamic ? "(Dynamic)" : "");
                     }
-                    WriteLine("    Version:         {0}", version?.ToString() ?? "<none>");
-                }
-                else
-                {
-                    WriteLine("{0:X16} {1:X8} {2}{3}", module.ImageBase, module.Size, module.Name, module.IsDynamic ? "(Dynamic)" : "");
                 }
             }
         }
index b2e1b274e8376efb48995bb8156c6b4f399dcf28..7047b8b784762bd0f984efa333650cbed8d4e9c4 100644 (file)
@@ -25,7 +25,6 @@ namespace Microsoft.Diagnostics.ExtensionCommands
         [Option(Name = "--segments", Aliases = new string[] { "-s" }, Help = "Displays the module segments.")]
         public bool Segment { get; set; }
 
-
         [Option(Name = "--name", Aliases = new string[] { "-n" }, Help = "RegEx filter on module name (path not included).")]
         public string ModuleName { get; set; }
 
@@ -57,7 +56,10 @@ namespace Microsoft.Diagnostics.ExtensionCommands
                         {
                             WriteLine("                     {0}", versionString);
                         }
-                        WriteLine("    PdbInfo:         {0}", module.PdbFileInfo?.ToString() ?? "<none>");
+                        foreach (PdbFileInfo pdbFileInfo in module.PdbFileInfos)
+                        {
+                            WriteLine("    PdbInfo:         {0}", pdbFileInfo);
+                        }
                         WriteLine("    BuildId:         {0}", !module.BuildId.IsDefaultOrEmpty ? string.Concat(module.BuildId.Select((b) => b.ToString("x2"))) : "<none>");
                     }
                     else
index 85e64dd6289899bd036b03755a756014d7b26541..2272d2ec4b5ea54b4324808acc857bf0bce88d74 100644 (file)
@@ -5,6 +5,7 @@
 using Microsoft.Diagnostics.DebugServices;
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 using System.Threading;
@@ -478,6 +479,7 @@ namespace Microsoft.Diagnostics.Repl
                 catch (Exception ex) when (!(ex is NullReferenceException || ex is ArgumentNullException || ex is ArgumentException))
                 {
                     WriteLine(OutputType.Error, "ERROR: {0}", ex.Message);
+                    Trace.TraceError(ex.ToString());
                     m_lastCommandLine = null;
                     result = false;
                 }
index cbd533e41ab77466f4547ed28b2c221703289051..74ee74b8502547a1047f1baf5d5a46e97f7a7a14 100644 (file)
@@ -70,10 +70,10 @@ namespace SOS.Extensions
                         int hr = _moduleService._debuggerServices.GetModuleVersionInformation(ModuleIndex, out VS_FIXEDFILEINFO fileInfo);
                         if (hr == HResult.S_OK)
                         {
-                            int major = (int)fileInfo.dwFileVersionMS >> 16;
-                            int minor = (int)fileInfo.dwFileVersionMS & 0xffff;
-                            int revision = (int)fileInfo.dwFileVersionLS >> 16;
-                            int patch = (int)fileInfo.dwFileVersionLS & 0xffff;
+                            int major = (int)(fileInfo.dwFileVersionMS >> 16);
+                            int minor = (int)(fileInfo.dwFileVersionMS & 0xffff);
+                            int revision = (int)(fileInfo.dwFileVersionLS >> 16);
+                            int patch = (int)(fileInfo.dwFileVersionLS & 0xffff);
                             _versionData = new VersionData(major, minor, revision, patch);
                         }
                         else
index 2b3b1b78a8538c71e4117e4853b17a27d6cf6fac..b744b86dfc6fc0f6e96ebf461426d915cd133579 100644 (file)
@@ -65,10 +65,6 @@ namespace Microsoft.Diagnostics.DebugServices.UnitTests
         [SkippableTheory, MemberData(nameof(GetConfigurations))]
         public void ModuleTests(TestHost host)
         {
-            if (OS.Kind == OSKind.Windows)
-            {
-                throw new SkipTestException("Test unstable on Windows. Issue: https://github.com/dotnet/diagnostics/issues/2709");
-            }
             var moduleService = host.Target.Services.GetService<IModuleService>();
             Assert.NotNull(moduleService);
 
@@ -241,10 +237,6 @@ namespace Microsoft.Diagnostics.DebugServices.UnitTests
         [SkippableTheory, MemberData(nameof(GetConfigurations))]
         public void RuntimeTests(TestHost host)
         {
-            if (OS.Kind == OSKind.Windows)
-            {
-                throw new SkipTestException("Test unstable on Windows. Issue: https://github.com/dotnet/diagnostics/issues/2709");
-            }
             // The current Linux test assets are not alpine/musl
             if (OS.IsAlpine)
             {
index e454a2e68fb1b5ebd2e07afba201312e519440e8..a73c733627d22532fb000a70a906bda59c0b88af 100644 (file)
@@ -4,7 +4,7 @@
     <!-- Needs to be netcoreapp3.1 and not higher so this test assembly can be loaded by dotnet-dump via the DOTNET_DIAGNOSTIC_EXTENSIONS env var -->
     <TargetFramework>netcoreapp3.1</TargetFramework>
     <TestConfigFileName>$(OutputPath)$(TargetFramework)\Debugger.Tests.Common.txt</TestConfigFileName>
-    <TestAssetsVersion>1.0.246501</TestAssetsVersion>
+    <TestAssetsVersion>1.0.257801</TestAssetsVersion>
     <!-- Controls the test asset package restore and the tests that use them -->
     <RunTests>true</RunTests>
   </PropertyGroup>
index 4448babe1daea018f7b9d09c89a8186c0e355bdb..867028f5369390aa7158ec0325b12bbe590adfc1 100644 (file)
@@ -93,7 +93,7 @@ namespace Microsoft.Diagnostics.DebugServices.UnitTests
 
         private void AddModuleMembers(XElement element, IModule module, string symbolModuleName)
         {
-            AddMembers(element, typeof(IModule), module, nameof(IModule.ModuleIndex), nameof(IModule.PdbFileInfo), nameof(IModule.VersionString));
+            AddMembers(element, typeof(IModule), module, nameof(IModule.ModuleIndex), nameof(IModule.PdbFileInfos), nameof(IModule.VersionString));
 
             if (symbolModuleName != null && IsModuleEqual(module, symbolModuleName))
             {
@@ -110,7 +110,7 @@ namespace Microsoft.Diagnostics.DebugServices.UnitTests
                         symbolElement.Add(new XElement("Value", ToHex(offset1)));
                     }
                     string symbol2 = "coreclr_execute_assembly";
-                    if (exportSymbols.TryGetSymbolAddress(symbol1, out ulong offset2))
+                    if (exportSymbols.TryGetSymbolAddress(symbol2, out ulong offset2))
                     {
                         XElement symbolElement = AddExportSymbolSection();
                         symbolElement.Add(new XElement("Name", symbol2));
diff --git a/test.sh b/test.sh
index 9855b2666cfa0bad599b0fa1a2a51ad6f1569ef7..65eb42dd0093e9d49b8ccd751baca76d79aaebb9 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -13,5 +13,5 @@ while [[ -h $source ]]; do
 done
 
 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
-"$scriptroot/eng/build.sh" --test --skipmanaged --skipnative $@
+"$scriptroot/eng/build.sh" -test -skipmanaged -skipnative $@