Documentation/Debugging with Valgrind: Difference between revisions

From QEMU
(Initial comments, cobbled together from other pages)
 
mNo edit summary
Line 1: Line 1:
Valgrind [http://www.valgrind.org valgrind] works much like QEMU's TCG mode except it has a focus on debugging and testing. You can use it to detect memory corruption and leaks within QEMU.
[http://www.valgrind.org Valgrind] works much like QEMU's TCG mode except it has a focus on debugging and testing. You can use it to detect memory corruption and leaks within QEMU.


= KVM Based QEMU =
= KVM Based QEMU =
Line 7: Line 7:
= TCG Based QEMU =
= TCG Based QEMU =


You will need to use the <code>--smc-check=all</code> option to instruct valgrind to detect self-modifying code which TCG makes extensive use of.
You will need to use the <code>--smc-check=all</code> (or <code>--smc-check=all-non-file</code> with newer valgrind versions) option to instruct valgrind to detect self-modifying code which TCG makes extensive use of.


== softmmu debugging ==
== softmmu debugging ==

Revision as of 22:42, 16 October 2014

Valgrind works much like QEMU's TCG mode except it has a focus on debugging and testing. You can use it to detect memory corruption and leaks within QEMU.

KVM Based QEMU

valgrind really doesn't function well when using KVM so it's advised to use TCG.

TCG Based QEMU

You will need to use the --smc-check=all (or --smc-check=all-non-file with newer valgrind versions) option to instruct valgrind to detect self-modifying code which TCG makes extensive use of.

softmmu debugging

Valgrind can be simply run by putting the it in-front on your qemu-system invocation

linux-user debugging

This is potentially complicated by the fact that a qemu-linux-user instance is usually run in a guest chroot. However with multi-arch systems you can bind mount the required host paths into your chroot so valgrind (and non-static qemu binaries) can run.