Skip to content

Commit

Permalink
Update DumpAsync to allow method table and object address to not have…
Browse files Browse the repository at this point in the history
… 0x prefix (dotnet#3876)

* Update DumpAsync to allow method table and object address to not have 0x prefix

* Specify null-return OK
  • Loading branch information
hoyosjs authored May 16, 2023
1 parent 3ae4837 commit e641da7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Microsoft.Diagnostics.ExtensionCommands/DumpAsyncCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@ public sealed class DumpAsyncCommand : ExtensionCommandBase
[ServiceImport(Optional = true)]
public ClrRuntime? Runtime { get; set; }


/// <summary>Gets whether to only show stacks that include the object with the specified address.</summary>
[Option(Name = "--address", Aliases = new string[] { "-addr" }, Help = "Only show stacks that include the object with the specified address.")]
public ulong? ObjectAddress { get; set; }
public string? ObjectAddress
{
get => _objectAddress?.ToString();
set => _objectAddress = ParseAddress(value);
}
private ulong? _objectAddress;

/// <summary>Gets whether to only show stacks that include objects with the specified method table.</summary>
[Option(Name = "--methodtable", Aliases = new string[] { "-mt" }, Help = "Only show stacks that include objects with the specified method table.")]
public ulong? MethodTableAddress { get; set; }
public string? MethodTableAddress
{
get => _methodTableAddress?.ToString();
set => _methodTableAddress = ParseAddress(value);
}
private ulong? _methodTableAddress;

/// <summary>Gets whether to only show stacks that include objects whose type includes the specified name in its name.</summary>
[Option(Name = "--type", Help = "Only show stacks that include objects whose type includes the specified name in its name.")]
Expand Down Expand Up @@ -532,14 +543,14 @@ string Describe(ClrObject obj)
// <summary>Determines whether the specified object is of interest to the user based on their criteria provided as command arguments.</summary>
bool IncludeInOutput(ClrObject obj)
{
if (ObjectAddress is ulong addr && obj.Address != addr)
if (_objectAddress is ulong addr && obj.Address != addr)
{
return false;
}

if (obj.Type is not null)
{
if (MethodTableAddress is ulong mt && obj.Type.MethodTable != mt)
if (_methodTableAddress is ulong mt && obj.Type.MethodTable != mt)
{
return false;
}
Expand Down

0 comments on commit e641da7

Please sign in to comment.