Fix `pathto` SOS command. (#4706)
authorMikhail Kurinnoi <m.kurinnoi@samsung.com>
Mon, 3 Jun 2024 16:54:34 +0000 (19:54 +0300)
committerGitHub <noreply@github.com>
Mon, 3 Jun 2024 16:54:34 +0000 (09:54 -0700)
Fix `pathto` SOS command arguments parsing logic.

Current status:
```
> pathto 0x1234
ERROR: Could not parse argument 'source': 4660
> pathto 0x4444
ERROR: Could not parse argument 'source': 17476
```
With this changes:
```
> pathto 0x003f1d1182d8
ERROR: Could not parse argument 'target': 0
> pathto 0x003f1d1182d8 0x003f1d1182d8
ERROR: Object reference not set to an instance of an object.
> pathto 0x003f1d1182d8 0x003b7180bfc0
Could not find a path from 3f1d1182d8 to 3b7180bfc0
```

CC @clamp03 @wscho77 @HJLeee @gbalykov

src/Microsoft.Diagnostics.ExtensionCommands/PathToCommand.cs

index ac0975b85926879fc514d82d44239227b9394725..2e6ab6a8cf330476f580f4da016a00c5c6bfc632 100644 (file)
@@ -21,14 +21,14 @@ namespace Microsoft.Diagnostics.ExtensionCommands
 
         public override void Invoke()
         {
-            if (TryParseAddress(SourceAddress, out ulong source))
+            if (!TryParseAddress(SourceAddress, out ulong source))
             {
                 throw new ArgumentException($"Could not parse argument 'source': {source}");
             }
 
-            if (TryParseAddress(TargetAddress, out ulong target))
+            if (!TryParseAddress(TargetAddress, out ulong target))
             {
-                throw new ArgumentException($"Could not parse argument 'source': {target}");
+                throw new ArgumentException($"Could not parse argument 'target': {target}");
             }
 
             ClrHeap heap = Runtime.Heap;