Skip to content

Instantly share code, notes, and snippets.

public class TaskStateCommand : ExtensionCommandBase
{
[Argument(Help = "The Task instance address.")]
public string Address { get; set; }
public override void Invoke()
{
if (string.IsNullOrEmpty(Address) && !Value.HasValue)
{
WriteLine("Missing Task reference address or state value..." + Environment.NewLine);
return;
protected bool TryParseAddress(string addressInHexa, out ulong address)
{
// skip 0x or leading 0000 if needed
if (addressInHexa.StartsWith("0x"))
addressInHexa = addressInHexa.Substring(2);
addressInHexa = addressInHexa.TrimStart('0');
return ulong.TryParse(addressInHexa, System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out address);
}
public class TaskStateCommand : ExtensionCommandBase
{
[Option(Name = "--value", Help = "<value> is the value of a Task m_stateFlags field.")]
[OptionAlias(Name = "-v")]
public ulong? Value { get; set; }
// access the Task state field if the flag is not given as a parameter
if (!Value.HasValue)
{
public class ParallelStacksCommand : ExtensionCommandBase
{
[Option(Name = "--allThreads", Help = "Displays all threads per group instead of at most 4 by default.")]
[OptionAlias(Name = "-a")]
public bool AllThreads { get; set; }
foreach (var timer in Helper.EnumerateTimers().OrderBy(t => t.Period))
{ ... }
public class ClrMDHelper
{
private readonly ClrRuntime _clr;
private readonly ClrHeap _heap;
public ClrMDHelper(ServiceProvider provider)
{
_clr = provider.GetService<ClrRuntime>();
_heap = _clr.Heap;
}
_serviceProvider.AddServiceFactory(typeof(ClrRuntime), () => CreateRuntime(target));
// ClrMD helper for extended commands
_serviceProvider.AddServiceFactory(typeof(ClrMDHelper), () =>
new ClrMDHelper(_serviceProvider)
);
[Command(Name = "parallelstacks", Help = "Display merged threads stack a la Visual Studio 'Parallel Stacks' panel.")]
[CommandAlias(Name = "pstacks")]
public class ParallelStacksCommand : ExtensionCommandBase
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
git add/gui
git commit
git remote add upstream https://github.com/criteo-forks/diagnostics
git push upstream PR_dotnet-dump_pstacks