Skip to content

Commit

Permalink
MIEngine: Array evaluation and address check (#1427)
Browse files Browse the repository at this point in the history
* MIEngine: Address is not an AD7MemoryAddress obj

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 rakesh.ganesh@intel.com

* MIEngine: Allow direct array evaluation

Allow direct array eval in memory window.

Signed-off-by: intel-rganesh rakesh.ganesh@intel.com

* MIEngine: Address review comments

Address review comments for array evaluation and address check:
1> Use the correct constant in AD7Disassembly when pCodeContext is not
AD7MemoryAddress.
2> Avoid creating new AD7Property to fetch variable information value.

Signed-off-by: intel-rganesh rakesh.ganesh@intel.com

---------

Signed-off-by: intel-rganesh rakesh.ganesh@intel.com
Co-authored-by: Andrew Wang <waan@microsoft.com>
  • Loading branch information
intel-rganesh and WardenGnaw authored Nov 28, 2023
1 parent 10b5760 commit 9f35772
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 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.E_FAIL;
}

public int GetCurrentLocation(out ulong puCodeLocationId)
Expand Down
30 changes: 28 additions & 2 deletions src/MIDebugEngine/AD7.Impl/AD7Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,37 @@ public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
v = v.Trim();

if ((v[0] == '[') && (v[v.Length-1] == ']'))
{
// this is an array evaluation result from GDB, which does not contain an address
// VS on the other hand supports direct array evaluations without address operator
// therefore we need to re-evaluate with an address operator
//
VariableInformation viArray = new VariableInformation("&(" + _variableInformation.FullName() + ")", (VariableInformation)_variableInformation);
viArray.SyncEval();
if (viArray.Error)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
v = viArray.Value;
v.Trim();
if (v.Length == 0)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
}

if (v[0] == '{')
{
var index = v.IndexOf('}');
if (index == -1)
{
// syntax error!
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
// strip type name and trailing spaces
v = v.Substring(v.IndexOf('}') + 1);
v = v.Substring(index+1);
v = v.Trim();
}
int i = v.IndexOf(' ');
Expand Down

0 comments on commit 9f35772

Please sign in to comment.