本文整理汇总了C#中IDebugMemoryContext2类的典型用法代码示例。如果您正苦于以下问题:C# IDebugMemoryContext2类的具体用法?C# IDebugMemoryContext2怎么用?C# IDebugMemoryContext2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDebugMemoryContext2类属于命名空间,在下文中一共展示了IDebugMemoryContext2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadAt
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public int ReadAt (IDebugMemoryContext2 pStartContext, uint dwCount, byte [] rgbMemory, out uint pdwRead, ref uint pdwUnreadable)
{
//
// Reads a sequence of bytes, starting at a given location.
//
LoggingUtils.PrintFunction ();
try
{
CONTEXT_INFO [] contextInfoArray = new CONTEXT_INFO [1];
LoggingUtils.RequireOk (pStartContext.GetInfo (enum_CONTEXT_INFO_FIELDS.CIF_ADDRESSABSOLUTE, contextInfoArray));
string command = string.Format ("-data-read-memory-bytes {0} {1}", contextInfoArray [0].bstrAddressAbsolute, dwCount);
MiResultRecord resultRecord = m_debugger.GdbClient.SendSyncCommand (command);
MiResultRecord.RequireOk (resultRecord, command);
MiResultValueList memoryStreamList = (MiResultValueList) resultRecord ["memory"] [0];
for (int s = 0; s < memoryStreamList.Values.Count; ++s)
{
if (!memoryStreamList [s].HasField ("contents"))
{
throw new InvalidOperationException ("-data-read-memory-bytes result missing 'contents' field");
}
string hexValue = memoryStreamList [s] ["contents"] [0].GetString ();
if ((hexValue.Length / 2) != dwCount)
{
throw new InvalidOperationException ();
}
for (int i = 0; i < dwCount; ++i)
{
rgbMemory [i] = byte.Parse (hexValue.Substring (i * 2, 2), NumberStyles.HexNumber);
}
}
pdwRead = dwCount;
pdwUnreadable = 0;
return Constants.S_OK;
}
catch (Exception e)
{
LoggingUtils.HandleException (e);
pdwRead = 0;
pdwUnreadable = dwCount;
return Constants.E_FAIL;
}
}
示例2: Compare
/// <summary>
/// Compares the memory context to each context in the given array in the manner indicated by compare flags, returning an index of the first context that matches.
/// </summary>
/// <param name="Compare">A value from the CONTEXT_COMPARE enumeration that determines the type of comparison.</param>
/// <param name="rgpMemoryContextSet">An array of references to the IDebugMemoryContext2 objects to compare against.</param>
/// <param name="dwMemoryContextSetLen">The number of contexts in the rgpMemoryContextSet array.</param>
/// <param name="pdwMemoryContext">Returns the index of the first memory context that satisfies the comparison.</param>
/// <returns>If successful, returns S_OK; otherwise, returns an error code. Returns E_COMPARE_CANNOT_COMPARE if the two contexts cannot be compared.</returns>
/// <remarks>A debug engine (DE) does not have to support all types of comparisons, but it must support at least CONTEXT_EQUAL, CONTEXT_LESS_THAN, CONTEXT_GREATER_THAN and CONTEXT_SAME_SCOPE.</remarks>
public virtual int Compare( enum_CONTEXT_COMPARE Compare,
IDebugMemoryContext2[] rgpMemoryContextSet,
uint dwMemoryContextSetLen,
out uint pdwMemoryContext)
{
Logger.Debug( string.Empty );
pdwMemoryContext = 0;
return VSConstants.E_NOTIMPL;
}
示例3: Compare
public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
{
for(int i = 0; i < dwMemoryContextSetLen; ++i)
{
pdwMemoryContext = (uint)i;
var other = rgpMemoryContextSet[i] as DebugCodeContext;
if (other == null)
return HResults.E_COMPARE_CANNOT_COMPARE;
var isSameMethod = Equals(Location.Class, other.Location.Class) && Equals(Location.Method, other.Location.Method);
switch (Compare)
{
case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
if (location.Equals(other.Location))
return VSConstants.S_OK;
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
if(Location.CompareTo(other.Location) > 0)
return VSConstants.S_OK;
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
if (Location.CompareTo(other.Location) >= 0)
return VSConstants.S_OK;
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
if (Location.CompareTo(other.Location) < 0)
return VSConstants.S_OK;
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
if (!isSameMethod) return HResults.E_COMPARE_CANNOT_COMPARE;
if (Location.CompareTo(other.Location) <= 0)
return VSConstants.S_OK;
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
return VSConstants.S_OK;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
if(isSameMethod)
return VSConstants.S_OK;
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
// TODO: analyze scopes.
if(isSameMethod)
return VSConstants.S_OK;
break;
}
}
pdwMemoryContext = (uint)0;
return VSConstants.S_FALSE;
}
示例4: switch
int IDebugMemoryContext2.Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext) {
pdwMemoryContext = 0;
for (int i = 0; i < rgpMemoryContextSet.Length; ++i) {
var other = rgpMemoryContextSet[i] as AD7MemoryAddress;
if (other == null || other.Engine != Engine) {
continue;
}
bool match = false;
switch (Compare) {
case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
match = (LineNumber == other.LineNumber);
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
match = (LineNumber < other.LineNumber);
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
match = (LineNumber <= other.LineNumber);
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
match = (LineNumber > other.LineNumber);
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
match = (LineNumber >= other.LineNumber);
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
match = true;
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
match = (FileName == other.FileName);
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
match = (LineNumber == other.LineNumber && FileName == other.FileName);
break;
default:
return VSConstants.E_NOTIMPL;
}
if (match) {
pdwMemoryContext = (uint)i;
return VSConstants.S_OK;
}
}
return VSConstants.S_FALSE;
}
示例5: Compare
public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet,
uint dwMemoryContextSetLen, out uint pdwMemoryContext)
{
throw new NotImplementedException();
}
示例6: GetMemoryContext
// Returns the memory context for a property value.
public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
{
ppMemory = null;
if (_variableInformation.Error)
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
// try to interpret the result as an address
string v = _variableInformation.Value;
v = v.Trim();
if (v.Length == 0)
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
if (v[0] == '{')
{
// strip type name and trailing spaces
v = v.Substring(v.IndexOf('}') + 1);
v = v.Trim();
}
int i = v.IndexOf(' ');
if (i > 0)
{
v = v.Substring(0, i);
}
uint addr;
if (!UInt32.TryParse(v, System.Globalization.NumberStyles.Any, null, out addr))
{
if (v.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
{
v = v.Substring(2);
if (!UInt32.TryParse(v, System.Globalization.NumberStyles.AllowHexSpecifier, null, out addr))
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
}
else
{
return AD7_HRESULT.S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT;
}
}
ppMemory = new AD7MemoryAddress(DebuggedProcess.g_Process.Engine, addr, null);
return Constants.S_OK;
}
示例7: Subtract
public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
{
throw new NotImplementedException();
}
示例8:
int IDebugProperty2.GetMemoryContext(out IDebugMemoryContext2 ppMemory) {
ppMemory = null;
return VSConstants.E_NOTIMPL;
}
示例9: Compare
// Compares the memory context to each context in the given array in the manner indicated by compare flags,
// returning an index of the first context that matches.
public int Compare(enum_CONTEXT_COMPARE contextCompare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex)
{
foundIndex = uint.MaxValue;
try
{
for (uint c = 0; c < compareToLength; c++)
{
AD7MemoryAddress compareTo = compareToItems[c] as AD7MemoryAddress;
if (compareTo == null)
{
continue;
}
if (!AD7Engine.ReferenceEquals(_engine, compareTo._engine))
{
continue;
}
bool result;
switch (contextCompare)
{
case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
result = (_address == compareTo._address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
result = (_address < compareTo._address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
result = (_address > compareTo._address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
result = (_address <= compareTo._address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
result = (_address >= compareTo._address);
break;
// The debug engine doesn't understand scopes
case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
result = (_address == compareTo._address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
if (_address == compareTo._address)
{
result = true;
break;
}
string funcThis = Engine.GetAddressDescription(_address);
if (string.IsNullOrEmpty(funcThis))
{
result = false;
break;
}
string funcCompareTo = Engine.GetAddressDescription(compareTo._address);
result = (funcThis == funcCompareTo);
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
result = (_address == compareTo._address);
if (result == false)
{
DebuggedModule module = _engine.DebuggedProcess.ResolveAddress(_address);
if (module != null)
{
result = module.AddressInModule(compareTo._address);
}
}
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
result = true;
break;
default:
// A new comparison was invented that we don't support
return Constants.E_NOTIMPL;
}
if (result)
{
foundIndex = c;
return Constants.S_OK;
}
}
return Constants.S_FALSE;
}
catch (MIException e)
{
return e.HResult;
//.........这里部分代码省略.........
示例10: GetMemoryContext
/// <summary>
/// Returns the memory context for a property value. (http://msdn.microsoft.com/en-ca/library/bb147028.aspx)
/// Not implemented.
/// </summary>
/// <param name="ppMemory"> Returns the IDebugMemoryContext2 object that represents the memory associated with this property. </param>
/// <returns> Not implemented. </returns>
public int GetMemoryContext(out IDebugMemoryContext2 ppMemory)
{
throw new Exception("The method or operation is not implemented.");
}
示例11: Compare
public int Compare(enum_CONTEXT_COMPARE Compare, IDebugMemoryContext2[] rgpMemoryContextSet, uint dwMemoryContextSetLen, out uint pdwMemoryContext)
{
pdwMemoryContext = 0;
return VSConstants.E_FAIL;
}
示例12: Subtract
// Subtracts a specified value from the current context's address to create a new context.
public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
{
ppMemCxt = new AD7MemoryAddress(_engine, _address - (uint)dwCount, null);
return Constants.S_OK;
}
示例13:
int IDebugCodeContext2.Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt) {
return IDebugMemoryContext2.Subtract(dwCount, out ppMemCxt);
}
示例14: Compare
// Compares the memory context to each context in the given array in the manner indicated by compare flags,
// returning an index of the first context that matches.
public int Compare(enum_CONTEXT_COMPARE uContextCompare, IDebugMemoryContext2[] compareToItems, uint compareToLength, out uint foundIndex)
{
foundIndex = uint.MaxValue;
try
{
enum_CONTEXT_COMPARE contextCompare = (enum_CONTEXT_COMPARE)uContextCompare;
for (uint c = 0; c < compareToLength; c++)
{
AD7MemoryAddress compareTo = compareToItems[c] as AD7MemoryAddress;
if (compareTo == null)
{
continue;
}
if (!AD7Engine.ReferenceEquals(this.m_engine, compareTo.m_engine))
{
continue;
}
bool result;
switch (contextCompare)
{
case enum_CONTEXT_COMPARE.CONTEXT_EQUAL:
result = (this.m_address == compareTo.m_address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN:
result = (this.m_address < compareTo.m_address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN:
result = (this.m_address > compareTo.m_address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_LESS_THAN_OR_EQUAL:
result = (this.m_address <= compareTo.m_address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_GREATER_THAN_OR_EQUAL:
result = (this.m_address >= compareTo.m_address);
break;
// The sample debug engine doesn't understand scopes or functions
case enum_CONTEXT_COMPARE.CONTEXT_SAME_SCOPE:
case enum_CONTEXT_COMPARE.CONTEXT_SAME_FUNCTION:
result = (this.m_address == compareTo.m_address);
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_MODULE:
result = (this.m_address == compareTo.m_address);
if (result == false)
{
//DebuggedModule module = m_engine.DebuggedProcess.ResolveAddress(m_address);
//if (module != null)
//{
// result = (compareTo.m_address >= module.BaseAddress) &&
// (compareTo.m_address < module.BaseAddress + module.Size);
//}
}
break;
case enum_CONTEXT_COMPARE.CONTEXT_SAME_PROCESS:
result = true;
break;
default:
// A new comparison was invented that we don't support
return VSConstants.E_NOTIMPL;
}
if (result)
{
foundIndex = c;
return VSConstants.S_OK;
}
}
return VSConstants.S_FALSE;
}
//catch (ComponentException e)
//{
// return e.HResult;
//}
catch (Exception e)
{
return EngineUtils.UnexpectedException(e);
}
}
示例15: Subtract
// Subtracts a specified value from the current context's address to create a new context.
public int Subtract(ulong dwCount, out IDebugMemoryContext2 ppMemCxt)
{
ppMemCxt = new AD7MemoryAddress(m_engine, (uint)dwCount - m_address);
return VSConstants.S_OK;
}