@@ -39,7 +39,9 @@ public void SetDocumentContext(IDebugDocumentContext2 docContext)
3939 // Adds a specified value to the current context's address to create a new context.
4040 public int Add ( ulong dwCount , out IDebugMemoryContext2 newAddress )
4141 {
42- // FIXME: this is not correct for IDebugCodeContext2
42+ // NB: this is not correct for IDebugCodeContext2 according to the docs
43+ // https://docs.microsoft.com/en-us/visualstudio/extensibility/debugger/reference/idebugcodecontext2#remarks
44+ // But it's not used in practice (instead: IDebugDisassemblyStream2.Seek)
4345 newAddress = new AD7MemoryAddress ( _engine , ( uint ) dwCount + _address , null ) ;
4446 return Constants . S_OK ;
4547 }
@@ -158,12 +160,19 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
158160 {
159161 pinfo [ 0 ] . dwFields = 0 ;
160162
161- if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS ) != 0 ||
162- ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ) != 0 )
163+ if ( ( dwFields & ( enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS | enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ) ) != 0 )
163164 {
164- pinfo [ 0 ] . bstrAddress = EngineUtils . AsAddr ( _address , _engine . DebuggedProcess . Is64BitArch ) ;
165- pinfo [ 0 ] . bstrAddressAbsolute = pinfo [ 0 ] . bstrAddress ;
166- pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS | enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ;
165+ string addr = EngineUtils . AsAddr ( _address , _engine . DebuggedProcess . Is64BitArch ) ;
166+ if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS ) != 0 )
167+ {
168+ pinfo [ 0 ] . bstrAddress = addr ;
169+ pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_ADDRESS ;
170+ }
171+ if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ) != 0 )
172+ {
173+ pinfo [ 0 ] . bstrAddressAbsolute = addr ;
174+ pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSABSOLUTE ;
175+ }
167176 }
168177 // Fields not supported by the sample
169178 if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_ADDRESSOFFSET ) != 0 ) { }
0 commit comments