windbg + winRT (WOA windows on ARM) kernel debug

來源:互聯網
上載者:User

有看到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 模式。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.