Skip to content

Commit

Permalink
MIEngine: Address is not an AD7MemoryAddress obj
Browse files Browse the repository at this point in the history
Handle condition where the address is not an AD7MemoryAddress
object.
On running multiple debug engines, it appears this gets called with a
different object type.

Signed-off-by: intel-rganesh [email protected]
  • Loading branch information
intel-rganesh committed Apr 17, 2023
1 parent 17d1252 commit 4eb20fe
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ public int GetCodeContext(ulong uCodeLocationId, out IDebugCodeContext2 ppCodeCo
public int GetCodeLocationId(IDebugCodeContext2 pCodeContext, out ulong puCodeLocationId)
{
AD7MemoryAddress addr = pCodeContext as AD7MemoryAddress;
puCodeLocationId = addr.Address;
return Constants.S_OK;
if (addr != null)
{
puCodeLocationId = addr.Address;
return Constants.S_OK;
}

puCodeLocationId = 0;
return Constants.S_FALSE;
}

public int GetCurrentLocation(out ulong puCodeLocationId)
Expand Down

1 comment on commit 4eb20fe

@intel-rganesh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There can be scenarios where the addr is null. With the null check, we would avoid NullReferenceException.

image

Please sign in to comment.