【翻译 windbg-3】高级WinDbg 使用教程

 

 

<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;
mso-font-charset:1;
mso-generic-font-family:roman;
mso-font-format:other;
mso-font-pitch:variable;
mso-font-signature:0 0 0 0 0 0;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;
mso-font-charset:0;
mso-generic-font-family:swiss;
mso-font-pitch:variable;
mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-unhide:no;
mso-style-qformat:yes;
mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-fareast-font-family:宋体;
mso-fareast-theme-font:minor-fareast;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-font-kerning:1.0pt;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
mso-themecolor:hyperlink;
text-decoration:underline;
text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-noshow:yes;
mso-style-priority:99;
color:purple;
mso-themecolor:followedhyperlink;
text-decoration:underline;
text-underline:single;}
.MsoChpDefault
{mso-style-type:export-only;
mso-default-props:yes;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:595.3pt 841.9pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:42.55pt;
mso-footer-margin:49.6pt;
mso-paper-source:0;
layout-grid:15.6pt;}
div.Section1
{page:Section1;}
-->

原文地址:

http://blogs.msdn.com/johan/archive/2008/01/23/using-windbg-advanced-commands.aspx

作者:Johan

翻译:AloneSword

网文:http://blog.csdn.net/alonesword/

 

高级WinDbg 使用

是否知道在windbg中使用像foreach, if 等等的高级命令,如下是完整的列表:

.if

.else

.elseif

.foreach

.for

.while

.do

.break

.continue

.catch

.leave

.printf

.block

 

使用这些命令,不仅能使用调试器的高级指令让工作更容易,更能极大的改进你的管理能力。

 

.foreach

让我们从一个简单的实例开始。假设你想查看当前堆栈上所有大于6500字节的字符串内容,只需要简单的键入: !dumpheap –type System.String –min 6500 即可,可以得到类似如下的信息:


0:000> !dumpheap -type System.String
-min 6500

Using our cache to search the heap.

  
Address         MT     Size 
Gen

0x00f68f34 0x79b946b0    7,152   
2 System.String SELECT b4.contract_config_id,

0x3b7d8bd0 0x79b946b0   14,708   
2 System.String

 

private double GetZTEDZBLo

0x3b7dc544 0x79b946b0   18,836   
2 System.String using System;

using System.Da

0x3b89e394 0x79b946b0   73,748   
2 System.String     public
Object FormulaComp1

0x1d004690 0x79b946b0   14,416   
2 System.String SELECT b4.contract_config_id,

0x1d01101c 0x79b946b0    8,376   
2 System.String SELECT bom.system_bom_id,

  

0x023462c0 0x79b946b0  145,916   
3 System.String using System;

using System.Da

0x02373d50 0x79b946b0  145,916   
3 System.String using System;

using System.Da

Statistics:

       
MT      Count     TotalSize Class Name

0x79b946b0          8       429,068 System.String

Total 8 objects, Total size: 429,068

 

到目前为止,我们认为这个内容还不错,问题是如果我想查看每个字符串的内容,就不得在每个字符串地址上运行 !dumpobj。在只有8个字符串地址的情况下,这么做还是能接受的,如果数量达到25 或100个呢?不知道大家是否注意到,传递-short 参数到 !dumpheap的话,它将给出最少的信息(仅仅是查询出对象的地址信息)


0:000> !dumpheap -type System.String
-min 6500 -short

0x00f68f34

0x3b7d8bd0

0x3b7dc544

0x3b89e394

0x1d004690

0x1d01101c

0x023462c0

0x02373d50

现在,就可以在 .foreach 语句中使用这些信息了:


0:000> .foreach (myAddr {!dumpheap
-type System.String -min 6500 -short}){!dumpobj myAddr;.echo
**************************}

String: SELECT b4.contract_config_id,

 

**************************

String:

 

private double GetZTEDZBLookUP(string
tableName,string rowName,string colName)

{

   
return 
SpecialFormula.GetZTEDZBLookUP(tableName, rowName, colName);

}          

 

**************************

String: using System;

using System.Data;

using System.Data.OleDb;

using System.Collections;

using ZTE.CCG.Business.Template;

