I can't spot what you are doing wrong, but I can provide a minimal self contained working example that just works in one command: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/467923860b78bb5d0c787f1433682dfc9c83223a#count-instructions
Once you clone do:
./run -n -- -trace exec_tb,file=trace
./qemu/scripts/simpletrace.py qemu/trace-events trace >trace.txt
wc -l trace
and you will see the traces.
For ARM:
./run -a arm -- -trace exec_tb,file=trace
Maybe this will allow you to diff out what is wrong.
The exact QEMU config line Buildroot did was:
./configure --target-list="arm-softmmu" --prefix="/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.arm~/hos
t/usr" --interp-prefix=/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.arm~/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot --cc="/usr/bin/gcc" --host-cc="/usr
/bin/gcc" --python=/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.arm~/host/usr/bin/python2 --extra-cflags="-O2 -I/home/ciro/bak/git/linux-kernel-module-cheat/bu
ildroot/output.arm~/host/usr/include" --extra-ldflags="-L/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.arm~/host/lib -L/home/ciro/bak/git/linux-kernel-module-ch
eat/buildroot/output.arm~/host/usr/lib -Wl,-rpath,/home/ciro/bak/git/linux-kernel-module-cheat/buildroot/output.arm~/host/usr/lib" --enable-debug --enable-sdl --extra-cflags='-
DDEBUG_PL061=1' --with-sdlabi=2.0
on QEMU v2.7.0, and the full QEMU command was:
./buildroot/output.x86_64~/host/usr/bin/qemu-system-x86_64 -m 128M -monitor telnet::45454,server,nowait -netdev user,hostfwd=tcp::45455-:45455,id=net0 -smp 1 -M pc -append 'root=/dev/vda nopat nokaslr norandmaps printk.devkmsg=on printk.time=y console=ttyS0 init=/poweroff.out' -device edu -device lkmc_pci_min -device virtio-net-pci,netdev=net0 -kernel ./buildroot/output.x86_64~/images/bzImage -nographic -trace exec_tb,file=trace -drive file='./buildroot/output.x86_64~/images/rootfs.ext2.qcow2,if=virtio,format=qcow2'
I also recommend that you start without --enable-trace-backends, which leads to the even simpler backend that just spits things to stdout, with a large performance penalty. Also try to GDB QEMU up, it should be easy to figure out what is missing.
Update 2.11
-d in_asm option
Edit: -d in_asm alone shows only translation chunks, so if a chunk gets executed multiple times, it won't show multiple times. There are some extra flags that make it more accurate, see: What instructions does qemu trace?
Since I found about this option, I have been using it to get instruction listings rather than the more complicated trace backend: Tracing/profiling instructions
I would expect performance to not be as good, but if it is good enough for you, as when I do baremetal / user mode simulation, go for it.