Skip to content

Commit

Permalink
Misc SOS fixes (#5040)
Browse files Browse the repository at this point in the history
Fix null refs when no dump or live session (ITarget == null)

Add .NET 10.0 runtime hosting for managed SOS code

Fix release prep stage from PR #5036
  • Loading branch information
mikem8361 authored Nov 21, 2024
1 parent 130c708 commit 278b652
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions eng/pipelines/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ stages:
displayName: 'Build Manifest generation and asset publishing tool'
- ${{ elseif and(ne(variables['System.TeamProject'], 'public'), startsWith(variables['Build.SourceBranch'], 'refs/heads/release/')) }}:
- task: UseDotNet@2
displayName: 'Use .NET Core runtime 6.x'
displayName: 'Use .NET Core runtime 8.x'
inputs:
packageType: runtime
version: 6.x
version: 8.x
installationPath: '$(Build.Repository.LocalPath)\.dotnet'
- template: /eng/common/templates/post-build/setup-maestro-vars.yml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Runtime : IRuntime, IDisposable

public Runtime(IServiceProvider services, int id, ClrInfo clrInfo)
{
Target = services.GetService<ITarget>() ?? throw new NullReferenceException($"Uninitialized service: {nameof(Target)}");
Target = services.GetService<ITarget>() ?? throw new DiagnosticsException("Dump or live session target required");
Id = id;
_clrInfo = clrInfo ?? throw new ArgumentNullException(nameof(clrInfo));
_symbolService = services.GetService<ISymbolService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal struct EXCEPTION_RECORD64

public SpecialDiagInfo(ITarget target, IMemoryService memoryService)
{
_target = target;
_target = target ?? throw new DiagnosticsException("Dump or live session target required");
_memoryService = memoryService;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ public static class CommandFormatHelpers
/// </summary>
public static void DisplaySpecialInfo(this CommandBase command, string indent = "")
{
if (command.Services.GetService<ITarget>().OperatingSystem != OSPlatform.Windows)
ITarget target = command.Services.GetService<ITarget>() ?? throw new DiagnosticsException("Dump or live session target required");
if (target.OperatingSystem != OSPlatform.Windows)
{
ulong address = SpecialDiagInfoHeader.GetAddress(command.Services);
command.Console.Write($"{indent}SpecialDiagInfoHeader : {address:X16}");
Expand Down Expand Up @@ -57,7 +58,7 @@ public static void DisplayResources(this CommandBase command, IModule module, bo
if (module.IsPEImage)
{
command.Console.WriteLine($"{indent}Resources:");
IDataReader reader = command.Services.GetService<IDataReader>() ?? throw new DiagnosticsException("IDataReader service needed");
IDataReader reader = command.Services.GetService<IDataReader>() ?? throw new DiagnosticsException("IDataReader service required");
IResourceNode resourceRoot = ModuleInfo.TryCreateResourceRoot(reader, module.ImageBase, module.ImageSize, module.IsFileLayout.GetValueOrDefault(false));
if (resourceRoot != null)
{
Expand Down Expand Up @@ -160,7 +161,8 @@ IConsoleService Console()
}

// Print the Windows runtime engine metrics (.NET Core and .NET Framework)
if (command.Services.GetService<ITarget>().OperatingSystem == OSPlatform.Windows)
ITarget target = command.Services.GetService<ITarget>() ?? throw new DiagnosticsException("Dump or live session target required");
if (target.OperatingSystem == OSPlatform.Windows)
{
if (symbols != null && symbols.TryGetSymbolAddress(ClrEngineMetrics.Symbol, out ulong metricsAddress))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static bool TryRead(IServiceProvider services, ulong address, out Special

public static ulong GetAddress(IServiceProvider services)
{
ITarget target = services.GetService<ITarget>();
ITarget target = services.GetService<ITarget>() ?? throw new DiagnosticsException("Dump or live session target required");
IMemoryService memoryService = services.GetService<IMemoryService>();
return target.OperatingSystem == OSPlatform.OSX ? SpecialDiagInfoAddress_OSX : (memoryService.PointerSize == 4 ? SpecialDiagInfoAddress_32BIT : SpecialDiagInfoAddress_64BIT);
}
Expand Down
2 changes: 2 additions & 0 deletions src/SOS/extensions/hostcoreclr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ namespace RuntimeHostingConstants
{9, 0},
{8, 0},
{6, 0},
{10, 0},
};

constexpr char DotnetRootEnvVar[] = "DOTNET_ROOT";
Expand Down Expand Up @@ -128,6 +129,7 @@ namespace RuntimeHostingConstants
"/rh-dotnet90/root/usr/bin/dotnet",
"/rh-dotnet80/root/usr/bin/dotnet",
"/rh-dotnet60/root/usr/bin/dotnet",
"/rh-dotnet100/root/usr/bin/dotnet",
"/usr/share/dotnet",
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class RunTestsCommand : CommandBase, ITestOutputHelper

public override void Invoke()
{
ITarget target = Services.GetService<ITarget>();
ITarget target = Services.GetService<ITarget>() ?? throw new DiagnosticsException("Dump or live session target required");
string os;
if (target.OperatingSystem == OSPlatform.Linux)
{
Expand Down

0 comments on commit 278b652

Please sign in to comment.