From 10b57604ba020857cec02fa5f7f7f12a8b802735 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Tue, 28 Nov 2023 13:10:23 -0800 Subject: [PATCH 1/2] Address .NET 8 SDK Build issues (#1425) This PR addresses issues building MIEngine with .NET 8 SDK. See https://github.com/dotnet/sdk/issues/34438 --- src/SSHDebugPS/SSHDebugPS.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SSHDebugPS/SSHDebugPS.csproj b/src/SSHDebugPS/SSHDebugPS.csproj index bcbe89061..677a34d63 100644 --- a/src/SSHDebugPS/SSHDebugPS.csproj +++ b/src/SSHDebugPS/SSHDebugPS.csproj @@ -13,7 +13,7 @@ net472 true true - false + true From 9f35772d171e37a10322309bf0477512941531f5 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Tue, 28 Nov 2023 22:35:20 +0100 Subject: [PATCH 2/2] MIEngine: Array evaluation and address check (#1427) * 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 --- src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs | 10 +++++-- src/MIDebugEngine/AD7.Impl/AD7Property.cs | 30 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs diff --git a/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs b/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs old mode 100644 new mode 100755 index b699a49df..2594376b6 --- a/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs @@ -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) diff --git a/src/MIDebugEngine/AD7.Impl/AD7Property.cs b/src/MIDebugEngine/AD7.Impl/AD7Property.cs index 2601d2c48..54ee427bd 100644 --- a/src/MIDebugEngine/AD7.Impl/AD7Property.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7Property.cs @@ -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(' ');