using ZTE.CCG.Business.Contract.Template;

 

using ZTE.CCG.Common.Tool;

 

namespace MyNamespace{

public class MyNewClass{

 

 

private double GetZTEDZBLookUP(string
tableName,string rowName,string colName)

{

   
return 
SpecialFormula.GetZTEDZBLookUP(tableName, rowName, colName);

}

 

**************************

String:     public Object FormulaComp148169817_264981(Object[]
_Param){

           

 

**************************

String: SELECT b4.contract_config_id,

                                                   

**************************

String: SELECT bom.system_bom_id,

 

**************************

String: using System;

using System.Data;

using System.Data.OleDb;

using System.Collections;

using ZTE.CCG.Business.Template;

using ZTE.CCG.Business.Contract.Template;

 

using ZTE.CCG.Common.Tool;

 

namespace MyNamespace{

public class MyNewClass{

   
public Object FormulaComp148169817_264981(Object[] _Param){

return((Convert.ToString(_Param[0])!="1/4")?Convert.ToDouble(_Param[1])*2:0);

   
}

 

**************************

String: using System;

using System.Data;

using System.Data.OleDb;

using System.Collections;

using ZTE.CCG.Business.Template;

using ZTE.CCG.Business.Contract.Template;

 

using ZTE.CCG.Common.Tool;

 

namespace MyNamespace{

public class MyNewClass{

   
public Object FormulaComp148170092_264981(Object[] _Param){

return((Convert.ToString(_Param[0])!="1/4")?Convert.ToDouble(_Param[1])*2:0);

   
}

**************************

“myobj” 是一个中间变量,为在随后的命令中使用。第二个命令就是想循环执行的语句。首先,对变量运行 !dumpobj ,同时使用 .echo 命令打印分割符,以便更好的阅读分析。

 

还有一些其他的参数可以使用,例如:可以选择跳过n行变量;指定一个文本文件作为命令的替代品。若对这些命令感兴趣,请查看windbg的文档。

 

.shell

我第一个看到这个命令使用的是我的大学同学
Doug Stewart,他在这方面完全就是一个天才。


0:000> .shell -i - -ci
"!iisinfo.clientconns" FIND /c "Request active"
40
.shell: Process exited

这个是什么意思呢?先运行 !iisinfo.clientonns 并使用 MS-DOS 的 Find 命令查”Request active”出现次数。当然,也可以使用这个命令来搜索任何输出的字符内容,比如”.shell –i - -ci “!do 0b62e790” FIND /c /i “<table””,也可以是其他的任何能满足要求的内容。

我们浏览一下相关语法:

当使用”.shell”命令时,-I 参数是必须的【标注1】,主要是输入文件选项。在上述情况中,我们没有使用输入文件,所以使用了连字符”-”,结果就是类似的语法:”.shell  -i -”

当我们使用
–ci 选项时,就表示接下来的命令将代替文件输入,”.shell  -I - -ci “!iisinfo.clientconns””

最后,我们指定运行指定的命令,在shell命令之后。”.shell –I - -ci “!iisinfo.clientconns” FIND
/c “Request active””

自然的我们可以使用任何复杂的命令来替换 !iisinfo.clientconns ,也可以运行任何一个 .foreach 循环语句

 

Johan.

 

【标注1】:更正,在 windbg 的文档关于 .shell 描述,-I 是一个可选项,而不是必选项。

 

时间: 2024-08-24 17:44:13

【翻译 windbg-3】高级WinDbg 使用教程的相关文章

MyBatis高级映射学习教程_java

对mybatis基础入门不太清楚的朋友可以参考下本篇文章:MyBatis入门学习教程(一)-MyBatis快速入门. 认识MyBatis MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache software foundation 迁移到了google code,并且改名为MyBatis .2013年11月迁移到Github. iBATIS一词来源于"internet"和"abatis"的组合,是一个基于Java的持久层框架

excel如何高级筛选动画教程

<Excel2003入门动画教程32.如何高级筛选>. 演示动画 操作步骤 利用Excel的"高级筛选"功能,我们可以把符合某种条件的数据挑选并保存到其他区域中. 同时满足多个条件数据的筛选 (我们在"员工基本情况登记表"中,把"职称"为"高级工程师",并且"学历"为"大学"的人员挑选出来,步骤如下) 先将条件列标题(学历.职称)和条件(大学.高级工程师)输入到某个单元格区域

javascript面向对象程序设计高级特性经典教程(值得收藏)_javascript技巧

本文实例讲述了javascript面向对象程序设计的高级特性.分享给大家供大家参考,具体如下: 1.创建对象的三种方式: 第一种构造法:new  Object var a = new Object(); a.x = 1, a.y = 2; 第二种构造法:对象直接量 var b = { x : 1, y : 2 }; 第三种构造法:定义类型 function Point(x, y){ this.x = x; this.y = y; } var p = new Point(1,2); 2.访问对象

Python高级数据结构学习教程

本文虽然不是很深入,不过实例比较多,学习Python高级数据结构的好基础教程. 数据结构的概念 数据结构的概念很好理解,就是用来将数据组织在一起的结构.换句话说,数据结构是用来存储一系列关联数据的东西.在Python中有四种内建的数据结构,分别是List.Tuple.Dictionary以及Set.大部分的应用程序不需要其他类型的数据结构,但若是真需要也有很多高级数据结构可供选择,例如Collection.Array.Heapq.Bisect.Weakref.Copy以及Pprint.本文将介绍

Photoshop高级鼠绘教程:绘制游戏中血精灵人物教程

HI各位童鞋大家好~本次小神给各位同学带来一种新的鼠绘思路,打破"制造"的格局,进阶"创造"的层次.小神研究鼠绘的出发点 是-零美术基础,通过一些基础练习结合PS软件锻炼鼠绘技巧,使用鼠标绘制属于自己的业余作品,这就是小神的业余鼠绘.当然如果拥有 美术基础则事半功倍,不过还是建议有美术基础的同学使用板子~研习正途.我们业余则是将偷懒进行到底~各位专家~前辈~飘过~ 本章最终效果如下: 使用软件: poser pro 2010(设定人物姿态)| photo shop

三星W2015如何开启高级功能手表?W2015开启高级功能手表教程

1. 在待机页面下,点击[应用程序].    2. 选择[设定].    3. 向上滑动屏幕,选择[高级功能手表].     4. 点击[高级功能手表]右侧的滑块,绿色代表开启.    5. 当关上手机翻盖或在屏幕关闭时点击主页键两次即可显示高级功能手表.       

Windows中IIS内FTP服务器高级配置图文教程_win服务器

提到FTP服务器,可能大家都会想到Serv-U.vs-FTP等软件,其实微软内置在IIS里的FTP服务已经够用,不信请往下看. 实现对多用户的管理 首先需要取消"站点属性/允许匿名连接",如图1. 接着进入"计算机管理/本地用户和组",新建立一个组,这里建立为FTPuser,然后新建立一个用户FTP01,然后修改FTP01的属性,把它加入FTPuser组,去掉系统默认的users组.在NTFS格式分区下(这里为d盘)创建文件夹FTP01和FTP02,然后设置安全权限

第二章排错的工具:调试器Windbg(上)

感谢博主 http://book.51cto.com/art/200711/59731.htm <Windows用户态程序高效排错>第二章主要介绍用户态调试相关的知识和工具.本文主要讲了排错的工具调试器Windbg.     第二章 汇编.异常.内存.同步和调试器--重要的知识点和神兵利器 这一部分主要介绍用户态调试相关的知识和工具.包括汇编.异常exception.内存布局.堆heap.栈stack.CRTC Runtime.handle/Criticalsection/thread con

三联photoshop教程周刊第五期

三联photoshop教程周刊第五期     一周排行 [PS调色教程] PhotoShop为外景模特照片调出HDR色调 效果 更多>> 575 [PS调色教程] Photoshop给外景人物加上流行的韩系红褐色 淡雅的红褐色及黄褐色是是韩系色彩中最为常用的.调色过程也不复杂:首先简单美化素材,把整体调淡.然后调整图片的主色,以暖色为主,后期再给暗部及高光增加暖色即可.更多>> 374 [PS调色教程] PS为外景人像调出纯净的天堂白色调教程 更多>> 341 [PS调