Qemu debug windows

Source: Internet
Author: User
Tags gdb debugger

Address: http://blog.csdn.net/ariesjzj/article/details/8698439

For kernel-level Windows debugging, windbg + virtualbox (VMware) is a good solution, but windbg depends on guest (that is, windows ). If the Windows crash in guest can be caught, but if the crash is serious and the part that communicates with windbg is damaged, windbg cannot work. Qemu does not have this problem, because gdbserver in qemu is in the virtual machine, and guest does not affect crash.

1. Prepare the Windows Image File. You can use the virtual cdrom of qemu to install it. You can also use virtualbox to select the qcow format and install it (only the latest virtualbox has this function ). Note that qcow does not support snapshot, while qcow2 does. The two can be converted through qemu-IMG.

2. Run qemu, for example:

$ Qemu-sytem-x86_64-hda/home/zjin/win7.qcow-M 2048-net Nic. VLAN = 0-Net user, VLAN = 0, hostname = EMU-boot C

We recommend that you do not add KVM:-machine accel = KVM or-enable-KVM. Otherwise, the system can run, but the software cannot be stopped.

3. Start gdbserver

In qemu, CTRL + ALT + 2 to go to monitor, and then

(Qemu) gdbserver

You can also add-s to the qemu command line to start with the system.

4. Start GDB on the host and execute

(GDB) target remote localhost: 1234

If the guest is 64-bit, execute

(GDB) set architecture i386: x86-64

Then you can use GDB to call it. You can press CTRL + ALT + 2 to monitor to view the simulation hardware information (such as TLB, CRX, MSR, and gdt.

Some questions:

* No available block device supports snapshots

It may be that the image file format is not supported. Convert the image file to qcow2.

* Remote 'G' packet reply is too long:

GDB does not know the mode change, so you need to manually change it:

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.