首页 > 代码库 > Vs2013在Linux开发中的应用(31):内存块显示
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实际读取数据并填充后就成了这样:
搞定!
??
Vs2013在Linux开发中的应用(31):内存块显示
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。