kd/WinDbgでVirtualBox上のWindowsをカーネルデバッグする
VirtualBoxの仮想マシン上で動いているWindowsをkd/WinDbgでカーネルデバッグしてみる。
環境
VirtualBox 4.3.28
>kd /version kd version 6.3.9600.17298
仮想マシンのシリアルポートを有効にする
仮想マシンの設定からシリアルポートを選び、「ポート1」を次のように設定する。
- 「シリアルポートを有効化」にチェック
- ポート番号「COM1」、ポートモード「ホストにパイプ」を選択
- 「パイプ作成」にチェック
- 「ポート/ファイルパス」に
\\.\pipe\debug
を指定
仮想マシン上のWindowsでデバッグポートを設定する
仮想マシンを起動し、管理者コマンドプロンプトから次のコマンドを実行する。
> bcdedit /debug on > bcdedit /dbgsettings serial debugport:1 baudrate:115200
コマンドを実行したら、仮想マシンをシャットダウンする。
kdで接続を待ち受ける
ホストPCのコマンドプロンプトから次を実行した後仮想マシンを起動すると、カーネルデバッグが行われる。
>kd -k com:pipe,port=\\.\pipe\debug,resets=0,reconnect Microsoft (R) Windows Debugger Version 6.3.9600.17298 X86 Copyright (c) Microsoft Corporation. All rights reserved. Waiting for pipe \\.\pipe\debug Kernel Debug Target Status: [no_debuggee]; Retries: [0] times in last [7] second s. Waiting to reconnect... Connected to Windows 8 9600 x86 compatible target at (Mon Sep 14 22:17:59.292 20 15 (UTC + 9:00)), ptr64 FALSE Kernel Debugger connection established. ************* Symbol Path validation summary ************** Response Time (ms) Location Deferred srv*C:\Symbols*http://msdl.micros oft.com/download/symbols Symbol search path is: srv*C:\Symbols*http://msdl.microsoft.com/download/symbols Executable search path is: Windows 8 Kernel Version 9600 MP (1 procs) Free x86 compatible Built by: 9600.17936.x86fre.winblue_ltsb.150715-0840 Machine Name: Kernel base = 0x8181a000 PsLoadedModuleList = 0x81a16718 System Uptime: 0 days 0:00:00.033 KDTARGET: Refreshing KD connection
コマンドプロンプト上でCtrl+C
を押すとブレークすることができる。
Break instruction exception - code 80000003 (first chance) ******************************************************************************* * * * You are seeing this message because you pressed either * * CTRL+C (if you run console kernel debugger) or, * * CTRL+BREAK (if you run GUI kernel debugger), * * on your debugger machine's keyboard. * * * * THIS IS NOT A BUG OR A SYSTEM CRASH * * * * If you did not intend to break into the debugger, press the "g" key, then * * press the "Enter" key now. This message might immediately reappear. If it * * does, press "g" and "Enter" again. * * * ******************************************************************************* nt!RtlpBreakWithStatusInstruction: 81916a14 cc int 3 kd> r eax=00000001 ebx=81a2b35c ecx=00000049 edx=00000000 esi=81a29120 edi=00000000 eip=81916a14 esp=8e087b7c ebp=8e087be4 iopl=0 nv up ei pl nz na po nc cs=0008 ss=0010 ds=0023 es=0023 fs=0030 gs=0000 efl=00000202 nt!RtlpBreakWithStatusInstruction: 81916a14 cc int 3 kd> g
kdを終了させるには、Ctrl+B
を押した後ENTER
を押す。
^B quit: