windbg + winRT (WOA windows on ARM) kernel debug

有看到WoA的機器,就想嘗試在WoA上調試AP、Driver。

目前,由於windbg沒有ARM的版本,因此無法想x86、x64平臺那樣簡單、快捷的來調試。因此只好通過remote debug的這種方式來嘗試。

首先想到的是利用windbg,進行本機kernel debug,在WoA的WDK中真的有windbg ARM版本,很興奮的裝上去,打開kernel debug時,發現local根本無法支持,一直顯示需要運行 "bcdedit /debug on" 然後 "reboot",嘗試了很多遍,一直重複這樣的提示。無法進入kernel debug。

其次想到的是利用 usb debug cable,雙機互聯,透過windbg來調試,沒想到WoA不支持此方法。原因麼,下面會提到。雙機連接,打開debug模式後,無法互聯。

最後想到的是利用 VS2012 的remote debug,但是在vs2012的目錄下並沒有找到支持ARM的remote debugger,只有x86、x64。

好了,上面的方法統統行不通,只好網絡上搜集,據win8發佈會視頻介紹,可以直接利用usb direct cable進行互聯,需要找到WoA上的一個特殊端口,在debug模式下,這個端口會被視作一個usb debug target,雙機互聯後,目標機器會被視作一個 usb debug target,在源機器上可以透過devcie manager看到一個 mocrosoft usb debug target。這裏的源機器是win7系統,系統可以自動識別這個device,其他系統可以嘗試手動加載驅動usb2dbg.sys。打開windbg,選擇kernel debug -> USB 可以順利連上目標機器。


ok,在源機器上打開windbg,可以顯示connect成功,但是。。。但是沒有log。什麼原因呢,看起來ARM並不是那麼容易show log。在OSR上找到一篇文章介紹瞭如何在目標機器上打開log。參考: http://www.osronline.com/article.cfm?article=295

Getting DbgPrint Output To Appear In Vista and Later 

OSR Staff | Published: 11-May-04| Modified: 25-Jan-13 

The problem: Your DbgPrint or KdPrint messages don't appear in WinDbg (or KD) when you run your driver on Windows Vista, Windows 7, or Windows 8.

The reason?  Versions of Windows starting with Vista automatically map DbgPrint and friends to DbgPrintEx.  Now, you may recall that DbgPrintEx allows you to control the conditions under which messages will be sent to the kernel debugger by filtering messages via a component name and level in the function call and an associated filter mask in either the registry or in memory. 

DbgPrint and KdPrint are mapped to component "DPFLTR_DEFAULT_ID" and level "DPFLTR_INFO_LEVEL".  Of course xxx_INFO_LEVEL output is disabled by default.  So, by default, your DbgPrint/KdPrint doesn't get sent to the kernel debugger.

 

How to fix it? Two choices:

  • Enable output of DbgPrint/KdPrint messages by default -- Open (or add, if it's not already there) the key "HKLM\SYSTEM\CCS\Control\Session Manager\Debug Print Filter".  Under this key, create a  value with the name "DEFAULT"  Set the value of this key equal to the DWORD value 8 to enable xxx_INFO_LEVEL output as well as xxx_ERROR_LEVEL output.  Or try setting the mask to 0xF so you get all output.  You must reboot for these changes to take effect.  Note... Don't set the value named "(default)" -- You actually have to create a new value with the name "DEFAULT" and set that to whatever value you want (0xF, for example).

  • Specifically change the component filter mast for DPFLTR. Starting with Windows Vista you need to set the mask value for the DWORD at Kd_DEFAULT_MASK ("ed Kd_DEFAULT_MASK").  You can specify 8 to enable DPFLTR_INFO_LEVEL output in addition to DPFLTR_ERROR_LEVEL output, or 0xF to get all levels of output.

See the WDK documentation for Reading and Filtering Debugging Messages (follow the path: Driver Development Tools\Tools for Debugging Drivers\Using Debugging Code in a Driver\Debugging Code Overview) for the complete details on the use of DbgPrintEx/KdPrintEx.  Or look at the Debugging Tools For Windowsdocumentation (Appendix A) on DbgPrintEx.

Tweet


筆者有嘗試上述方法,還是沒有能夠產生LOG,最終在windbg中運行以下命令真的看到LOG了:

ed Kd_DPFLTR_MASK 0xFF

至此,windbg + WoA 順利進入kernel debug 模式。

發佈了67 篇原創文章 · 獲贊 12 · 訪問量 57萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章