Enable kernel debugging in Windows Vista

要被 debug 的目標電腦上跑有會造成 crash 的 kernel/application/service etc.
Windows Vista 後要設定 target machine 參考以下這篇文章做設定:


Kernel Debugging in Windows Vista
http://www.microsoft.com/whdc/driver/tips/debug_vista.mspx


原則上就是先將 {current} 的 boot loader setting 複製一份成 DebugEntry,然後 enable debug in DebugEntry
最後將 DebugEntry 設成 default boot


為了怕上述網頁失聯,以下是一些相關的 command


1. 設定 debug type 為 USB,targetname 為 MYDEBUG
bcdedit /dbgsettings USB TARGETNAME:MYDEBUG


2. 顯示 global debugging settings
bcdedit /enum all


3. 由目前的 boot entry 複製成新的 DebugEntry
bcdedit /copy {current} /d DebugEntry
執行成功後會回傳該 entry 的 GUID


4. Add the new boot entry to the boot menu
其中 {ID} 為 entry 的 GUID
bcdedit /displayorder {current} {ID}


5. Enable debugging on the new boot entry
bcdedit /debug {ID} ON
設定完後在 entry 最下面會看見 Kernel debugger: Yes 的內容
(在 Windows 7 中我看見 debugger: Yes)


6. Change the default boot entry
bcdedit /default {ID}


7. Reboot the computer
重啟後便會看見 DebugEntry [debugger enabled] 這個選項出現


########################################################


至於 host machine 的設定則參考以下網路上找到的步驟。有些地方我加了中文註解


1. Prepare the "Hi-Speed USB 2.0 Host-to-Host Debug Device"
2. Plug both USB connectors into the host PC
3. Start WinDbg in elevated mode (run as admin)
4. Start kernel debug in USB mode, it should install drivers necessary
Windbg 的 targetname 可以先亂寫,反正只要讓 Windbg 以為你真的要用 USB 連接就好
5. Unplug one USB cable and plug it into the target PC
6. In host PC's Device Manager, locate the "Ajays USB 2.0 Debug Cable", and
provide the missing driver for it from [WDK dir]\Debuggers
這個地方我是在 target machine 也安裝了 Windbg,並且重複 3-4 步驟來裝 driver 的
7. Locate USB "Port 1" on target PC using USBVIEW from the WDK
8. Plug the USB cable into this port
9. Configure target PC for USB debug, using same targetname as in 4) above
這部份的 targetname 就是設定 target machine 時,使用 bcdedit 來設定的
10. Reboot the target PC
重啟後記得要選 debugger enabled 的選項。然後就可以看見 host machine 的 Windbg 開始出現連結的訊息。


微軟方面的資訊可參考:


Setting Up a USB 2.0 Debug Cable Connection
http://msdn.microsoft.com/en-us/library/ff556869(v=VS.85).aspx


########################################################


另外更簡單的方式是,在 command line 下打 msconfig,在 boot->Advanced options 裡頭也可以直接設定 debug 選項


留言

熱門文章