0
|
1 # QEMU
|
|
2
|
|
3 - What is QEMU?
|
|
4
|
|
5 > QEMU is a generic and open source machine emulator and virtualizer.
|
|
6
|
|
7 - qemu
|
|
8
|
|
9 https://www.qemu.org/
|
|
10
|
|
11 ## debug buildの参考になりそう
|
|
12
|
|
13 - brewでのビルド設定
|
|
14 - `$brew cat qemu`
|
|
15
|
|
16 - 検索したら出てきたweb page
|
|
17 - https://www.cnblogs.com/root-wang/p/8005212.html
|
|
18
|
|
19 ## mac osでのビルド時に必要になりそうなパッケージ
|
|
20 ```
|
|
21 "libtool" => :build
|
|
22 "pkg-config" => :build
|
|
23 "glib"
|
|
24 "gnutls"
|
|
25 "jpeg"
|
|
26 "libpng"
|
|
27 "libssh2"
|
|
28 "libusb"
|
|
29 "ncurses"
|
|
30 "pixman"
|
|
31 "vde"
|
|
32 ```
|
|
33
|
|
34 ## linuxでのdebug build
|
|
35
|
|
36 - https://www.cnblogs.com/root-wang/p/8005212.html が参考になりそう
|
|
37
|
|
38 ```
|
|
39 ./configure --target-list=i386-softmmu,x86_64-softmmu,arm-softmmu,arm-linux-user --enable-kvm --enable-debug --prefix=$HOME/build/qemu
|
|
40 ```
|
|
41
|
|
42 ## debug時のおすすめ
|
|
43
|
|
44 (gdb) b disas_arm_insn
|
|
45 Breakpoint 2 at 0x555555691c55: file /home/syster_clown/src/qemu-4.0.0/target/arm/translate.c, line 9180.
|
|
46 (gdb) r
|
|
47 Starting program: /home/syster_clown/build/qemu/bin/qemu-arm ../localhost/sample-32
|
|
48 [Thread debugging using libthread_db enabled]
|
|
49 Using host libthread_db library "/lib64/libthread_db.so.1".
|
|
50 [New Thread 0x7ffff7acf700 (LWP 1981)]
|
|
51 Thread 1 "qemu-arm" hit Breakpoint 2, disas_arm_insn (s=0x7fffffffd3e0, insn=3852271616)
|
|
52 at /home/syster_clown/src/qemu-4.0.0/target/arm/translate.c:9180
|
|
53 9180 if (arm_dc_feature(s, ARM_FEATURE_M)) {
|
|
54 (gdb) bt
|
|
55 #0 disas_arm_insn (s=0x7fffffffd3e0, insn=3852271616) at /home/syster_clown/src/qemu-4.0.0/target/arm/translate.c:9180
|
|
56 #1 0x000055555569cc7b in arm_tr_translate_insn (dcbase=0x7fffffffd3e0, cpu=0x555557a94f30)
|
|
57 at /home/syster_clown/src/qemu-4.0.0/target/arm/translate.c:13483
|
|
58 #2 0x00005555556200eb in translator_loop (ops=0x5555559d8ba0 <arm_translator_ops>, db=0x7fffffffd3e0, cpu=0x555557a94f30,
|
|
59 tb=0x555555a77040 <static_code_gen_buffer+2272>) at /home/syster_clown/src/qemu-4.0.0/accel/tcg/translator.c:107
|
|
60 #3 0x000055555569d3e4 in gen_intermediate_code (cpu=0x555557a94f30, tb=0x555555a77040 <static_code_gen_buffer+2272>)
|
|
61 at /home/syster_clown/src/qemu-4.0.0/target/arm/translate.c:13772
|
|
62 #4 0x000055555561e699 in tb_gen_code (cpu=0x555557a94f30, pc=415056, cs_base=0, flags=128, cflags=-16777216)
|
|
63 at /home/syster_clown/src/qemu-4.0.0/accel/tcg/translate-all.c:1723
|
|
64 #5 0x000055555561bbbe in tb_find (cpu=0x555557a94f30, last_tb=0x0, tb_exit=0, cf_mask=0)
|
|
65 at /home/syster_clown/src/qemu-4.0.0/accel/tcg/cpu-exec.c:407
|
|
66 #6 0x000055555561c328 in cpu_exec (cpu=0x555557a94f30) at /home/syster_clown/src/qemu-4.0.0/accel/tcg/cpu-exec.c:728
|
|
67 #7 0x000055555565bcf6 in cpu_loop (env=0x555557a9d1f0) at /home/syster_clown/src/qemu-4.0.0/linux-user/arm/cpu_loop.c:218
|
|
68 #8 0x000055555562a725 in main (argc=2, argv=0x7fffffffdea8, envp=0x7fffffffdec0)
|
|
69 at /home/syster_clown/src/qemu-4.0.0/linux-user/main.c:819
|
|
70
|
|
71 ## qemu よみ
|
|
72
|
|
73 - armの命令のエミュレータを読むには qemu-arm をトレースしていく
|
|
74 - 内部で中間表現を生成している
|
|
75 - 中間形式はTCG(Tiny Code Generator )と呼ばれる
|