virtual-machineqemuriscvkvm

Getting dynamic execution traces for running a program in QEMU


I am running Fedora in QEMU for RISC-V ISA (64 bit). I have queries with regards to getting the dynamic execution traces as shown here(slide 3.3). This is my boot script for initialing QEMU:

qemu-system-riscv64 -d cpu -D \
   -nographic \
   -machine virt \
   -smp 4 \
   -m 4G \
   -kernel <path to elf file> \
   -bios none \
   -object rng-random,filename=/dev/urandom,id=rng0 \
   -device virtio-rng-device,rng=rng0 \
   -device virtio-blk-device,drive=hd0 \
   -drive file=<path to raw file>,format=raw,id=hd0 \
   -device virtio-net-device,netdev=usernet \
   -netdev user,id=usernet,hostfwd=tcp::10000-:22 \ 

I see in the slide to use the -d argument when launching the VM, but it does not seem to work. QEMU does not boot and it is hung on the loading stage itself. Is there something that I am missing? Or is there some other way in order to get the dynamic execution traces using QEMU? I do one other question here, but I cannot go past this. Any help would be appreciated. p.s. Let us just assume that I want to get the traces for a simple hello world C program.


Solution

  • The -D option takes a filename to write the traces to, and you have not provided it with one. The rest of your command line will then be being mis-interpreted, because -nographic is being taken as the filename.

    You should also note that debug tracing of cpu events like this will slow QEMU down a lot, so it will generally only be useful for testing relatively small bare-metal ELF binaries. Tracing, for example, a full Linux kernel boot, will take too long and produce too much trace output.