QEMU+GDBマルチプロセス
前回の続き
前回、単純にやるとGDBからはCortex-A72しか見ることができず、実行もできない。
次のページを"Cortex-R5"で検索すると
"Debugging Multiple Processes"に必要なことが書いてあった。Cortex 実行してみる。
QEMUの方は前回の記事と同様-s -Sをつけて実行して待つ。実行前のレジスタ状態は以下
(qemu) cpu 2
(qemu) info registers
R00=00000000 R01=00000000 R02=00000000 R03=00000000
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000000 R14=00000000 R15=0000003c
PSR=400001d3 -Z-- A svc32
s00=00000000 s01=00000000 d00=0000000000000000
s02=00000000 s03=00000000 d01=0000000000000000
s04=00000000 s05=00000000 d02=0000000000000000
s06=00000000 s07=00000000 d03=0000000000000000
s08=00000000 s09=00000000 d04=0000000000000000
s10=00000000 s11=00000000 d05=0000000000000000
s12=00000000 s13=00000000 d06=0000000000000000
s14=00000000 s15=00000000 d07=0000000000000000
s16=00000000 s17=00000000 d08=0000000000000000
s18=00000000 s19=00000000 d09=0000000000000000
s20=00000000 s21=00000000 d10=0000000000000000
s22=00000000 s23=00000000 d11=0000000000000000
s24=00000000 s25=00000000 d12=0000000000000000
s26=00000000 s27=00000000 d13=0000000000000000
s28=00000000 s29=00000000 d14=0000000000000000
s30=00000000 s31=00000000 d15=0000000000000000
FPSCR: 00000000
GDBでは、
(gdb) target extended-remote :1234
Remote debugging using :1234
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
0x0000000000000000 in ?? ()
(gdb) info threads
Id Target Id Frame
* 1 Thread 1.1 (Cortex-A72 #0 [running]) 0x0000000000000000 in ?? ()
2 Thread 1.2 (Cortex-A72 #1 [running]) 0x0000000000000000 in ?? ()
(gdb) add-inferior
[New inferior 2]
Added inferior 2 on connection 1 (extended-remote :1234)
(gdb) info inferiors
Num Description Connection Executable
* 1 process 1 1 (extended-remote :1234)
2 <null> 1 (extended-remote :1234)
(gdb) inferior 2
[Switching to inferior 2 [<null>] (<noexec>)]
(gdb) attach 2
Attaching to process 2
warning: No executable has been specified and target does not support
determining executable automatically. Try using the "file" command.
[New Thread 2.4]
0x0000003c in ?? ()
(gdb) info threads
Id Target Id Frame
1.1 Thread 1.1 (Cortex-A72 #0 [running]) 0x0000000000000000 in ?? ()
1.2 Thread 1.2 (Cortex-A72 #1 [running]) 0x0000000000000000 in ?? ()
* 2.1 Thread 2.3 (Cortex-R5 #0 [running]) 0x0000003c in ?? ()
2.2 Thread 2.4 (Cortex-R5 #1 [running]) 0x00000000 in ?? ()
というわけで、inferiorでprocess 2をアタッチすることで、R5も見えることが確認できた。
後は、ちょうど Cortex-R5(Thread 2.1)が選ばれているので、プログラムが実行できる。
(gdb) c
Continuing.
変わらず戻ってこないが、qemu側ではHello Worldが出力されている。
(qemu) Hello WorldHello Test Passed
Successfully ran UartPsv Hello World Example
レジスタ状態は以下のように変化
(qemu) info registers
R00=0000000b R01=00000000 R02=ff000018 R03=00000000
R04=0000000b R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00046978 R14=00041b15 R15=00041af0
PSR=600000df -ZC- A sys32
s00=00000000 s01=00000000 d00=0000000000000000
s02=00000000 s03=00000000 d01=0000000000000000
s04=00000000 s05=00000000 d02=0000000000000000
s06=00000000 s07=00000000 d03=0000000000000000
s08=00000000 s09=00000000 d04=0000000000000000
s10=00000000 s11=00000000 d05=0000000000000000
s12=00000000 s13=00000000 d06=0000000000000000
s14=00000000 s15=00000000 d07=0000000000000000
s16=00000000 s17=00000000 d08=0000000000000000
s18=00000000 s19=00000000 d09=0000000000000000
s20=00000000 s21=00000000 d10=0000000000000000
s22=00000000 s23=00000000 d11=0000000000000000
s24=00000000 s25=00000000 d12=0000000000000000
s26=00000000 s27=00000000 d13=0000000000000000
s28=00000000 s29=00000000 d14=0000000000000000
s30=00000000 s31=00000000 d15=0000000000000000
FPSCR: 00000000