Windbg有没有通用的格式化输出内存的扩展命令。

Windows内核调试

Windbg有没有通用的格式化输出内存的扩展命令。


Coding 2009-10-12, 11:43 上午

我们能用dt address type 来按类型来输出内存的内容。

但是,有时候symbols里面根本就没有对应的type,比如说,有一个网络消息结构,在C/C++源文件里面,没有申明一个对应的结构,源代码里面都直接使用宏去访问消息中的特定的域。这样的话,为了在Windbg格式中格式化输出这样一个结构,只有自己写扩展命令去做。

问题在于,这样的无类型申明的结构很多,为每一个都写一个扩展明显不值得,而且不得不重新编译扩展dll。

是否已经有一个通用的扩展dll和对应的用于描述结构的"脚本文件",扩展dll每次解析这样的一个"脚本文件"来格式化输出内存内容。

这样的话,每次有个新的需求,只需要写一个新的"脚本文件"来描述这个类型就可以了。

Re: Windbg有没有通用的格式化输出内存的扩展命令。


格蠹老雷 2009-10-12, 13:00 下午

感觉没有现成的命令,这是改进WinDBG一个很好建议,可以按这个思路写一个通用的扩展命令。WinDBG有“合成符号”的概念,可以派给某个地址加个名称:

Synthetic Symbols

Synthetic symbols are a way to label an arbitrary address for easy reference. Synthetic symbols can be created in any existing module. The method AddSyntheticSymbol creates a new synthetic symbol. Synthetic symbols can be removed using RemoveSyntheticSymbol. Reloading the symbols for the module deletes all synthetic symbols associated with that module.

 

Re: Windbg有没有通用的格式化输出内存的扩展命令。


Coding 2009-10-13, 10:56 上午
看了下VS2008的功能,有两个东西,autoexp 和 Visualizers 是用来定制watch窗口显示的。不过似乎也需要申明过这样一个类型。
不过autoexp是个很不错的东西,好像windbg下面也没有类似的东西。简单来说,用autoexp我可以很方便的只显示我关心的内容,只需要编辑一个"脚本"就可以了。
Visualizers 也有趣
这里有个C#的例子,调试一张图片的时候,直接就把这个图片显示出来了。
http://www.codeproject.com/KB/trace/ImageVisualizer.aspx
现在手头的windbg扩展dll,只是dump图片到磁盘,回头也写成可以直接显示的。

Powered by Community Server Powered by CnForums.Net