From 4eb20fe15ceab798a9a47d1d985fc5cd957658a2 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Mon, 17 Apr 2023 16:57:51 +0200 Subject: [PATCH 1/3] 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 --- src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 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..bb34678dd --- 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.S_FALSE; } public int GetCurrentLocation(out ulong puCodeLocationId) From 03a22896a64155c1b8003d6e78cf23e85db30063 Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Mon, 17 Apr 2023 17:03:54 +0200 Subject: [PATCH 2/3] MIEngine: Allow direct array evaluation Allow direct array eval in memory window. Signed-off-by: intel-rganesh rakesh.ganesh@intel.com --- src/MIDebugEngine/AD7.Impl/AD7Property.cs | 31 +++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/MIDebugEngine/AD7.Impl/AD7Property.cs b/src/MIDebugEngine/AD7.Impl/AD7Property.cs index 2601d2c48..f8ba8b125 100644 --- a/src/MIDebugEngine/AD7.Impl/AD7Property.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7Property.cs @@ -229,11 +229,38 @@ 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; + } + AD7Property propArray = new AD7Property(_engine, viArray); + v = propArray._variableInformation.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(' '); From 83cc74f389e49d7e83921fd0f2c11879e410926f Mon Sep 17 00:00:00 2001 From: Rakesh Ganesh Date: Tue, 28 Nov 2023 10:54:43 +0000 Subject: [PATCH 3/3] 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 --- src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs | 2 +- src/MIDebugEngine/AD7.Impl/AD7Property.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs b/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs index bb34678dd..2594376b6 100755 --- a/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7Disassembly.cs @@ -41,7 +41,7 @@ public int GetCodeLocationId(IDebugCodeContext2 pCodeContext, out ulong puCodeLo } puCodeLocationId = 0; - return Constants.S_FALSE; + 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 f8ba8b125..54ee427bd 100644 --- a/src/MIDebugEngine/AD7.Impl/AD7Property.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7Property.cs @@ -242,8 +242,7 @@ public int GetMemoryContext(out IDebugMemoryContext2 ppMemory) { return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT; } - AD7Property propArray = new AD7Property(_engine, viArray); - v = propArray._variableInformation.Value; + v = viArray.Value; v.Trim(); if (v.Length == 0) {