Dr.Watson使用技巧摘要

 

For Win98/WinME the executable is DRWATSON.EXE
For WinNT/Win2000/WinXP the executable is DRWTSN32.EXE (although DRWATSON.EXE is provided for backwards compatability)

DrWatson.exe (used to do dump stack information when a program crashes)works for 16-bit windows applications and DrWtsn32.exe works for 32-bit applications in NT.

若要使Dr Watson生成的Log中能包括出错函数的调用堆栈(很有用!),请在VC中指定生成COFF format或Both format的Debug Info,而不是缺省的Microsoft format。对于VC 6.0,可在Project Setting的Link - Debug处设定。

Dr. Watson log file. For Windows 2000 the Log file is located at: C:/Documents and Settings/All Users/Documents/Microsoft/Dr Watson. For Windows XP the log file is located at: C:/Documents and Settings/All Users/Application Data/Microsoft/Dr Watson (MS KB Q308538说缺省保存在C:/Documents and Settings/All Users.WINNT/Application Data/Microsoft/Dr Watson,到底是哪里未确认). The file is typically named drwtsn32.log. For Windows NT the log file is located at C:/WinNT and the file is typically named drwatson.log.

User dump log file. For Windows 2000 the Log file is located at: C:/Documents and Settings/All Users/Documents/Microsoft/Dr Watson. For Windows XP the log file is located at: C:/Documents and Settings/All Users/Application Data/Microsoft/Dr Watson. For Windows NT the log file is located at C:/Winnt. The file is typically named user.dmp.

以上的位置和Dump文件名可以在Dr Watson的GUI窗口中设置。

Dr. Watson is basically a debugging tool.  When a program has an unhandled exception, Dr Watson will be automatically started by the system.  An unhandled exception means that the program itself doesn't specify what to do when the error occurs, and no other debuggers are installed and configured to handle the error.  There are two Registry entries that tell the system the debugger to use:

Hive: HKEY_LOCAL_MACHINE
Key: Software/Microsoft/Windows NT/CurrentVersion/AeDebug
Name: Debugger
Data Type: REG_SZ
Value: drwtsn32 -p %ld -e %ld -g

Hive: HKEY_LOCAL_MACHINE
Key: Software/Microsoft/Windows NT/CurrentVersion/AeDebug
Name: Auto
Data Type: REG_SZ
Value: 1

For the first entry, the value shown is the default for Dr Watson.  If another debugger is used, the value will be the path and options of that debugger.  The second value tells whether the debugger will start automatically (value of 1) or prompt the user first (value of 0).  When Dr. Watson runs, it not only stops the program that errored, it also generates a log file at C:/Documents and Settings/All Users/Documents/DrWatson by default (根据OS的不同,其位置和文件名是不同的,请看下面的详细说明), called drwtsn32.log, which contains a plethora of information.  This information is particularly useful to developers, but is difficult to decipher for users.  If a third party debugger is installed, and you want to make Dr. Watson the default again, simply run "drwtsn32.exe -i" to restore the above Registry entries.

在NT或2000中,要禁用 Dr. Watson,请按照下列步骤操作

1. 单击开始,单击运行,在打开框中键入 regedit.exe,然后单击确定。
 
2. 找到并单击以下注册表项:

HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/AeDebug

注意:步骤 3 和步骤 4 是可选的;如果您要还原使用 Dr. Watson 的默认设置,则需要执行这两个步骤。
 
3. 单击 AeDebug 项,然后单击注册表菜单上的导出注册表文件。
 
4. 为要保存的注册表文件输入名称和位置,然后单击保存。
 
5. 删除 AeDebug 项。
 

在 Windows 中,调试程序的注册表项位于 AeDebug 项中。默认情况下,Dr. Watson 程序安装在 Windows 中,并配置为在发生应用程序错误时运行(Auto 值的数据值为 1)。默认值为:

数值名称 = Auto
类型 = 字符串 (REG_SZ)
数据值 = 1 或 0。(默认值为 1)

