2016-08-25 31 views
2

由於沒有人幫助解答,因此這是一個追加到this問題的附加細節。我克隆了最新的QEMU回購協議,並遵循this教程爲arm-softmmu創建了一個Hello World程序。我使用幫助函數追蹤了TCG,而不是基本塊中的寄存器,但是我遇到了跟​​蹤功能,我想嘗試一下。在documentation之後,取消註釋跟蹤事件文件後,這是my/tmp/events文件。如何使用QEMU的簡單跟蹤後端?

exec_tb 
exec_tb_exit 

跟蹤事件文件中,除去禁止的關鍵字,以使跟蹤的部分是:

# TCG related tracing (mostly disabled by default) 
# cpu-exec.c 
exec_tb(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR 
exec_tb_nocache(void *tb, uintptr_t pc) "tb:%p pc=0x%"PRIxPTR 
exec_tb_exit(void *last_tb, unsigned int flags) "tb:%p flags=%x" 

這是我如何配置和運行QEMU的可執行文件:

./configure --target-list=arm-softmmu --enable-trace-backends=simple 

make 

./qemu-system-arm -trace events=/tmp/events -M versatilepb -m 256M -nographic -kernel ~/FileName.bin 

從arm-softmmu目錄中,我以這種方式運行簡單的跟蹤python腳本:

./scripts/simpletrace.py trace-events arm-softmmu/trace-*pid* | head 

我在這裏做錯了什麼嗎?因爲我絕對沒有收到任何信息。即使是跟蹤後的二進制文件也只是一小段(當然是亂碼)。我預計實際上會有足夠大的痕跡。

回答

-1

我看不出你在做什麼錯,但我可以提供一個最小的自包含的工作的例子,只是工作中的一個命令:https://github.com/cirosantilli/linux-kernel-module-cheat/tree/467923860b78bb5d0c787f1433682dfc9c83223a#count-instructions

一旦你做克隆:

./run -n -- -trace exec_tb,file=trace 
./qemu/scripts/simpletrace.py qemu/trace-events trace >trace.txt 
wc -l trace 

和你會看到痕跡。

對於ARM:

./run -a arm -- -trace exec_tb,file=trace 

也許這將讓你diff的什麼是錯的。

確切QEMU配置行Buildroot裏面所做的是:

./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 

上QEMU V2.7.0,以及完整的QEMU命令是:

./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' 

我還建議你開始沒有--enable-trace-backends,這導致更簡單的後端,只是吐出一些東西,並有很大的性能損失。也嘗試GDB QEMU,應該很容易找出缺少的東西。

更新2.11