22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
44using System ;
5- using System . Collections . Generic ;
6- using System . Text ;
75using Microsoft . VisualStudio . Debugger . Interop ;
86using MICore ;
9- using Microsoft . MIDebugEngine . Natvis ;
107
118namespace Microsoft . MIDebugEngine
129{
1310 // And implementation of IDebugCodeContext2 and IDebugMemoryContext2.
1411 // IDebugMemoryContext2 represents a position in the address space of the machine running the program being debugged.
1512 // IDebugCodeContext2 represents the starting position of a code instruction.
1613 // For most run-time architectures today, a code context can be thought of as an address in a program's execution stream.
17- internal class AD7MemoryAddress : IDebugCodeContext2
14+ internal sealed class AD7MemoryAddress : IDebugCodeContext2
1815 {
1916 private readonly AD7Engine _engine ;
2017 private readonly ulong _address ;
@@ -42,6 +39,7 @@ public void SetDocumentContext(IDebugDocumentContext2 docContext)
4239 // Adds a specified value to the current context's address to create a new context.
4340 public int Add ( ulong dwCount , out IDebugMemoryContext2 newAddress )
4441 {
42+ // FIXME: this is not correct for IDebugCodeContext2
4543 newAddress = new AD7MemoryAddress ( _engine , ( uint ) dwCount + _address , null ) ;
4644 return Constants . S_OK ;
4745 }
@@ -160,19 +158,15 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
160158 {
161159 pinfo [ 0 ] . dwFields = 0 ;
162160
163- if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS ) != 0 )
161+ if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS ) != 0 ||
162+ ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ) != 0 )
164163 {
165164 pinfo [ 0 ] . bstrAddress = EngineUtils . AsAddr ( _address , _engine . DebuggedProcess . Is64BitArch ) ;
166- pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS ;
165+ pinfo [ 0 ] . bstrAddressAbsolute = pinfo [ 0 ] . bstrAddress ;
166+ pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS | enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ;
167167 }
168-
169168 // Fields not supported by the sample
170169 if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSOFFSET ) != 0 ) { }
171- if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ) != 0 )
172- {
173- pinfo [ 0 ] . bstrAddressAbsolute = EngineUtils . AsAddr ( _address , _engine . DebuggedProcess . Is64BitArch ) ;
174- pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ;
175- }
176170 if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_MODULEURL ) != 0 )
177171 {
178172 DebuggedModule module = _engine . DebuggedProcess . ResolveAddress ( _address ) ;
@@ -195,7 +189,10 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
195189 pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_FUNCTION ;
196190 }
197191 }
198- if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_FUNCTIONOFFSET ) != 0 ) { }
192+ if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_FUNCTIONOFFSET ) != 0 )
193+ {
194+ // TODO:
195+ }
199196
200197 return Constants . S_OK ;
201198 }
@@ -210,10 +207,10 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
210207 }
211208
212209 // Gets the user-displayable name for this context
213- // This is not supported by the sample engine.
214210 public int GetName ( out string pbstrName )
215211 {
216- throw new NotImplementedException ( ) ;
212+ pbstrName = _functionName ?? Engine . GetAddressDescription ( _address ) ;
213+ return Constants . S_OK ;
217214 }
218215
219216 // Subtracts a specified value from the current context's address to create a new context.
0 commit comments