数值名称 = Debugger
类型 = 字符串 (REG_SZ)
数据值 = drwtsn32 -p %ld -e %ld -g

注意:该数据值 (drwtsn32 -p %ld -e %ld -g) 是 Dr.Watson 专有的。其他调试程序将具有它们自己的值和参数。


1.Dr.Watson是什么?
          Dr.Watson( drwtsn32.exe)是Windows自带的调试工具,相比于比较专业的程序调试工(WinDbg,Ntsd…)她显得比较的弱小,但是在如下场合她应该是比较好的一种选择:
a.       在没有安装任何调试工具的测试机器上我们的程序崩溃了.怎么办?是把Windows弹出来的报错的对话框抓屏发给开发人员看吗?说实话那个对话框对开发人员来说信息太少了,唯一能断定的是:哦,这个程序崩溃了.
b.       在最终用户的机器上;我们的程序已经发售到了最终用户手上,程序崩溃了,怎么办?问题出在哪?
在这个时候Dr.Watson显出了她的优势:她是Windows自带的调试工具,不需要另外安装,而且她能提供给开发人员必要的信息去确定问题 的所在.
这就是说Dr.Watson能在如下时刻帮助我们:
1.       应用程序崩溃了(Crash);
2.        应用程序遇到了异常(Exception)(注:产生了异常如果我们采取了一切措施,比如Try-Catch机制,并不会导致崩溃)
 
2.Dr.Watson什么时候会被运行起来?
           如果你的机器上Dr.Watson被设置成默认的调试工具那么当你的Windows中任何程序崩溃的时候Dr.Watson会自动运行,当然她的运行也许没有界面(可以在Dr.Watson界面中设置),她只是默默的产生了一个包含错误信息的文件存放在特定的路径下.这时候你要做的也许就是把这个包含错误信息的文件发给开发人员.注意我们前面说到的”如果Dr.Watson被设置成默认的调试工具那么….”也就是说Dr.Watson有可能并不是你机器上的默认的调试工具,比如说你安装了VC6++那么VC6++就会成为你的默认的调试工具….那如何把我们的Dr.Watson妹妹设置成默认的调试工具呢??请参看4.如何把 Dr.Watson设置成Windows默认的调试工具?
           另外一种运行Dr.Watson的方式就是在Run(运行)处输入drwtsn32回车.
 
3.当有程序崩溃的时候 Dr.Watson会产生什么文件?存在哪?
                 Dr.Watson产生的drwtson32.log,user.dmp文件,其中drwtson32.log是一个文本文件,大家随便找一个 TextEdit就可以打开,里面包含的信息的解释稍后有详细的介绍,user.dmp文件是提供给WinDbg之类的稍专业一点的调试工具用的,WinDbg可以导入user.dmp文件然后看到崩溃的现场.
           文件的存放位置是可以在Dr.Watson中设置的,默认的存放位置和Windows的版本有关系:
Windows NT   :  %UserProfile%/Local Settings.
Windows 2000 : %AllUsersProfile%/Documents/DrWatson.
Windows 2003 : %AllUsersProfile%/Application Data/Microsoft/Dr Watson .
Windows XP   : %AllUsersProfile%/Application Data/Microsoft/Dr Watson .

4.如何把 Dr.Watson设置成Windows默认的调试工具?
                 Start(开始)àRun(运行),输入”drwtsn32 –i”回车,好了,现在Dr.Watson就是你的Windows的默认的调试工具了.
 
5.如何让 Dr.Watson只关心我指定的程序的崩溃情况?
                 大部分时间我们并不关心别的程序是否崩溃而只是关心我们正在测试/调试的程序,那我们能否让Dr.Watson只记录我们感兴趣的那个程序的崩溃情况呢??
                  在Run(运行)对话框中输入”drwtsn32 -p ProcessID”你就可以指定Dr.Watson只调试指定的进程. 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值