Qemu調試Windows

來源:互聯網
上載者:User

原文地址:http://blog.csdn.net/ariesjzj/article/details/8698439

Kernel級的Windows調試,Windbg+Virtualbox(Vmware )這套方案很好用,但Windbg依賴於guest(也就是Windows)。如果guest中的Windows小crash,可以抓到,但如果crash得比較嚴重,把和Windbg通訊的那部分也破壞了,那Windbg就沒法work了。而用qemu則沒有這個問題,因為qemu中的gdbserver是在虛擬機器裡的,guest無論怎麼crash都沒有影響。

1. 準備Windows的image檔案,可以用qemu的虛擬cdrom進行安裝。也可以用Virtualbox選擇qcow格式並安裝(最新的Virtualbox才有這功能)。注意qcow不支援snapshot,而qcow2支援,兩者可以通過qemu-img轉。


2. 運行qemu,如:

$ qemu-sytem-x86_64 -hda /home/zjin/win7.qcow -m 2048 -net nic.vlan=0 -net user,vlan=0,hostname=emu -boot c
最好不要加kvm: -machine accel=kvm 或 -enable-kvm,否則系統能跑起來,但軟體中斷停不下來。


3. 起gdbserver

在qemu裡Ctrl+Alt+2進入monitor,然後 (qemu) gdbserver

也可以在qemu命令列加-s -S隨系統啟動。


4. 在host上起gdb,執行

(gdb)target remote localhost:1234

如果guest是64位的話還要執行

(gdb)set architecture i386:x86-64

然後就可以用gdb調了,要看一些類比硬體的資訊(tlb, crx, msr, gdt等)可以Ctrl+Alt+2到monitor裡看。



一些問題:

* No available block device supports snapshots
可能是image檔案格式不支援,將image檔案轉成qcow2

* Remote 'g' packet reply is too long:

Mode的變化gdb並不知道,所以要手動改:
gdb set architecture i386:x86-64

gdb set archtecture i386

Reference:

Running Virtual Machines with qemu-kvm http://doc.opensuse.org/products/draft/SLES/SLES-kvm_sd_draft/cha.qemu.running.html

Debugging Tips(Qemu+windbg) http://www.h7.dion.ne.jp/~qemu-win/DebuggingTips-en.html#windbg

Developing Linux inside QEMU/KVM Virtual Machines http://chemnitzer.linux-tage.de/2012/vortraege/folien/1061-VirtualDebugging.pdf

qemu+gdb http://www.ece.cmu.edu/~ee349/f-2012/lab2/qemu.pdf

Using IDA's GDB debugger with QEMU emulator https://www.hex-rays.com/products/ida/support/tutorials/debugging_gdb_qemu.pdf


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.