2
2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
3
4
4
using System ;
5
- using System . Collections . Generic ;
6
- using System . Text ;
7
5
using Microsoft . VisualStudio . Debugger . Interop ;
8
6
using MICore ;
9
- using Microsoft . MIDebugEngine . Natvis ;
10
7
11
8
namespace Microsoft . MIDebugEngine
12
9
{
13
10
// And implementation of IDebugCodeContext2 and IDebugMemoryContext2.
14
11
// IDebugMemoryContext2 represents a position in the address space of the machine running the program being debugged.
15
12
// IDebugCodeContext2 represents the starting position of a code instruction.
16
13
// 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
18
15
{
19
16
private readonly AD7Engine _engine ;
20
17
private readonly ulong _address ;
@@ -42,6 +39,7 @@ public void SetDocumentContext(IDebugDocumentContext2 docContext)
42
39
// Adds a specified value to the current context's address to create a new context.
43
40
public int Add ( ulong dwCount , out IDebugMemoryContext2 newAddress )
44
41
{
42
+ // FIXME: this is not correct for IDebugCodeContext2
45
43
newAddress = new AD7MemoryAddress ( _engine , ( uint ) dwCount + _address , null ) ;
46
44
return Constants . S_OK ;
47
45
}
@@ -160,19 +158,15 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
160
158
{
161
159
pinfo [ 0 ] . dwFields = 0 ;
162
160
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 )
164
163
{
165
164
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 ;
167
167
}
168
-
169
168
// Fields not supported by the sample
170
169
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
- }
176
170
if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_MODULEURL ) != 0 )
177
171
{
178
172
DebuggedModule module = _engine . DebuggedProcess . ResolveAddress ( _address ) ;
@@ -195,7 +189,10 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
195
189
pinfo [ 0 ] . dwFields |= enum_CONTEXT_INFO_FIELDS . CIF_FUNCTION ;
196
190
}
197
191
}
198
- if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_FUNCTIONOFFSET ) != 0 ) { }
192
+ if ( ( dwFields & enum_CONTEXT_INFO_FIELDS . CIF_FUNCTIONOFFSET ) != 0 )
193
+ {
194
+ // TODO:
195
+ }
199
196
200
197
return Constants . S_OK ;
201
198
}
@@ -210,10 +207,10 @@ public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
210
207
}
211
208
212
209
// Gets the user-displayable name for this context
213
- // This is not supported by the sample engine.
214
210
public int GetName ( out string pbstrName )
215
211
{
216
- throw new NotImplementedException ( ) ;
212
+ pbstrName = _functionName ?? Engine . GetAddressDescription ( _address ) ;
213
+ return Constants . S_OK ;
217
214
}
218
215
219
216
// Subtracts a specified value from the current context's address to create a new context.
0 commit comments