diff --git a/src/MIDebugEngine/AD7.Impl/AD7MemoryAddress.cs b/src/MIDebugEngine/AD7.Impl/AD7MemoryAddress.cs index 0be7d6e79..09bc6a277 100644 --- a/src/MIDebugEngine/AD7.Impl/AD7MemoryAddress.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7MemoryAddress.cs @@ -39,7 +39,9 @@ public void SetDocumentContext(IDebugDocumentContext2 docContext) // Adds a specified value to the current context's address to create a new context. public int Add(ulong dwCount, out IDebugMemoryContext2 newAddress) { - // FIXME: this is not correct for IDebugCodeContext2 + // NB: this is not correct for IDebugCodeContext2 according to the docs + // https://docs.microsoft.com/en-us/visualstudio/extensibility/debugger/reference/idebugcodecontext2#remarks + // But it's not used in practice (instead: IDebugDisassemblyStream2.Seek) newAddress = new AD7MemoryAddress(_engine, (uint)dwCount + _address, null); return Constants.S_OK; } @@ -158,12 +160,19 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo) { pinfo[0].dwFields = 0; - if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS) != 0 || - (dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE) != 0) + if ((dwFields & (enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS | enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE)) != 0) { - pinfo[0].bstrAddress = EngineUtils.AsAddr(_address, _engine.DebuggedProcess.Is64BitArch); - pinfo[0].bstrAddressAbsolute = pinfo[0].bstrAddress; - pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS | enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE; + string addr = EngineUtils.AsAddr(_address, _engine.DebuggedProcess.Is64BitArch); + if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS) != 0) + { + pinfo[0].bstrAddress = addr; + pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS; + } + if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE) != 0) + { + pinfo[0].bstrAddressAbsolute = addr; + pinfo[0].dwFields |= enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE; + } } // Fields not supported by the sample if ((dwFields & enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSOFFSET) != 0) { } diff --git a/src/OpenDebugAD7/AD7Impl/AD7BreakPointRequest.cs b/src/OpenDebugAD7/AD7Impl/AD7BreakPointRequest.cs index 1528236a1..96d36f1d7 100644 --- a/src/OpenDebugAD7/AD7Impl/AD7BreakPointRequest.cs +++ b/src/OpenDebugAD7/AD7Impl/AD7BreakPointRequest.cs @@ -8,7 +8,7 @@ namespace OpenDebugAD7.AD7Impl { - internal class AD7BreakPointRequest : IDebugBreakpointRequest2, IDebugBreakpointChecksumRequest2 + internal sealed class AD7BreakPointRequest : IDebugBreakpointRequest2, IDebugBreakpointChecksumRequest2 { private static uint s_nextBreakpointId = 0; diff --git a/src/OpenDebugAD7/AD7Impl/AD7DocumentPosition.cs b/src/OpenDebugAD7/AD7Impl/AD7DocumentPosition.cs index 2e900a3dc..08da1242a 100644 --- a/src/OpenDebugAD7/AD7Impl/AD7DocumentPosition.cs +++ b/src/OpenDebugAD7/AD7Impl/AD7DocumentPosition.cs @@ -2,13 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Globalization; -using Microsoft.DebugEngineHost; using Microsoft.VisualStudio.Debugger.Interop; namespace OpenDebugAD7.AD7Impl { - internal class AD7DocumentPosition : IDebugDocumentPosition2, IDebugDocumentPosition110 + internal sealed class AD7DocumentPosition : IDebugDocumentPosition2, IDebugDocumentPosition110 { public string Path {