Vs2013在Linux开发中的应用(31):内存块显示

来源:互联网 发布:ieee33节点数据 编辑:程序博客网 时间:2024/06/07 22:39

快乐虾

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实际读取数据并填充后就成了这样:



搞定!







0 0