Add `runtimes --all` option.
/// Returns the list of .NET runtimes in the target
/// </summary>
/// <param name="startingRuntimeId">The starting runtime id for this provider</param>
- public IEnumerable<IRuntime> EnumerateRuntimes(int startingRuntimeId)
+ /// <param name="flags">Enumeration control flags</param>
+ public IEnumerable<IRuntime> EnumerateRuntimes(int startingRuntimeId, RuntimeEnumerationFlags flags)
{
// The ClrInfo and DataTarget instances are disposed when Runtime instance is disposed. Runtime instances are
// not flushed when the Target/RuntimeService is flushed; they are all disposed and the list cleared. They are
// all re-created the next time the IRuntime or ClrRuntime instance is queried.
- DataTarget dataTarget = new(new CustomDataTarget(_services.GetService<IDataReader>()))
+ DataTarget dataTarget = new(new CustomDataTarget(_services.GetService<IDataReader>())
{
+ ForceCompleteRuntimeEnumeration = (flags & RuntimeEnumerationFlags.All) != 0,
FileLocator = null
- };
+ });
for (int i = 0; i < dataTarget.ClrVersions.Length; i++)
{
yield return new Runtime(_services, startingRuntimeId + i, dataTarget.ClrVersions[i]);
/// <summary>
/// Returns the list of runtimes in the target
/// </summary>
- public IEnumerable<IRuntime> EnumerateRuntimes()
+ /// <param name="flags">Enumeration control flags</param>
+ public IEnumerable<IRuntime> EnumerateRuntimes(RuntimeEnumerationFlags flags)
{
if (_runtimes is null)
{
foreach (ServiceFactory factory in _serviceManager.EnumerateProviderFactories(typeof(IRuntimeProvider)))
{
IRuntimeProvider provider = (IRuntimeProvider)factory(_services);
- _runtimes.AddRange(provider.EnumerateRuntimes(_runtimes.Count));
+ _runtimes.AddRange(provider.EnumerateRuntimes(_runtimes.Count, flags));
}
}
return _runtimes;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System;
using System.Collections.Generic;
namespace Microsoft.Diagnostics.DebugServices
/// Returns the list of runtimes in the target
/// </summary>
/// <param name="startingRuntimeId">The starting runtime id for this provider</param>
- IEnumerable<IRuntime> EnumerateRuntimes(int startingRuntimeId);
+ /// <param name="flags">Enumeration control flags</param>
+ IEnumerable<IRuntime> EnumerateRuntimes(int startingRuntimeId, RuntimeEnumerationFlags flags);
}
}
/// <summary>
/// Returns the list of runtimes in the target
/// </summary>
- IEnumerable<IRuntime> EnumerateRuntimes();
+ /// <param name="flags">Enumeration control flags</param>
+ IEnumerable<IRuntime> EnumerateRuntimes(RuntimeEnumerationFlags flags = RuntimeEnumerationFlags.Default);
}
}
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System;
+
+namespace Microsoft.Diagnostics.DebugServices
+{
+ /// <summary>
+ /// Enumeration control flags
+ /// </summary>
+ [Flags]
+ public enum RuntimeEnumerationFlags
+ {
+ /// <summary>
+ /// Providers can return only the runtimes they feel are important like ones involved in a crash.
+ /// </summary>
+ Default = 0x00,
+
+ /// <summary>
+ /// Force enumeration of all runtimes. If set, all the possible runtimes in the target process are enumerated.
+ /// </summary>
+ All = 0x01,
+ }
+}
[Option(Name = "--netcore", Aliases = new string[] { "-netcore", "-c" }, Help = "Switches to the .NET Core or .NET 5+ runtime if exists.")]
public bool NetCore { get; set; }
+ [Option(Name = "--all", Aliases = new string[] { "-a" }, Help = "Forces all runtimes to be enumerated.")]
+ public bool All { get; set; }
+
public override void Invoke()
{
if (NetFx && NetCore)
{
throw new DiagnosticsException("Cannot specify both -netfx and -netcore options");
}
+ RuntimeEnumerationFlags flags = RuntimeEnumerationFlags.Default;
+
+ if (All)
+ {
+ // Force all runtimes to be enumerated. This requires a target flush.
+ flags = RuntimeEnumerationFlags.All;
+ Target.Flush();
+ }
+
if (NetFx || NetCore)
{
string name = NetFx ? "desktop .NET Framework" : ".NET Core";
- foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes())
+ foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes(flags))
{
if (NetFx && runtime.RuntimeType == RuntimeType.Desktop ||
NetCore && runtime.RuntimeType == RuntimeType.NetCore)
else
{
// Display the current runtime star ("*") only if there is more than one runtime and it is the current one
- bool displayStar = RuntimeService.EnumerateRuntimes().Count() > 1;
+ bool displayStar = RuntimeService.EnumerateRuntimes(flags).Count() > 1;
IRuntime currentRuntime = ContextService.GetCurrentRuntime();
- foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes())
+ foreach (IRuntime runtime in RuntimeService.EnumerateRuntimes(flags))
{
string current = displayStar ? (runtime == currentRuntime ? "*" : " ") : "";
Write(current);
<None Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\PDB\sos.pdb" Pack="true" Visible="false">
<PackagePath>$(SOSPackagePathPrefix)/win-x64</PackagePath>
</None>
+ </ItemGroup>
+
+ <ItemGroup Condition="'$(BuildX64Package)' != 'true'">
<None Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\PDB\sos.pdb" Pack="true" Visible="false">
<PackagePath>$(SOSPackagePathPrefix)/win-x86</PackagePath>
</None>
<ItemGroup>
<SosRequiredBinaries Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\sos.dll" TargetRid="win-x64" />
<SosRequiredBinaries Include="$(ArtifactsBinDir)\Windows_NT.x64.$(Configuration)\Microsoft.DiaSymReader.Native.amd64.dll" TargetRid="win-x64" />
+ </ItemGroup>
+ <ItemGroup Condition="'$(BuildX64Package)' != 'true'">
<SosRequiredBinaries Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\sos.dll" TargetRid="win-x86" />
<SosRequiredBinaries Include="$(ArtifactsBinDir)\Windows_NT.x86.$(Configuration)\Microsoft.DiaSymReader.Native.x86.dll" TargetRid="win-x86" />