標籤:使用 os io 檔案 資料 for art ar
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只調試指定的進程.