WinDbg Basic Commands

WinDbg Basic Commands

When WinDbg is attached to the debuggee process, WinDbg can fully control any execution of the debuggee process. For example, WinDbg can run the debuggee step by step, check call stack of a thread, check variable/data structure values, and set breakpoint on a specific code, and so on.

Let's look at some of typical commands that are used in WinDbg. First, here is a very simple C++ code we are going to use for debugging.

#include "stdafx.h"

int Divide(int a, int b)
{
	int c = a / b;
	return c;
}

int main()
{
	int x = 100;
	int y = 2;

	int result = Divide(x, y);
	printf("%d\n", result);

	y -= 2;
	result = Divide(x, y);
	printf("%d\n", result);

	return 0;
}

After build, open executable file (call it CrashApp.exe) from WinDbg. When WinDbg opens EXE file, it immediately breaks into the beginning of the executable, which gives WinDbg an oppurtunity of any necessary control. If we want to set breakpoint or any other settings, this is the good time to do that. Once those settings are done (if any), we can issue g (go) command to keep running the debuggee.

After g command, the debuggee application was crashed with divide by zero exception as shown below. If there is no exception, the debuggee will keep running.

To check where the exception was thrown, we can use kp command which will show call stacks with input parameters information. Call stack shows all the function call history up to this exception. Each line in call stack is called "frame." Typically we tend to check call stack from top frame (latest call) to bottom frame. Each frame represent different function, so each frame has different variables. To check variables in current frame, use dv (display variables) command. If /t is used, variable type is also displayed and if /v is used, memory address is also displayed. As shown in the picture, we got divide by zero exception because variable b is 0.

In order to change call stack frame, use .frame {frame#} command. For example, to go to the first frame, use ".frame 0" and for the second frame, use ".frame 1" (Please note that there is dot(.) in front of the command, which will be covered later). In below picture, we go to 2nd frame and check variables of main() function. Here we can see y value is zero, which is passed to 2nd parameter of Divide() function.

Once all the investigation is done, use q (quit) command to exit WinDbg.



两个鬼故事姓袁的女孩起名大全鹅店有怎么起名字高端化妆品商标起名大全psp但丁地狱医疗器械公司名字起名字大全给公司起英文名名字测在一起的几率病毒软件保字辈的怎么起名合适女孩起名的古诗词葡萄酒起名大全八字起名字大全免费观看武极天下5200宋仲基壁纸灵柩霞谷先祖位置宝宝2020年起名字足浴店起名西红柿什么时候传入中国中信银行网银易经测公司起名塑胶制品起名带宝起名字无心法师百度云myfather程姓女孩起名设计企业起名网吧起名对合作社起个名字目穷淮海满如银少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化