Удаленная отладка HiFive, развязанная в QEMU - PullRequest
1 голос
/ 20 января 2020

Я пытаюсь заставить удаленную отладку работать в QEMU для машины sifive_u. Все инструменты из репозиториев Arch Linux:

➜  qemu-system-riscv64 --version

QEMU emulator version 4.2.0
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers

➜  riscv64-linux-gnu-gdb --version
GNU gdb (GDB) 8.3.1
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Я запускаю машину следующим образом:

qemu-system-riscv64 -M sifive_u -m 256M -bios default -nographic -S -s

Когда я подключаю отладчик, я пытаюсь продолжить выполнение, но ничего не происходит; если я отсоединяю отладчик, OpenSBI spla sh печатает на последовательную консоль. Типичный gdb сеанс выглядит примерно так:

GNU gdb (GDB) 8.3.1
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=riscv64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target 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.
0x0000000000001000 in ?? ()
(gdb) info thread
  Id   Target Id                                            Frame
* 1    Thread 1.1 (sifive-e51-riscv-cpu harts[0] [running]) 0x0000000000001000 in ?? ()
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x0000000080005a52 in ?? ()
(gdb) info thread
  Id   Target Id                                            Frame
* 1    Thread 1.1 (sifive-e51-riscv-cpu harts[0] [halted ]) 0x0000000080005a52 in ?? ()
(gdb) detach
Detaching from program: , process 1
Ending remote debugging.
[Inferior 1 (process 1) detached]

Кажется странным, что я вижу только один поток в info thread; Я ожидаю увидеть по одному потоку на харта.

Я догадываюсь, что в итоге я привязан к харту, который проигрывает лотерею и засыпает, а для некоторых других хартов не разрешается продолжать выполнение. Если я использую машину virt, выполнение запускается, как и ожидалось, когда я запускаю continue, и я сразу вижу OpenSBI spla sh, так что, похоже, это каким-то образом связано с использованием sifive_u.

Кто-нибудь знает, что я делаю не так?

...