Qemu i VirtualBox nie posiadają debugera z prawdziwego zdarzenia
Do Qemu możesz podpiąć GDB (http://wiki.osdev.org/Qemu#GDB-stub). IMHO to bardzo wygodne rozwiązanie, lepsze niż w Bochs.
Do GDB mam mieszane uczucia, przykład:
Uruchamiam Qemu z parametrami "-s -S"
To jest mój plik .gdbinit
set arch i386:x86-64
target remote :1234
break *0x100147
set disassembly-flavor intel
continue
Uruchamiam GDB i co się okazuje:
GNU gdb (GDB) 7.9.1
Copyright (C) 2015 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 "x86_64-unknown-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".
0x0000fff0 in ?? ()
Breakpoint 1 at 0x100147
/root/.gdbinit:4: Error in sourced command file:
Remote 'g' packet reply is too long: 0000000000000000a08f12000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000047011000000000004600000008000000100000001000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f0000
(gdb)
Podobno popularny błąd przy debugowaniu binarek, którego rozwiązania nie idzie znaleźć...
Zdawało mi się, że mogę to zignorować i po prostu debugować dalej, więc wyświetliłem TUI dla rejestrów i disas.
┌──Register group: general────────────────────────────────────────────────┐
│eax 0x0 0 ecx 0x0 0 │
│edx 0x663 1635 ebx 0x0 0 │
│esp 0x0 0x0 ebp 0x0 0x0 │
│esi 0x0 0 edi 0x0 0 │
│eip 0xfff0 0xfff0 eflags 0x2 [ ] │
│cs 0xf000 61440 ss 0x0 0 │
│ds 0x0 0 es 0x0 0 │
│fs 0x0 0 gs 0x0 0 │
│ │
│ │
│ │
───────────────────────────────────────────────────────────────────────┘
>│0xfff0 add BYTE PTR [eax],al │
│0xfff2 add BYTE PTR [eax],al │
│0xfff4 add BYTE PTR [eax],al │
│0xfff6 add BYTE PTR [eax],al │
│0xfff8 add BYTE PTR [eax],al │
│0xfffa add BYTE PTR [eax],al │
│0xfffc add BYTE PTR [eax],al │
│0xfffe add BYTE PTR [eax],al │
│0x10000 add BYTE PTR [eax],al │
│0x10002 add BYTE PTR [eax],al │
│0x10004 add BYTE PTR [eax],al │
└──────────────────────────────────────────────────────────────────────┘
remote Thread 1 In: L?? PC: 0xfff0
000000000460000000800000010000000100000001000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
7f0300000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000801f0000
(gdb)
GDB nawet nie ruszył z miejsca. Sprawdzam co za "kura" zatrzymała mój kod.
(gdb) info threads
Id Target Id Frame
8 Thread 8 (CPU#7 [halted ]) (running)
7 Thread 7 (CPU#6 [halted ]) (running)
6 Thread 6 (CPU#5 [halted ]) (running)
5 Thread 5 (CPU#4 [halted ]) (running)
4 Thread 4 (CPU#3 [halted ]) (running)
3 Thread 3 (CPU#2 [halted ]) (running)
2 Thread 2 (CPU#1 [halted ]) (running)
* 1 Thread 1 (CPU#0 [running]) (running)
(gdb)
Sprawdzałem nawet nakładki do GDB, typu DDD... zawiesza się.
Dalej dałem sobie siana, i zostałem przy Bochs Enhanced Debugger.