Vs2013在Linux开发中的应用(31):内存块显示
快乐虾
http://blog.csdn.net/lights_joy/
欢迎转载,但请保留作者信息
要实现内存块的显示,需要实现IDebugMemoryBytes2接口,类似这样的:
class AD7MemoryBytes : IDebugMemoryBytes2 { private AD7Engine _engine; public AD7Engine Engine { get { return _engine; } } public AD7MemoryBytes(AD7Engine engine) { _engine = engine; } public int GetSize(out ulong pqwSize) { throw new NotImplementedException(); } public int ReadAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] rgbMemory, out uint pdwRead, ref uint pdwUnreadable) { AD7MemoryAddress addr = pStartContext as AD7MemoryAddress; pdwRead = dwCount; pdwUnreadable = 0; return Constants.S_OK; } public int WriteAt(IDebugMemoryContext2 pStartContext, uint dwCount, byte[] rgbMemory) { throw new NotImplementedException(); }
当VS显示内存窗口时,会调用:
// The memory bytes as represented by the IDebugMemoryBytes2 object is for the program‘s image in memory and not any memory // that was allocated when the program was executed. public int GetMemoryBytes(out IDebugMemoryBytes2 ppMemoryBytes) { ppMemoryBytes = new AD7MemoryBytes(this); return Constants.S_OK; }
这里仅仅实现了一个空接口,并没有实现内存实际值的刷新,但此时已经可以在IDE中看到这样的效果了:
在读取数据的接口中使用gdb的-data-read-memory实际读取数据并填充后就成了这样:
搞定!
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。