Merge main into release/stable (#3100)
authorMike McLaughlin <mikem@microsoft.com>
Wed, 1 Jun 2022 05:08:31 +0000 (22:08 -0700)
committerGitHub <noreply@github.com>
Wed, 1 Jun 2022 05:08:31 +0000 (22:08 -0700)
* Update dependencies from https://github.com/dotnet/aspnetcore build 20220406.3 (#2990)

[main] Update dependencies from dotnet/aspnetcore

* Update dependencies from https://github.com/dotnet/runtime build 20220406.5 (#2991)

[main] Update dependencies from dotnet/runtime

* Set the build ID using arcade's scripts instead of retrieving it from another job (#2993)

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220328.1 (#2967)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/dotnet/arcade build 20220406.10 (#3000)

[main] Update dependencies from dotnet/arcade

* Update dependencies from https://github.com/dotnet/symstore build 20220410.1 (#3002)

Microsoft.SymbolStore
 From Version 1.0.320401 -> To Version 1.0.321001

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
* Update dependencies from https://github.com/dotnet/installer build 20220410.6 (#3001)

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.104-servicing.22181.15 -> To Version 6.0.104-servicing.22210.6

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
* Update dependencies from https://github.com/dotnet/symstore build 20220411.1 (#3007)

[main] Update dependencies from dotnet/symstore

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220411.2 (#3006)

[main] Update dependencies from dotnet/aspnetcore

* Update dependencies from https://github.com/dotnet/runtime build 20220411.4 (#3008)

[main] Update dependencies from dotnet/runtime

* Update dependencies from https://github.com/dotnet/runtime build 20220412.7 (#3011)

[main] Update dependencies from dotnet/runtime

* Update dependencies from https://github.com/dotnet/symstore build 20220412.1 (#3010)

[main] Update dependencies from dotnet/symstore

* Rewrite DumpAsync in C# (#2964)

* Rewrite DumpAsync in C#

This rewrites the dumpasync command as a C# SOS extension.  Doing so makes the code easier to maintain and add features to in the future.  Along with the rewrite, a variety of requests for the feature have been satisfied:
- Added a "coalesced stacks" view (`--coalesce`) that coalesces stacks together to create a high-level view of the state of the process
- Improved filtering so that a specified filter (address, method table, substring) applies to any frame of a stack and not just to the top frame
- Improved stack stitching to always consider task objects from the heap and not just if `--tasks` was specified.  This helps to better connect state machines separated by constructs like Task.Run.
- Added synthesized frames to try to show what's being awaited in the case where the top frame is an async method.
- Added DML links for more things to better navigate through results.

* Fix tests

* Fix tests for DumpAsync on WebApp3

* Skip visiting tasks multiple times

* Special case completion sentinnel

* Only synthesize faux awaiter frame if the task is not completed.

* PR feedback

Co-authored-by: Juan Sebastian Hoyos Ayala <juan.hoyos@microsoft.com>
* Update dependencies from https://github.com/dotnet/runtime build 20220413.11 (#3014)

Microsoft.NETCore.App.Runtime.win-x64 , VS.Redist.Common.NetCore.SharedFramework.x64.6.0
 From Version 6.0.5 -> To Version 6.0.5

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
* Update dependencies from https://github.com/dotnet/aspnetcore build 20220413.12 (#3013)

[main] Update dependencies from dotnet/aspnetcore

* Use symstore retry changes in tests (#2968)

* Create clear error messages for dotnet-trace (#3012)

* Catch UnauthorizedAccessException, Win32Exception and simplify for loop

* altered to conventional C# style

* Set symstore HTTP retry count in all test cases (#3015)

* Set symstore HTTP retry count in all test cases

* Update src/Microsoft.Diagnostics.DebugServices/ISymbolService.cs

Co-authored-by: Juan Hoyos <juan.hoyos@microsoft.com>
* Code review feedback

Co-authored-by: Juan Hoyos <juan.hoyos@microsoft.com>
* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220415.1 (#3016)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/dotnet/arcade build 20220415.2 (#3017)

[main] Update dependencies from dotnet/arcade

* Update lldb instuctions (#3020)

Mostly just delete distro versions that are not supported for any supported .NET version.

* Use minipal in more places (#3019)

* Port minipal/getexepath.h from runtime repo

* Use ARRAY_SIZE from minipal in more places

* Fix C4996 warning on windows

* Introspect sys/auxv.h in SOS configuration

* Fix include

* [main] Update dependencies from dotnet/installer (#3018)

* Update dependencies from https://github.com/dotnet/installer build 20220415.3

Microsoft.Dotnet.Sdk.Internal
 From Version 6.0.104-servicing.22210.6 -> To Version 6.0.105-servicing.22215.3

* Fix single-file runtime version

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Mike McLaughlin <mikem@microsoft.com>
* Update dependencies from https://github.com/dotnet/symstore build 20220418.1 (#3022)

[main] Update dependencies from dotnet/symstore

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220419.2 (#3023)

[main] Update dependencies from dotnet/source-build-reference-packages

* Create EventPipeFormat.md (#3024)

* Update dependencies from https://github.com/dotnet/arcade build 20220422.4 (#3027)

[main] Update dependencies from dotnet/arcade

* Update dependencies from https://github.com/dotnet/installer build 20220419.37 (#3028)

[main] Update dependencies from dotnet/installer

* dotent-trace report - account for missing symbol (#3021)

* Update dependencies from https://github.com/microsoft/clrmd build 20220426.1 (#3035)

[main] Update dependencies from microsoft/clrmd

* Write temp files to tempdir (#3031)

* update to use viewport-relative coordinates (#3034)

This fixes some rendering issues of dontet-counters, however, dotnet-counters renders incorrectly when:
- terminal changes size while the tool is running
- terminal is not wide enough to print the output

As noted in #3036

* Update dependencies from https://github.com/dotnet/installer build 20220429.9 (#3038)

[main] Update dependencies from dotnet/installer

* Update dependencies from https://github.com/dotnet/arcade build 20220425.6 (#3037)

[main] Update dependencies from dotnet/arcade

* Update dependencies from https://github.com/dotnet/symstore build 20220502.1 (#3040)

[main] Update dependencies from dotnet/symstore

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220503.1 (#3043)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220503.6 (#3041)

[main] Update dependencies from dotnet/aspnetcore

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220504.3 (#3045)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220504.26 (#3044)

[main] Update dependencies from dotnet/aspnetcore

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220505.18 (#3046)

[main] Update dependencies from dotnet/aspnetcore

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220505.1 (#3048)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/microsoft/clrmd build 20220505.1 (#3047)

[main] Update dependencies from microsoft/clrmd

* Update EventPipeStress (#3049)

* Update dependencies from https://github.com/dotnet/arcade build 20220505.2 (#3052)

[main] Update dependencies from dotnet/arcade

* Update dependencies from https://github.com/dotnet/installer build 20220504.12 (#3053)

[main] Update dependencies from dotnet/installer

* Update dependencies from https://github.com/microsoft/clrmd build 20220509.1 (#3056)

[main] Update dependencies from microsoft/clrmd

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220509.4 (#3058)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/dotnet/symstore build 20220509.1 (#3057)

[main] Update dependencies from dotnet/symstore

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220509.8 (#3055)

[main] Update dependencies from dotnet/aspnetcore

* Port setsymbolserver command to C# (#3050)

* Port setsymbolserver command to C#

Fixes issue: https://github.com/dotnet/diagnostics/issues/3032

Removes quite a bit of native and interop code.

Remove some noisy logging in success paths.

Rename ISymbolService.DownloadModule to DownloadModuleFile. Add ISymbolService.DownloadSymbolFile.

Rename some IModule properties to functions. Add IModule.LoadSymbols().

Fix MacOS test failures

Make setsymbolserver a global command

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220510.8 (#3063)

[main] Update dependencies from dotnet/aspnetcore

* Enable SDL required warnings explicitly (#3054)

* Enable SDL required warnings explicitly
* Fix build issues that don't escape on failure properly

* Add devcontainer infra to diagnostics repo (#2986)

* Pass by reference (#3066)

* Update dependencies from https://github.com/dotnet/aspnetcore build 20220512.8 (#3070)

[main] Update dependencies from dotnet/aspnetcore

* Fix Typo (#3071)

* Misc dbgshim and SOS fixes (#3072)

* Fix some issues found with netcoredbg

* Fix some sign-extension issues on alpine arm32

* Fix DbgShim.UnitTest's Microsoft.Diagnostics.DbgShimAPI+NativeRuntimeStartupCallbackDelegate being called after collected by the GC

* Code review feedback

* [main] Update dependencies from dotnet/installer (#3076)

[main] Update dependencies from dotnet/installer

 - Update single-file version

* Update dependencies from https://github.com/dotnet/symstore build 20220516.1 (#3079)

[main] Update dependencies from dotnet/symstore

* Update dependencies from https://github.com/dotnet/arcade build 20220512.8 (#3075)

[main] Update dependencies from dotnet/arcade

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220511.1 (#3068)

[main] Update dependencies from dotnet/source-build-reference-packages

* Update dependencies from https://github.com/dotnet/arcade build 20220519.3 (#3086)

[main] Update dependencies from dotnet/arcade

* Enable shipping dbgshim packages (#3088)

* Add error message to WriteDump response (#3084)

Add error message to WriteDump response

Add the new generate core dump command that can receive error text on failure.

Fix issue #2976

* Use Environment.GetFolderPath to obtain home directory (#3087)

* Use Environment.GetFolderPath to obtain home directory

* Format documents in changeset

* Update dependencies from https://github.com/dotnet/symstore build 20220523.1 (#3091)

[main] Update dependencies from dotnet/symstore

* Update dependencies from https://github.com/dotnet/source-build-reference-packages build 20220520.1 (#3085)

[main] Update dependencies from dotnet/source-build-reference-packages

* SOS fixes for regions (#3062)

Noticed that DacpHeapSegmentData::Request doesn't set the highAllocMark for regions correctly, and that we haven't fixed GCHeapSnapshot::GetGeneration for regions yet.

Moved fix for highAllocMark into the DAC, but keep some logic here so things work correctly for older DACs with segments.

Fix more places where we need to use highAllocMark.

Kudos to @cshung for pointing out the better way to fix this!

* Update dependencies from https://github.com/dotnet/arcade build 20220526.1 (#3096)

[main] Update dependencies from dotnet/arcade

* Update dependencies from https://github.com/dotnet/installer build 20220527.1 (#3097)

[main] Update dependencies from dotnet/installer

* Update dependencies from https://github.com/dotnet/symstore build 20220530.1 (#3098)

[main] Update dependencies from dotnet/symstore

* Fix dbgshim's OpenVirtualProcess on windows arm64 (#3099)

Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Juan Hoyos <juan.s.hoyos@outlook.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Juan Sebastian Hoyos Ayala <juan.hoyos@microsoft.com>
Co-authored-by: mikelle-rogers <45022607+mikelle-rogers@users.noreply.github.com>
Co-authored-by: Dan Moseley <danmose@microsoft.com>
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
Co-authored-by: John Salem <josalem@microsoft.com>
Co-authored-by: Andrew Au <andrewau@microsoft.com>
Co-authored-by: Martin-Molinero <martin@quantconnect.com>
Co-authored-by: Peter Sollich <petersol@microsoft.com>
18 files changed:
eng/Version.Details.xml
eng/Versions.props
eng/common/tools.ps1
global.json
src/Microsoft.Diagnostics.DebugServices.Implementation/SymbolService.cs
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsClient/DiagnosticsClient.cs
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcCommands.cs
src/Microsoft.Diagnostics.NETCore.Client/DiagnosticsIpc/IpcMessage.cs
src/SOS/SOS.InstallHelper/InstallHelper.cs
src/SOS/Strike/eeheap.cpp
src/SOS/Strike/gcroot.cpp
src/SOS/Strike/sos.cpp
src/Tools/dotnet-dump/Analyzer.cs
src/Tools/dotnet-dump/Dumper.Windows.cs
src/dbgshim/debugshim.cpp
src/dbgshim/pkg/Microsoft.Diagnostics.DbgShim.props
src/shared/inc/dacprivate.h
src/shared/pal/inc/rt/ntimage.h

index 07d6ba866a50563cd9a3d8f086586533a24e15f2..e29011c03d04791f3260da7bb66866ee938cbe41 100644 (file)
@@ -1,8 +1,8 @@
 <Dependencies>
   <ProductDependencies>
-    <Dependency Name="Microsoft.SymbolStore" Version="1.0.326601">
+    <Dependency Name="Microsoft.SymbolStore" Version="1.0.328001">
       <Uri>https://github.com/dotnet/symstore</Uri>
-      <Sha>073abc4f492cbc6795989e4a813b0d32017a8623</Sha>
+      <Sha>1ff51a5afa61af820a14b3aa84b401d1a79bc783</Sha>
     </Dependency>
     <Dependency Name="Microsoft.Diagnostics.Runtime" Version="2.0.325901">
       <Uri>https://github.com/microsoft/clrmd</Uri>
       <Uri>https://github.com/microsoft/clrmd</Uri>
       <Sha>a64d9ac11086f28fbd4b2b2337c19be7826fbfa9</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="7.0.0-alpha.1.22261.1">
+    <Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="7.0.0-alpha.1.22270.1">
       <Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
-      <Sha>c71ce108eda9f657c9f58a613a1fe56b6b08235d</Sha>
+      <Sha>3dbb19f76474f2f22749b2e64d34c15178381ffb</Sha>
       <SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
     </Dependency>
   </ProductDependencies>
   <ToolsetDependencies>
-    <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.22269.3">
+    <Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.22276.1">
       <Uri>https://github.com/dotnet/arcade</Uri>
-      <Sha>0403b0d07aff1b103256cfbe082c97a5c8846d20</Sha>
+      <Sha>b8b67b243ba93bf9b89390c85b4dee034d3c5609</Sha>
       <SourceBuild RepoName="arcade" ManagedOnly="true" />
     </Dependency>
-    <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="7.0.0-beta.22269.3">
+    <Dependency Name="Microsoft.DotNet.RemoteExecutor" Version="7.0.0-beta.22276.1">
       <Uri>https://github.com/dotnet/arcade</Uri>
-      <Sha>0403b0d07aff1b103256cfbe082c97a5c8846d20</Sha>
+      <Sha>b8b67b243ba93bf9b89390c85b4dee034d3c5609</Sha>
     </Dependency>
-    <Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.106-servicing.22263.13">
+    <Dependency Name="Microsoft.Dotnet.Sdk.Internal" Version="6.0.106-servicing.22277.1">
       <Uri>https://github.com/dotnet/installer</Uri>
-      <Sha>ee1b7085a6eb99c97851ed67fc3fd52b8bda3ba0</Sha>
+      <Sha>0632d08f8d604ed2a9ea697e88991b7f2ec68141</Sha>
     </Dependency>
     <Dependency Name="Microsoft.AspNetCore.App.Ref.Internal" Version="6.0.6-servicing.22262.8">
       <Uri>https://github.com/dotnet/aspnetcore</Uri>
index 08c1bc22e91b989dcf8163aec000f57dcd6c2fa9..bb8fd3f44abe5943dd76f6566fd60f922281e01e 100644 (file)
@@ -18,7 +18,7 @@
     <!-- The SDK runtime version used to build single-file apps (currently hardcoded) -->
     <SingleFileRuntimeVersion>6.0.5</SingleFileRuntimeVersion>
     <!-- Latest symstore version updated by darc -->
-    <MicrosoftSymbolStoreVersion>1.0.326601</MicrosoftSymbolStoreVersion>
+    <MicrosoftSymbolStoreVersion>1.0.328001</MicrosoftSymbolStoreVersion>
     <!-- Runtime versions to test -->
     <MicrosoftNETCoreApp31Version>3.1.18</MicrosoftNETCoreApp31Version>
     <MicrosoftAspNetCoreApp31Version>$(MicrosoftNETCoreApp31Version)</MicrosoftAspNetCoreApp31Version>
@@ -31,7 +31,7 @@
     <MicrosoftAspNetCoreAppRefInternalVersion>6.0.6-servicing.22262.8</MicrosoftAspNetCoreAppRefInternalVersion>
     <MicrosoftAspNetCoreAppRefVersion>6.0.6</MicrosoftAspNetCoreAppRefVersion>
     <!-- dotnet/installer: Testing version of the SDK. Needed for the signed & entitled host. -->
-    <MicrosoftDotnetSdkInternalVersion>6.0.106-servicing.22263.13</MicrosoftDotnetSdkInternalVersion>
+    <MicrosoftDotnetSdkInternalVersion>6.0.106-servicing.22277.1</MicrosoftDotnetSdkInternalVersion>
   </PropertyGroup>
   <PropertyGroup>
     <!-- Opt-in/out repo features -->
@@ -58,7 +58,7 @@
     <SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion>
     <SystemTextJsonVersion>4.7.1</SystemTextJsonVersion>
     <XUnitAbstractionsVersion>2.0.3</XUnitAbstractionsVersion>
-    <MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.22269.3</MicrosoftDotNetRemoteExecutorVersion>
+    <MicrosoftDotNetRemoteExecutorVersion>7.0.0-beta.22276.1</MicrosoftDotNetRemoteExecutorVersion>
     <cdbsosversion>10.0.18362</cdbsosversion>
     <NewtonSoftJsonVersion>12.0.2</NewtonSoftJsonVersion>
   </PropertyGroup>
index 797f05292a8515814e4631470374d698566efc87..423bd962e9661b88044a99339ed56d564d4be99a 100644 (file)
@@ -635,6 +635,10 @@ function InitializeNativeTools() {
         InstallDirectory = "$ToolsDir"
       }
     }
+    if (Test-Path variable:NativeToolsOnMachine) {
+      Write-Host "Variable NativeToolsOnMachine detected, enabling native tool path promotion..."
+      $nativeArgs += @{ PathPromotion = $true }
+    }
     & "$PSScriptRoot/init-tools-native.ps1" @nativeArgs
   }
 }
index 37472ac52b6a536d68c8d4f95864438c6b097a9c..4d6c9be5a9d63469b965f4ed11e0234a7029d706 100644 (file)
@@ -16,6 +16,6 @@
   },
   "msbuild-sdks": {
     "Microsoft.Build.NoTargets": "2.0.1",
-    "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22269.3"
+    "Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22276.1"
   }
 }
index 97b82ac458f2084a1410cf0f9acf2d96af1a3385..b7fba2507937456d4867b2431e670a4be82caa40 100644 (file)
@@ -79,12 +79,12 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                     }
                     else
                     {
-                        _defaultSymbolCache = Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".dotnet", "symbolcache");
+                        _defaultSymbolCache = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet", "symbolcache");
                     }
                 }
                 return _defaultSymbolCache;
             }
-            set 
+            set
             {
                 _defaultSymbolCache = value;
             }
@@ -182,7 +182,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                                             symbolCachePaths.Add(DefaultSymbolCache);
                                         }
                                     }
-                                    else 
+                                    else
                                     {
                                         symbolCachePaths.Add(parts[i]);
                                     }
@@ -461,10 +461,10 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                     }
                 }
             }
-            catch (Exception ex) when 
-                (ex is UnauthorizedAccessException || 
-                 ex is BadImageFormatException || 
-                 ex is InvalidVirtualAddressException || 
+            catch (Exception ex) when
+                (ex is UnauthorizedAccessException ||
+                 ex is BadImageFormatException ||
+                 ex is InvalidVirtualAddressException ||
                  ex is IOException)
             {
                 Trace.TraceError($"GetMetaData: {ex.Message}");
@@ -493,7 +493,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                 peStream = Utilities.TryOpenFile(assemblyPath);
                 if (peStream == null)
                     return null;
-                
+
                 options = PEStreamOptions.Default;
             }
 
@@ -606,7 +606,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                     Trace.TraceWarning($"DownLoadPE: no key generated for module {fileName} ");
                     return null;
                 }
-            } 
+            }
             else if ((flags & KeyTypeFlags.SymbolKey) != 0)
             {
                 IEnumerable<PdbFileInfo> pdbInfos = module.GetPdbFileInfos();
@@ -647,7 +647,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                     return null;
                 }
             }
-            else 
+            else
             {
                 throw new ArgumentException($"Key flag not supported {flags}");
             }
@@ -829,7 +829,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
                 string pdbPath = data.Path;
                 Stream pdbStream = null;
 
-                if (assemblyPath != null) 
+                if (assemblyPath != null)
                 {
                     try
                     {
@@ -916,7 +916,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         public override string ToString()
         {
             StringBuilder sb = new StringBuilder();
-            ForEachSymbolStore<Microsoft.SymbolStore.SymbolStores.SymbolStore>((symbolStore) => 
+            ForEachSymbolStore<Microsoft.SymbolStore.SymbolStores.SymbolStore>((symbolStore) =>
             {
                 if (symbolStore is HttpSymbolStore httpSymbolStore)
                 {
@@ -962,7 +962,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
             }
         }
 
-        private bool IsDuplicateSymbolStore<T>(Microsoft.SymbolStore.SymbolStores.SymbolStore symbolStore, Func<T, bool> match) 
+        private bool IsDuplicateSymbolStore<T>(Microsoft.SymbolStore.SymbolStores.SymbolStore symbolStore, Func<T, bool> match)
             where T : Microsoft.SymbolStore.SymbolStores.SymbolStore
         {
             while (symbolStore != null)
@@ -1006,7 +1006,7 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         /// <returns>Last component of path</returns>
         internal static string GetFileName(string pathName)
         {
-            int pos = pathName.LastIndexOfAny(new char[] { '/', '\\'});
+            int pos = pathName.LastIndexOfAny(new char[] { '/', '\\' });
             if (pos < 0)
             {
                 return pathName;
@@ -1019,11 +1019,11 @@ namespace Microsoft.Diagnostics.DebugServices.Implementation
         /// </summary>
         private static bool IsPathEqual(string path1, string path2)
         {
-            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 
+            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             {
                 return StringComparer.OrdinalIgnoreCase.Equals(path1, path2);
             }
-            else 
+            else
             {
                 return string.Equals(path1, path2);
             }
index 181ccc4a94abc4c21ad7b173f6d02c80827731f5..2d58ef8626d115ff1957623cbcdeb2f9401a03af 100644 (file)
@@ -121,9 +121,7 @@ namespace Microsoft.Diagnostics.NETCore.Client
         /// <param name="logDumpGeneration">When set to true, display the dump generation debug log to the console.</param>
         public void WriteDump(DumpType dumpType, string dumpPath, bool logDumpGeneration = false)
         {
-            IpcMessage request = CreateWriteDumpMessage(dumpType, dumpPath, logDumpGeneration);
-            IpcMessage response = IpcClient.SendMessage(_endpoint, request);
-            ValidateResponseMessage(response, nameof(WriteDump));
+            WriteDump(dumpType, dumpPath, logDumpGeneration ? WriteDumpFlags.LoggingEnabled : WriteDumpFlags.None);
         }
 
         /// <summary>
@@ -134,15 +132,22 @@ namespace Microsoft.Diagnostics.NETCore.Client
         /// <param name="flags">logging and crash report flags. On runtimes less than 6.0, only LoggingEnabled is supported.</param>
         public void WriteDump(DumpType dumpType, string dumpPath, WriteDumpFlags flags)
         {
-            IpcMessage request = CreateWriteDumpMessage2(dumpType, dumpPath, flags);
+            IpcMessage request = CreateWriteDumpMessage(DumpCommandId.GenerateCoreDump3, dumpType, dumpPath, flags);
             IpcMessage response = IpcClient.SendMessage(_endpoint, request);
-            if (!ValidateResponseMessage(response, nameof(WriteDump), ValidateResponseOptions.UnknownCommandReturnsFalse))
+            if (!ValidateResponseMessage(response, "Write dump", ValidateResponseOptions.UnknownCommandReturnsFalse | ValidateResponseOptions.ErrorMessageReturned))
             {
-                if ((flags & ~WriteDumpFlags.LoggingEnabled) != 0)
+                request = CreateWriteDumpMessage(DumpCommandId.GenerateCoreDump2, dumpType, dumpPath, flags);
+                response = IpcClient.SendMessage(_endpoint, request);
+                if (!ValidateResponseMessage(response, "Write dump", ValidateResponseOptions.UnknownCommandReturnsFalse))
                 {
-                    throw new ArgumentException($"Only {nameof(WriteDumpFlags.LoggingEnabled)} flag is supported by this runtime version", nameof(flags));
+                    if ((flags & ~WriteDumpFlags.LoggingEnabled) != 0)
+                    {
+                        throw new ArgumentException($"Only {nameof(WriteDumpFlags.LoggingEnabled)} flag is supported by this runtime version", nameof(flags));
+                    }
+                    request = CreateWriteDumpMessage(dumpType, dumpPath, logDumpGeneration: (flags & WriteDumpFlags.LoggingEnabled) != 0);
+                    response = IpcClient.SendMessage(_endpoint, request);
+                    ValidateResponseMessage(response, "Write dump");
                 }
-                WriteDump(dumpType, dumpPath, logDumpGeneration: (flags & WriteDumpFlags.LoggingEnabled) != 0);
             }
         }
 
@@ -153,11 +158,9 @@ namespace Microsoft.Diagnostics.NETCore.Client
         /// <param name="dumpPath">Full path to the dump to be generated. By default it is /tmp/coredump.{pid}</param>
         /// <param name="logDumpGeneration">When set to true, display the dump generation debug log to the console.</param>
         /// <param name="token">The token to monitor for cancellation requests.</param>
-        public async Task WriteDumpAsync(DumpType dumpType, string dumpPath, bool logDumpGeneration, CancellationToken token)
+        public Task WriteDumpAsync(DumpType dumpType, string dumpPath, bool logDumpGeneration, CancellationToken token)
         {
-            IpcMessage request = CreateWriteDumpMessage(dumpType, dumpPath, logDumpGeneration);
-            IpcMessage response = await IpcClient.SendMessageAsync(_endpoint, request, token).ConfigureAwait(false);
-            ValidateResponseMessage(response, nameof(WriteDumpAsync));
+            return WriteDumpAsync(dumpType, dumpPath, logDumpGeneration ? WriteDumpFlags.LoggingEnabled : WriteDumpFlags.None, token);
         }
 
         /// <summary>
@@ -169,15 +172,22 @@ namespace Microsoft.Diagnostics.NETCore.Client
         /// <param name="token">The token to monitor for cancellation requests.</param>
         public async Task WriteDumpAsync(DumpType dumpType, string dumpPath, WriteDumpFlags flags, CancellationToken token)
         {
-            IpcMessage request = CreateWriteDumpMessage2(dumpType, dumpPath, flags);
+            IpcMessage request = CreateWriteDumpMessage(DumpCommandId.GenerateCoreDump3, dumpType, dumpPath, flags);
             IpcMessage response = await IpcClient.SendMessageAsync(_endpoint, request, token).ConfigureAwait(false);
-            if (!ValidateResponseMessage(response, nameof(WriteDumpAsync), ValidateResponseOptions.UnknownCommandReturnsFalse))
+            if (!ValidateResponseMessage(response, "Write dump", ValidateResponseOptions.UnknownCommandReturnsFalse | ValidateResponseOptions.ErrorMessageReturned))
             {
-                if ((flags & ~WriteDumpFlags.LoggingEnabled) != 0)
+                request = CreateWriteDumpMessage(DumpCommandId.GenerateCoreDump2, dumpType, dumpPath, flags);
+                response = await IpcClient.SendMessageAsync(_endpoint, request, token).ConfigureAwait(false);
+                if (!ValidateResponseMessage(response, "Write dump", ValidateResponseOptions.UnknownCommandReturnsFalse))
                 {
-                    throw new ArgumentException($"Only {nameof(WriteDumpFlags.LoggingEnabled)} flag is supported by this runtime version", nameof(flags));
+                    if ((flags & ~WriteDumpFlags.LoggingEnabled) != 0)
+                    {
+                        throw new ArgumentException($"Only {nameof(WriteDumpFlags.LoggingEnabled)} flag is supported by this runtime version", nameof(flags));
+                    }
+                    request = CreateWriteDumpMessage(dumpType, dumpPath, logDumpGeneration: (flags & WriteDumpFlags.LoggingEnabled) != 0);
+                    response = await IpcClient.SendMessageAsync(_endpoint, request, token).ConfigureAwait(false);
+                    ValidateResponseMessage(response, "Write dump");
                 }
-                await WriteDumpAsync(dumpType, dumpPath, logDumpGeneration: (flags & WriteDumpFlags.LoggingEnabled) != 0, token);
             }
         }
 
@@ -522,13 +532,13 @@ namespace Microsoft.Diagnostics.NETCore.Client
             return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump, payload);
         }
 
-        private static IpcMessage CreateWriteDumpMessage2(DumpType dumpType, string dumpPath, WriteDumpFlags flags)
+        private static IpcMessage CreateWriteDumpMessage(DumpCommandId command, DumpType dumpType, string dumpPath, WriteDumpFlags flags)
         {
             if (string.IsNullOrEmpty(dumpPath))
                 throw new ArgumentNullException($"{nameof(dumpPath)} required");
 
             byte[] payload = SerializePayload(dumpPath, (uint)dumpType, (uint)flags);
-            return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)DumpCommandId.GenerateCoreDump2, payload);
+            return new IpcMessage(DiagnosticsServerCommandSet.Dump, (byte)command, payload);
         }
 
         private static ProcessInfo GetProcessInfoFromResponse(IpcResponse response, string operationName)
@@ -552,8 +562,13 @@ namespace Microsoft.Diagnostics.NETCore.Client
         {
             switch ((DiagnosticsServerResponseId)responseMessage.Header.CommandId)
             {
+                case DiagnosticsServerResponseId.OK:
+                    return true;
+
                 case DiagnosticsServerResponseId.Error:
                     uint hr = BitConverter.ToUInt32(responseMessage.Payload, 0);
+                    int index = sizeof(uint);
+                    string message = null;
                     switch (hr)
                     {
                         case (uint)DiagnosticsIpcError.UnknownCommand:
@@ -562,18 +577,36 @@ namespace Microsoft.Diagnostics.NETCore.Client
                                 return false;
                             }
                             throw new UnsupportedCommandException($"{operationName} failed - Command is not supported.");
+
                         case (uint)DiagnosticsIpcError.ProfilerAlreadyActive:
                             throw new ProfilerAlreadyActiveException($"{operationName} failed - A profiler is already loaded.");
+
                         case (uint)DiagnosticsIpcError.InvalidArgument:
                             if (options.HasFlag(ValidateResponseOptions.InvalidArgumentIsRequiresSuspension))
                             {
                                 throw new ServerErrorException($"{operationName} failed - The runtime must be suspended for this command.");
                             }
                             throw new UnsupportedCommandException($"{operationName} failed - Invalid command argument.");
+
+                        case (uint)DiagnosticsIpcError.NotSupported:
+                            message = $"{operationName} - Not supported by this runtime.";
+                            break;
+
+                        default:
+                            break;
                     }
-                    throw new ServerErrorException($"{operationName} failed - HRESULT: 0x{hr:X8}");
-                case DiagnosticsServerResponseId.OK:
-                    return true;
+                    // Check if the command can return an error message and if the payload is big enough to contain the
+                    // error code (uint) and the string length (uint).
+                    if (options.HasFlag(ValidateResponseOptions.ErrorMessageReturned) && responseMessage.Payload.Length >= (sizeof(uint) * 2))
+                    {
+                        message = IpcHelpers.ReadString(responseMessage.Payload, ref index);
+                    }
+                    if (string.IsNullOrWhiteSpace(message))
+                    {
+                        message = $"{operationName} failed - HRESULT: 0x{hr:X8}.";
+                    }
+                    throw new ServerErrorException(message);
+
                 default:
                     throw new ServerErrorException($"{operationName} failed - Server responded with unknown response.");
             }
@@ -585,6 +618,7 @@ namespace Microsoft.Diagnostics.NETCore.Client
             None = 0x0,
             UnknownCommandReturnsFalse = 0x1,
             InvalidArgumentIsRequiresSuspension = 0x2,
+            ErrorMessageReturned = 0x4,
         }
     }
 }
index 516cf3064562c6ceb34da7ace89308b0f3e98b42..241acaee04eca821af07573c78089316f867f38b 100644 (file)
@@ -35,6 +35,7 @@ namespace Microsoft.Diagnostics.NETCore.Client
     {
         GenerateCoreDump = 0x01,
         GenerateCoreDump2 = 0x02,
+        GenerateCoreDump3 = 0x03,
     }
 
     internal enum ProfilerCommandId : byte
index 9aa4d253047e64164fa8ddbc280d1e001c5b1626..9a771b83b5d205c3486dccf0f10b4e50783f81e2 100644 (file)
@@ -16,7 +16,9 @@ namespace Microsoft.Diagnostics.NETCore.Client
     /// </summary>
     internal enum DiagnosticsIpcError : uint
     {
+        Fail                  = 0x80004005,
         InvalidArgument       = 0x80070057,
+        NotSupported          = 0x80131515,
         ProfilerAlreadyActive = 0x8013136A,
         BadEncoding           = 0x80131384,
         UnknownCommand        = 0x80131385,
index b9753f1a4fcdf7f2f41905978edf40220ef348b9..a89cfe5485ebc224d0b7b51cc3b4e4ff67da22bb 100644 (file)
@@ -57,21 +57,10 @@ namespace SOS
         {
             m_writeLine = writeLine;
             string rid = GetRid(architecture);
-            string home;
+            string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
 
-            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) 
+            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
             {
-                home = Environment.GetEnvironmentVariable("USERPROFILE");
-                if (string.IsNullOrEmpty(home)) {
-                    throw new SOSInstallerException("USERPROFILE environment variable not found");
-                }
-            }
-            else
-            {
-                home = Environment.GetEnvironmentVariable("HOME");
-                if (string.IsNullOrEmpty(home)) {
-                    throw new SOSInstallerException("HOME environment variable not found");
-                }
                 LLDBInitFile = Path.Combine(home, ".lldbinit");
             }
             InstallLocation = Path.GetFullPath(Path.Combine(home, ".dotnet", "sos"));
@@ -87,16 +76,20 @@ namespace SOS
         {
             WriteLine("Installing SOS to {0}", InstallLocation);
 
-            if (string.IsNullOrEmpty(SOSNativeSourcePath) || string.IsNullOrEmpty(SOSManagedSourcePath)) {
+            if (string.IsNullOrEmpty(SOSNativeSourcePath) || string.IsNullOrEmpty(SOSManagedSourcePath))
+            {
                 throw new SOSInstallerException("SOS source path not valid");
             }
-            if (!Directory.Exists(SOSNativeSourcePath)) {
+            if (!Directory.Exists(SOSNativeSourcePath))
+            {
                 throw new SOSInstallerException($"Operating system or architecture not supported: installing from {SOSNativeSourcePath}");
             }
-            if (!Directory.Exists(SOSManagedSourcePath)) {
+            if (!Directory.Exists(SOSManagedSourcePath))
+            {
                 throw new SOSInstallerException($"Invalid SOS source directory {SOSManagedSourcePath}");
             }
-            if (string.IsNullOrEmpty(InstallLocation)) {
+            if (string.IsNullOrEmpty(InstallLocation))
+            {
                 throw new SOSInstallerException($"Installation path {InstallLocation} not valid");
             }
 
@@ -139,10 +132,12 @@ namespace SOS
                 });
 
                 // Configure lldb 
-                if (LLDBInitFile != null) {
+                if (LLDBInitFile != null)
+                {
                     Configure();
                 }
-                else {
+                else
+                {
                     WriteLine($"Execute '.load {InstallLocation}\\sos.dll' to load SOS in your Windows debugger.");
                 }
 
@@ -207,7 +202,8 @@ namespace SOS
         /// <exception cref="SOSInstallerException"></exception>
         public void Configure(bool remove = false)
         {
-            if (string.IsNullOrEmpty(LLDBInitFile)) {
+            if (string.IsNullOrEmpty(LLDBInitFile))
+            {
                 throw new SOSInstallerException("No lldb configuration file path");
             }
             bool changed = false;
@@ -243,7 +239,8 @@ namespace SOS
                     }
                 }
 
-                if (markerFound) {
+                if (markerFound)
+                {
                     throw new SOSInstallerException(".lldbinit file end marker not found");
                 }
             }
@@ -256,7 +253,8 @@ namespace SOS
                 string extension = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? ".dylib" : ".so";
                 lines.Add($"plugin load {plugin}{extension}");
 
-                if (EnableSymbolServer) {
+                if (EnableSymbolServer)
+                {
                     lines.Add(string.Format("setsymbolserver -ms"));
                 }
                 lines.Add(InitFileEnd);
@@ -266,10 +264,12 @@ namespace SOS
             // If there is anything to write, write the lldb init file
             if (changed)
             {
-                if (remove) {
+                if (remove)
+                {
                     WriteLine("Reverting {0} file - LLDB will no longer load SOS at startup", LLDBInitFile);
                 }
-                else {
+                else
+                {
                     WriteLine("{0} {1} file - LLDB will load SOS automatically at startup", existing ? "Updating existing" : "Creating new", LLDBInitFile);
                 }
                 RetryOperation($"Problem writing lldb init file {LLDBInitFile}", () => File.WriteAllLines(LLDBInitFile, lines.ToArray()));
@@ -303,7 +303,8 @@ namespace SOS
                 }
                 catch (Exception ex) when (ex is ArgumentException || ex is UnauthorizedAccessException || ex is SecurityException)
                 {
-                    if (errorMessage == null) {
+                    if (errorMessage == null)
+                    {
                         return;
                     }
                     throw new SOSInstallerException($"{errorMessage}: {ex.Message}", ex);
@@ -312,7 +313,8 @@ namespace SOS
 
             if (lastfailure != null)
             {
-                if (errorMessage == null) {
+                if (errorMessage == null)
+                {
                     return;
                 }
                 throw new SOSInstallerException($"{errorMessage}: {lastfailure.Message}", lastfailure);
@@ -378,4 +380,4 @@ namespace SOS
         {
         }
     }
-}
\ No newline at end of file
+}
index 2642d0a755619879bde954bd9dee2cc5cd40ed80..7bb21cf8b09e64fc46576911674470d9a34d419c 100644 (file)
@@ -503,12 +503,12 @@ void GCPrintSegmentInfo(const GCHeapDetails &heap, DWORD_PTR &total_allocated_si
                 }
                 ExtOut("%p  %p  %p  %p  0x%" POINTERSIZE_TYPE "x(%" POINTERSIZE_TYPE"d)  0x%" POINTERSIZE_TYPE "x(%" POINTERSIZE_TYPE "d)\n",
                     SOS_PTR(dwAddrSeg),
-                    SOS_PTR(segment.mem), SOS_PTR(segment.allocated), SOS_PTR(segment.committed),
-                    (ULONG_PTR)(segment.allocated - segment.mem),
-                    (ULONG_PTR)(segment.allocated - segment.mem),
+                    SOS_PTR(segment.mem), SOS_PTR(segment.highAllocMark), SOS_PTR(segment.committed),
+                    (ULONG_PTR)(segment.highAllocMark - segment.mem),
+                    (ULONG_PTR)(segment.highAllocMark - segment.mem),
                     (ULONG_PTR)(segment.committed - segment.mem),
                     (ULONG_PTR)(segment.committed - segment.mem));
-                total_allocated_size += (DWORD_PTR)(segment.allocated - segment.mem);
+                total_allocated_size += (DWORD_PTR)(segment.highAllocMark - segment.mem);
                 total_committed_size += (DWORD_PTR)(segment.committed - segment.mem);
                 dwAddrSeg = (DWORD_PTR)segment.next;
             }
@@ -700,16 +700,11 @@ BOOL GCObjInSegment(TADDR taddrObj, const GCHeapDetails &heap,
                     ExtOut("Error requesting heap segment %p\n", SOS_PTR(taddrSeg));
                     return FALSE;
                 }
-                TADDR allocated = TO_TADDR(dacpSeg.allocated);
-                if (taddrSeg == TO_TADDR(heap.ephemeral_heap_segment))
-                {
-                    allocated = TO_TADDR(heap.alloc_allocated);
-                }
-                if (taddrObj >= TO_TADDR(dacpSeg.mem) && taddrObj < allocated)
+                if (taddrObj >= TO_TADDR(dacpSeg.mem) && taddrObj < dacpSeg.highAllocMark)
                 {
                     rngSeg.segAddr = (TADDR)dacpSeg.segmentAddr;
                     rngSeg.start = (TADDR)dacpSeg.mem;
-                    rngSeg.end = (TADDR)dacpSeg.allocated;
+                    rngSeg.end = (TADDR)dacpSeg.highAllocMark;
                     gen = gen_num;
                     return TRUE;
                 }
@@ -983,7 +978,7 @@ BOOL GCHeapUsageStats(const GCHeapDetails& heap, BOOL bIncUnreachable, HeapUsage
                     return FALSE;
                 }
 #ifndef FEATURE_PAL
-                GCGenUsageStats((TADDR)dacpSeg.mem, (TADDR)dacpSeg.allocated, (TADDR)dacpSeg.committed, liveObjs, heap, FALSE, FALSE, &allocInfo, &hpUsage->genUsage[n]);
+                GCGenUsageStats((TADDR)dacpSeg.mem, (TADDR)dacpSeg.highAllocMark, (TADDR)dacpSeg.committed, liveObjs, heap, FALSE, FALSE, &allocInfo, &hpUsage->genUsage[n]);
 #endif
                 taddrSeg = (TADDR)dacpSeg.next;
             }
@@ -1268,7 +1263,6 @@ BOOL GCHeapTraverse(const GCHeapDetails &heap, AllocInfo* pallocInfo, VISITGCHEA
     DacpHeapSegmentData segment;
     if (heap.has_regions)
     {
-        DWORD_PTR end_youngest = (DWORD_PTR)heap.alloc_allocated;
         BOOL bPrevFree = FALSE;
         for (UINT n = 0; n <= GetMaxGeneration(); n++)
         {
@@ -1286,15 +1280,11 @@ BOOL GCHeapTraverse(const GCHeapDetails &heap, AllocInfo* pallocInfo, VISITGCHEA
                     return FALSE;
                 }
                 dwAddrCurrObj = (DWORD_PTR)segment.mem;
-                DWORD_PTR end_of_segment = (DWORD_PTR)segment.allocated;
-                if (dwAddrSeg == (DWORD_PTR)heap.ephemeral_heap_segment)
-                {
-                    end_of_segment = end_youngest;
-                }
+                DWORD_PTR end_of_segment = (DWORD_PTR)segment.highAllocMark;
 
                 while (true)
                 {
-                    if (dwAddrCurrObj - SIZEOF_OBJHEADER == end_youngest - Align(min_obj_size))
+                    if (dwAddrCurrObj - SIZEOF_OBJHEADER == end_of_segment - Align(min_obj_size))
                         break;
 
                     if (dwAddrCurrObj >= (DWORD_PTR)end_of_segment)
@@ -1314,13 +1304,13 @@ BOOL GCHeapTraverse(const GCHeapDetails &heap, AllocInfo* pallocInfo, VISITGCHEA
                     }
 
                     if (dwAddrSeg == (DWORD_PTR)heap.ephemeral_heap_segment
-                        && dwAddrCurrObj >= end_youngest)
+                        && dwAddrCurrObj >= end_of_segment)
                     {
-                        if (dwAddrCurrObj > end_youngest)
+                        if (dwAddrCurrObj > end_of_segment)
                         {
                             // prev_object length is too long
-                            ExtOut("curr_object: %p > end_youngest: %p\n",
-                                SOS_PTR(dwAddrCurrObj), SOS_PTR(end_youngest));
+                            ExtOut("curr_object: %p > end_of_segment: %p\n",
+                                SOS_PTR(dwAddrCurrObj), SOS_PTR(end_of_segment));
                             if (dwAddrPrevObj) 
                             {
                                 DMLOut("Last good object: %s\n", DMLObject(dwAddrPrevObj));
@@ -2017,18 +2007,45 @@ int GCHeapSnapshot::GetGeneration(CLRDATA_ADDRESS objectPointer)
     }
 
     TADDR taObj = TO_TADDR(objectPointer);
-    // The DAC doesn't fill the generation table with true CLRDATA_ADDRESS values
-    // but rather with ULONG64 values (i.e. non-sign-extended 64-bit values)
-    // We use the TO_TADDR below to ensure we won't break if this will ever
-    // be fixed in the DAC.
-    if (taObj >= TO_TADDR(pDetails->generation_table[0].allocation_start) &&
-        taObj <= TO_TADDR(pDetails->alloc_allocated))
-        return 0;
-
-    if (taObj >= TO_TADDR(pDetails->generation_table[1].allocation_start) &&
-        taObj <= TO_TADDR(pDetails->generation_table[0].allocation_start))
-        return 1;
+    if (pDetails->has_regions)
+    {
+        for (int gen_num = 0; gen_num <= 1; gen_num++)
+        {
+            CLRDATA_ADDRESS dwAddrSeg = pDetails->generation_table[gen_num].start_segment;
+            while (dwAddrSeg != 0)
+            {
+                DacpHeapSegmentData segment;
+                if (segment.Request(g_sos, dwAddrSeg, pDetails->original_heap_details) != S_OK)
+                {
+                    ExtOut("Error requesting heap segment %p\n", SOS_PTR(dwAddrSeg));
+                    return 0;
+                }
+                // The DAC doesn't fill the generation table with true CLRDATA_ADDRESS values
+                // but rather with ULONG64 values (i.e. non-sign-extended 64-bit values)
+                // We use the TO_TADDR below to ensure we won't break if this will ever
+                // be fixed in the DAC.
+                if (TO_TADDR(segment.mem) <= taObj && taObj < TO_TADDR(segment.highAllocMark))
+                {
+                    return gen_num;
+                }
+                dwAddrSeg = segment.next;
+            }
+        }
+    }
+    else
+    {
+        // The DAC doesn't fill the generation table with true CLRDATA_ADDRESS values
+        // but rather with ULONG64 values (i.e. non-sign-extended 64-bit values)
+        // We use the TO_TADDR below to ensure we won't break if this will ever
+        // be fixed in the DAC.
+        if (taObj >= TO_TADDR(pDetails->generation_table[0].allocation_start) &&
+            taObj <= TO_TADDR(pDetails->alloc_allocated))
+            return 0;
 
+        if (taObj >= TO_TADDR(pDetails->generation_table[1].allocation_start) &&
+            taObj <= TO_TADDR(pDetails->generation_table[0].allocation_start))
+            return 1;
+    }
     return 2;
 }
 
index a649bad82c69aa92240d83cf59da220ad0ad02a9..b4cfe56615387e2c3c4c904e42033dce4bf5f675 100644 (file)
@@ -1656,8 +1656,7 @@ BOOL FindSegment(const GCHeapDetails &heap, DacpHeapSegmentData &seg, CLRDATA_AD
                     ExtOut("Error requesting heap segment %p\n", SOS_PTR(dwAddrSeg));
                     return FALSE;
                 }
-                if (addr >= TO_TADDR(seg.mem) &&
-                    addr < (dwAddrSeg == heap.ephemeral_heap_segment ? heap.alloc_allocated : TO_TADDR(seg.allocated)))
+                if (addr >= TO_TADDR(seg.mem) && addr < seg.highAllocMark)
                 {
                     return TRUE;
                 }
index a430fac743587ae27f233671afc3c5162e0591ea..f2052cfa2ef726930446e19399a0e0b11b416ec2 100644 (file)
@@ -596,9 +596,7 @@ namespace sos
         }
 
         mCurrObj = mStart < TO_TADDR(mSegment.mem) ? TO_TADDR(mSegment.mem) : mStart;
-        mSegmentEnd = (segStart == TO_TADDR(mHeaps[0].ephemeral_heap_segment)) ?
-                            TO_TADDR(mHeaps[0].alloc_allocated) :
-                            TO_TADDR(mSegment.allocated);
+        mSegmentEnd = TO_TADDR(mSegment.highAllocMark);
 
         CheckSegmentRange();
     }
@@ -661,9 +659,7 @@ namespace sos
 
         mLastObj = 0;
         mCurrObj = mStart < TO_TADDR(mSegment.mem) ? TO_TADDR(mSegment.mem) : mStart;
-        mSegmentEnd = (next == TO_TADDR(mHeaps[mCurrHeap].ephemeral_heap_segment)) ?
-                            TO_TADDR(mHeaps[mCurrHeap].alloc_allocated) :
-                            TO_TADDR(mSegment.allocated);
+        mSegmentEnd = TO_TADDR(mSegment.highAllocMark);
         return CheckSegmentRange();
     }
 
index 0e284c974c93c952827e4f048d0969e302a047a8..7532b870dffdcebea9d71cd38fd03c16ad5a8c4a 100644 (file)
@@ -47,7 +47,8 @@ namespace Microsoft.Diagnostics.Tools.Dump
             _serviceProvider.AddService<IContextService>(_contextService);
             _serviceProvider.AddServiceFactory<SOSLibrary>(() => SOSLibrary.Create(this));
 
-            _contextService.ServiceProvider.AddServiceFactory<ClrMDHelper>(() => {
+            _contextService.ServiceProvider.AddServiceFactory<ClrMDHelper>(() =>
+            {
                 ClrRuntime clrRuntime = _contextService.Services.GetService<ClrRuntime>();
                 return clrRuntime != null ? new ClrMDHelper(clrRuntime) : null;
             });
@@ -64,23 +65,17 @@ namespace Microsoft.Diagnostics.Tools.Dump
             _consoleProvider.WriteLine($"Loading core dump: {dump_path} ...");
 
             // Attempt to load the persisted command history
-            string dotnetHome;
-            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) {
-                dotnetHome = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), ".dotnet");
-            }
-            else { 
-                dotnetHome = Path.Combine(Environment.GetEnvironmentVariable("HOME"), ".dotnet");
-            }
+            string dotnetHome = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".dotnet");
             string historyFileName = Path.Combine(dotnetHome, "dotnet-dump.history");
             try
             {
                 string[] history = File.ReadAllLines(historyFileName);
                 _consoleProvider.AddCommandHistory(history);
             }
-            catch (Exception ex) when 
-                (ex is IOException || 
-                 ex is UnauthorizedAccessException || 
-                 ex is NotSupportedException || 
+            catch (Exception ex) when
+                (ex is IOException ||
+                 ex is UnauthorizedAccessException ||
+                 ex is NotSupportedException ||
                  ex is SecurityException)
             {
             }
@@ -89,11 +84,12 @@ namespace Microsoft.Diagnostics.Tools.Dump
             LoadExtensions();
 
             try
-            { 
+            {
                 using DataTarget dataTarget = DataTarget.LoadDump(dump_path.FullName);
 
                 OSPlatform targetPlatform = dataTarget.DataReader.TargetPlatform;
-                if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || dataTarget.DataReader.EnumerateModules().Any((module) => Path.GetExtension(module.FileName) == ".dylib")) {
+                if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || dataTarget.DataReader.EnumerateModules().Any((module) => Path.GetExtension(module.FileName) == ".dylib"))
+                {
                     targetPlatform = OSPlatform.OSX;
                 }
                 _target = new TargetFromDataReader(dataTarget.DataReader, targetPlatform, this, _targetIdFactory++, dump_path.FullName);
@@ -112,7 +108,8 @@ namespace Microsoft.Diagnostics.Tools.Dump
                     foreach (string cmd in command)
                     {
                         _commandService.Execute(cmd, _contextService.Services);
-                        if (_consoleProvider.Shutdown) {
+                        if (_consoleProvider.Shutdown)
+                        {
                             break;
                         }
                     }
@@ -123,7 +120,8 @@ namespace Microsoft.Diagnostics.Tools.Dump
                     _consoleProvider.WriteLine("Ready to process analysis commands. Type 'help' to list available commands or 'help [command]' to get detailed help on a command.");
                     _consoleProvider.WriteLine("Type 'quit' or 'exit' to exit the session.");
 
-                    _consoleProvider.Start((string commandLine, CancellationToken cancellation) => {
+                    _consoleProvider.Start((string commandLine, CancellationToken cancellation) =>
+                    {
                         _commandService.Execute(commandLine, _contextService.Services);
                     });
                 }
@@ -152,10 +150,10 @@ namespace Microsoft.Diagnostics.Tools.Dump
                 {
                     File.WriteAllLines(historyFileName, _consoleProvider.GetCommandHistory());
                 }
-                catch (Exception ex) when 
-                    (ex is IOException || 
-                     ex is UnauthorizedAccessException || 
-                     ex is NotSupportedException || 
+                catch (Exception ex) when
+                    (ex is IOException ||
+                     ex is UnauthorizedAccessException ||
+                     ex is NotSupportedException ||
                      ex is SecurityException)
                 {
                 }
@@ -177,14 +175,16 @@ namespace Microsoft.Diagnostics.Tools.Dump
 
         public void DestroyTarget(ITarget target)
         {
-            if (target == null) {
+            if (target == null)
+            {
                 throw new ArgumentNullException(nameof(target));
             }
             if (target == _target)
             {
                 _target = null;
                 _contextService.ClearCurrentTarget();
-                if (target is IDisposable disposable) {
+                if (target is IDisposable disposable)
+                {
                     disposable.Dispose();
                 }
             }
@@ -221,7 +221,7 @@ namespace Microsoft.Diagnostics.Tools.Dump
             {
                 assembly = Assembly.LoadFrom(extensionPath);
             }
-            catch (Exception ex) when (ex is IOException || ex is ArgumentException  || ex is BadImageFormatException || ex is System.Security.SecurityException)
+            catch (Exception ex) when (ex is IOException || ex is ArgumentException || ex is BadImageFormatException || ex is System.Security.SecurityException)
             {
                 _consoleProvider.WriteLineError($"Extension load {extensionPath} FAILED {ex.Message}");
             }
index 12d4d5cc1945a2f631684e9d03530fc621b55ef2..41de4e2ae83e6e62a4dbe3eb6d21b690b8148b17 100644 (file)
@@ -4,7 +4,7 @@
 
 using Microsoft.Win32.SafeHandles;
 using System;
-using System.Diagnostics;
+using System.ComponentModel;
 using System.IO;
 using System.Runtime.InteropServices;
 
@@ -21,7 +21,9 @@ namespace Microsoft.Diagnostics.Tools.Dump
                 using SafeProcessHandle processHandle = NativeMethods.OpenProcess(NativeMethods.PROCESS_QUERY_INFORMATION | NativeMethods.PROCESS_VM_READ, false, processId);
                 if (processHandle.IsInvalid)
                 {
-                    throw new ArgumentException($"Invalid process id {processId} error: {Marshal.GetLastWin32Error()}");
+                    int error = Marshal.GetLastWin32Error();
+                    string errorText = new Win32Exception(error).Message;
+                    throw new ArgumentException($"Invalid process id {processId} - {errorText} ({error})");
                 }
 
                 // Open the file for writing
@@ -77,7 +79,7 @@ namespace Microsoft.Diagnostics.Tools.Dump
                         else
                         {
                             int err = Marshal.GetHRForLastWin32Error();
-                            if (err != NativeMethods.ERROR_PARTIAL_COPY)
+                            if (err != NativeMethods.HR_ERROR_PARTIAL_COPY)
                             {
                                 Marshal.ThrowExceptionForHR(err);
                             }
@@ -88,7 +90,7 @@ namespace Microsoft.Diagnostics.Tools.Dump
 
             private static class NativeMethods
             {
-                public const int ERROR_PARTIAL_COPY = unchecked((int)0x8007012b);
+                public const int HR_ERROR_PARTIAL_COPY = unchecked((int)0x8007012b);
 
                 public const int PROCESS_VM_READ = 0x0010;
                 public const int PROCESS_QUERY_INFORMATION = 0x0400;
index 40fa07a85624fe700f86a985a4b7dac2f235a678..0f6a0741b91592f40bf12192d9eecc0f53888d02 100644 (file)
@@ -643,13 +643,15 @@ HRESULT CLRDebuggingImpl::GetCLRInfo(ICorDebugDataTarget * pDataTarget,
             hrGetResource = GetResourceRvaFromResourceSectionRvaByName(pDataTarget, moduleBaseAddress, resourceSectionRVA, 10, resourceName, 0, &debugResourceRVA, &debugResourceSize);
             useCrossPlatformNaming = SUCCEEDED(hrGetResource);
 
-    #if defined(HOST_WINDOWS) && (defined(HOST_X86) || defined(HOST_AMD64) || defined(HOST_ARM))
+    #if defined(HOST_WINDOWS) && (defined(HOST_X86) || defined(HOST_AMD64) || defined(HOST_ARM) || defined(HOST_ARM64))
       #if defined(HOST_X86)
         #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_I386
       #elif defined(HOST_AMD64)
         #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_AMD64
       #elif defined(HOST_ARM)
         #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_ARMNT
+      #elif defined(HOST_ARM64)
+        #define _HOST_MACHINE_TYPE IMAGE_FILE_MACHINE_ARM64
       #endif
 
             // if this is windows, and if host_arch matches target arch then we can fallback to searching for CLRDEBUGINFO on failure
@@ -661,7 +663,7 @@ HRESULT CLRDebuggingImpl::GetCLRInfo(ICorDebugDataTarget * pDataTarget,
       #undef _HOST_MACHINE_TYPE
     #endif
             // if the search failed, we don't recognize the CLR
-            if(FAILED(hrGetResource))
+            if (FAILED(hrGetResource))
             {
                 hr = CORDBG_E_NOT_CLR;
             }
index 045b82e1c5293b6b8d93a1e0f94eb152ff33d60a..cf15af8c84719a0fe0282549817033052ae72b65 100644 (file)
@@ -5,12 +5,10 @@
       <!-- IncludeBuildOutput needs to be set to true to make NuGet include the passed in debug symbol files. -->
       <IncludeBuildOutput>false</IncludeBuildOutput>
       <IncludeSymbols>true</IncludeSymbols>
-      <DebugSymbols>false</DebugSymbols>
-      <DebugType>none</DebugType>
       <IsPackable>true</IsPackable>
-      <AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>.pdb;.dbg;.dwarf</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>
+      <AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>$(SymbolsSuffix)</AllowedOutputExtensionsInSymbolsPackageBuildOutputFolder>
       <!-- When KeepNativeSymbols is set, debug symbols are kept in the .so files.  Separate symbol files do not exist that need to be packed. -->
-      <!-- <TargetsForTfmSpecificDebugSymbolsInPackage Condition="'$(KeepNativeSymbols)' != 'true'">$(TargetsForTfmSpecificDebugSymbolsInPackage);AddRuntimeSpecificNativeSymbolToPackage</TargetsForTfmSpecificDebugSymbolsInPackage> -->
+      <TargetsForTfmSpecificDebugSymbolsInPackage Condition="'$(KeepNativeSymbols)' != 'true'">$(TargetsForTfmSpecificDebugSymbolsInPackage);AddRuntimeSpecificNativeSymbolToPackage</TargetsForTfmSpecificDebugSymbolsInPackage>
       <UseRuntimePackageDisclaimer>true</UseRuntimePackageDisclaimer>
       <!-- This is a native package and doesn't contain any ref/lib assets. -->
       <NoWarn>$(NoWarn);NU5128</NoWarn>
 
     <Target Name="AddRuntimeSpecificNativeSymbolToPackage">
       <ItemGroup>
-        <TfmSpecificDebugSymbolsFile Include="$(NativeBinDir)$(LibPrefix)dbgshim$(LibSuffix)$(SymbolsSuffix)"
+        <TfmSpecificDebugSymbolsFile Condition="$(OutputRid.StartsWith('win'))"
+                                     Include="$(NativeBinDir)PDB\$(LibPrefix)dbgshim$(SymbolsSuffix)"
+                                     TargetPath="/runtimes/$(OutputRid)/native"
+                                     TargetFramework="$(TargetFramework)" />
+
+        <TfmSpecificDebugSymbolsFile Condition="!$(OutputRid.StartsWith('win'))"
+                                     Include="$(NativeBinDir)$(LibPrefix)dbgshim$(LibSuffix)$(SymbolsSuffix)"
                                      TargetPath="/runtimes/$(OutputRid)/native"
                                      TargetFramework="$(TargetFramework)" />
       </ItemGroup>
index 1dec58062d570907b85be5e33430dbf55b9c26b3..abbb31405da7874463cefbe18492d82ae2d0133b 100644 (file)
@@ -805,13 +805,15 @@ struct MSLAYOUT DacpHeapSegmentData
 
     HRESULT Request(ISOSDacInterface *sos, CLRDATA_ADDRESS addr, const DacpGcHeapDetails& heap)
     {
+        // clear this here to make sure we don't get stale values
+        this->highAllocMark = 0;
+
         HRESULT hr = sos->GetHeapSegmentData(addr, this);
 
-        // if this is the start segment, set highAllocMark too.
-        if (SUCCEEDED(hr))
+        // if this is the start segment, and the Dac hasn't set highAllocMark, set it here.
+        if (SUCCEEDED(hr) && this->highAllocMark == 0)
         {
-            // TODO:  This needs to be put on the Dac side.
-            if (this->segmentAddr == heap.generation_table[0].start_segment)
+            if (this->segmentAddr == heap.ephemeral_heap_segment)
                 highAllocMark = heap.alloc_allocated;
             else
                 highAllocMark = allocated;
index 1880375184f057bdbfdfe3503ed6c1a26b95ba8b..f722da0e4b1af414f2708f4707f5b2d42b2da31b 100644 (file)
@@ -2,6 +2,9 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 //
 
+// This file is a verbatim copy of the Windows OS header with PE file structure definitions.
+
+
 //
 // ===========================================================================
 // File: ntimage.h
@@ -222,7 +225,7 @@ typedef struct _IMAGE_FILE_HEADER {
 #define IMAGE_FILE_MACHINE_SH4               0x01a6  // SH4 little-endian
 #define IMAGE_FILE_MACHINE_SH5               0x01a8  // SH5
 #define IMAGE_FILE_MACHINE_ARM               0x01c0  // ARM Little-Endian
-#define IMAGE_FILE_MACHINE_THUMB             0x01c2
+#define IMAGE_FILE_MACHINE_THUMB             0x01c2  // ARM Thumb/Thumb-2 Little-Endian
 #define IMAGE_FILE_MACHINE_ARMNT             0x01c4  // ARM Thumb-2 Little-Endian
 #define IMAGE_FILE_MACHINE_AM33              0x01d3
 #define IMAGE_FILE_MACHINE_POWERPC           0x01F0  // IBM PowerPC Little-Endian
@@ -238,7 +241,9 @@ typedef struct _IMAGE_FILE_HEADER {
 #define IMAGE_FILE_MACHINE_EBC               0x0EBC  // EFI Byte Code
 #define IMAGE_FILE_MACHINE_AMD64             0x8664  // AMD64 (K8)
 #define IMAGE_FILE_MACHINE_M32R              0x9041  // M32R little-endian
+#define IMAGE_FILE_MACHINE_ARM64             0xAA64  // ARM64 Little-Endian
 #define IMAGE_FILE_MACHINE_CEE               0xC0EE
+#define IMAGE_FILE_MACHINE_LOONGARCH64       0x6264  // LOONGARCH64.
 
 //
 // Directory format.
@@ -1025,6 +1030,12 @@ typedef IMAGE_RELOCATION UNALIGNED *PIMAGE_RELOCATION;
 #define IMAGE_REL_IA64_GPREL32          0x001C
 #define IMAGE_REL_IA64_ADDEND           0x001F
 
+//
+// LOONGARCH64 relocation types
+//
+#define IMAGE_REL_LOONGARCH64_PC        0x0003
+#define IMAGE_REL_LOONGARCH64_JIR       0x0004
+
 //
 // CEF relocation types.
 //