Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIEngine: Array evaluation and address check #1427

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading