OLD | NEW |
| (Empty) |
1 // Copyright 2009 The Native Client Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can | |
3 // be found in the LICENSE file. | |
4 using System.Diagnostics; | |
5 using Microsoft.VisualStudio; | |
6 using Microsoft.VisualStudio.Debugger.Interop; | |
7 | |
8 namespace Google.MsAd7.BaseImpl { | |
9 public class MemoryContext : IDebugMemoryContext2 { | |
10 public MemoryContext(string name, ulong address, ulong count) { | |
11 name_ = name; | |
12 address_ = address; | |
13 count_ = count; | |
14 } | |
15 | |
16 public MemoryContext(string name, ulong address) | |
17 : this(name, address, 0) {} | |
18 | |
19 public ulong Address { | |
20 get { return address_; } | |
21 } | |
22 | |
23 public ulong Count { | |
24 get { return count_; } | |
25 } | |
26 | |
27 public string Name { | |
28 get { return name_; } | |
29 } | |
30 | |
31 #region Implementation of IDebugMemoryContext2 | |
32 | |
33 public int GetName(out string pbstrName) { | |
34 Debug.WriteLine("MemoryContext.GetName"); | |
35 pbstrName = name_; | |
36 return VSConstants.S_OK; | |
37 } | |
38 | |
39 public int GetInfo(enum_CONTEXT_INFO_FIELDS dwFields, CONTEXT_INFO[] pinfo)
{ | |
40 Debug.WriteLine("MemoryContext.GetInfo"); | |
41 | |
42 pinfo[0].bstrAddress = Address.ToString("X"); | |
43 pinfo[0].bstrAddressAbsolute = pinfo[0].bstrAddress; | |
44 pinfo[0].bstrAddressOffset = pinfo[0].bstrAddress; | |
45 pinfo[0].bstrFunction = ""; | |
46 pinfo[0].bstrModuleUrl = ""; | |
47 pinfo[0].dwFields = enum_CONTEXT_INFO_FIELDS.CIF_ALLFIELDS; | |
48 | |
49 return VSConstants.S_OK; | |
50 } | |
51 | |
52 public int Add(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) { | |
53 Debug.WriteLine("MemoryContext.Add"); | |
54 ppMemCxt = new MemoryContext(name_, address_ + dwCount, count_); | |
55 return VSConstants.S_OK; | |
56 } | |
57 | |
58 public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) { | |
59 Debug.WriteLine("MemoryContext.Subtract"); | |
60 ppMemCxt = new MemoryContext(name_, address_ - dwCount, count_); | |
61 return VSConstants.S_OK; | |
62 } | |
63 | |
64 public int Compare(enum_CONTEXT_COMPARE Compare, | |
65 IDebugMemoryContext2[] rgpMemoryContextSet, | |
66 uint dwMemoryContextSetLen, | |
67 out uint pdwMemoryContext) { | |
68 Debug.WriteLine("MemoryContext.Compare"); | |
69 | |
70 // TODO(ilewis): | |
71 // must implement at least CONTEXT_EQUAL, CONTEXT_LESS_THAN, | |
72 // CONTEXT_GREATER_THAN and CONTEXT_SAME_SCOPE. (MSDN) | |
73 pdwMemoryContext = uint.MaxValue; | |
74 return VSConstants.S_OK; | |
75 } | |
76 | |
77 #endregion | |
78 | |
79 #region Private Implementation | |
80 | |
81 private readonly ulong address_; | |
82 private readonly ulong count_; | |
83 private readonly string name_; | |
84 | |
85 #endregion | |
86 } | |
87 } | |
OLD | NEW |