gdb, bochs, qemu weirdness
Posted: Thu May 13, 2010 3:02 am
I'm in the process of writing a boot loader and trying to get gdb to work with qemu or bochs. I can connect to either bochs or qemu without any problems, set a breakpoint at 0x7c00 and type continue in gdb to get things going. This is however where the weirdness starts. Qemu apparently ignores the breakpoint and executes everything until it reaches the "jmp $" instruction in my code (this is evident as qemu shows the message my loader outputs), the gdb however reports reaching a breakpoint at the 0x7c00 memory address. Consequent stepi command in gcc breaks at the address of "jmp $". With bochs, on the other hand, setting a breakpoint at 0x7c00 results in bochs and gdb reporting a break at 0xe0000 while the emulator seems to break at 0x7c00 (or at least before my program prints anything). Consequent stepi in gdb breaks at the same location, while "continue" works as expected. Does anyone have any idea what the hell is going on?
also, here's the output of bochs just in case:
also, here's the output of bochs just in case:
Code: Select all
00000000000i[ ] lt_dlhandle is 0x376b530
00000000000i[PLGIN] loaded plugin libbx_sdl.so
00000000000i[ ] installing sdl module as the Bochs GUI
00000000000i[ ] Bochs x86 Emulator 2.4.2
00000000000i[ ] Build from CVS snapshot on November 12, 2009
00000000000i[ ] System configuration
00000000000i[ ] processors: 1 (cores=1, HT threads=1)
00000000000i[ ] A20 line support: yes
00000000000i[ ] CPU configuration
00000000000i[ ] level: 6
00000000000i[ ] SMP support: no
00000000000i[ ] APIC support: yes
00000000000i[ ] FPU support: yes
00000000000i[ ] MMX support: yes
00000000000i[ ] SSE support: 4E
00000000000i[ ] CLFLUSH support: yes
00000000000i[ ] 3dnow! support: yes
00000000000i[ ] 1G paging support: no
00000000000i[ ] x86-64 support: yes
00000000000i[ ] SEP support: yes
00000000000i[ ] MWAIT support: no
00000000000i[ ] XSAVE support: yes
00000000000i[ ] AES support: no
00000000000i[ ] VMX support: no
00000000000i[ ] Optimization configuration
00000000000i[ ] RepeatSpeedups support: yes
00000000000i[ ] Trace cache support: yes
00000000000i[ ] Fast function calls: yes
00000000000i[ ] Devices configuration
00000000000i[ ] ACPI support: yes
00000000000i[ ] NE2000 support: yes
00000000000i[ ] PCI support: yes, enabled=yes
00000000000i[ ] SB16 support: yes
00000000000i[ ] USB support: yes
00000000000i[ ] VGA extension support: vbe
00000000000i[MEM0 ] allocated memory at 0x7f49cade8010. after alignment, vector=0x7f49cade9000
00000000000i[MEM0 ] 32,00MB
00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/share/bochs/BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/38400 ('/usr/share/bochs/VGABIOS-lgpl-latest')
00000000000i[ ] lt_dlhandle is 0x37d2b30
00000000000i[PLGIN] loaded plugin libbx_cmos.so
00000000000i[ ] lt_dlhandle is 0x37d3530
00000000000i[PLGIN] loaded plugin libbx_dma.so
00000000000i[ ] lt_dlhandle is 0x37d3f70
00000000000i[PLGIN] loaded plugin libbx_pic.so
00000000000i[ ] lt_dlhandle is 0x37d47b0
00000000000i[PLGIN] loaded plugin libbx_pit.so
00000000000i[ ] lt_dlhandle is 0x37d5100
00000000000i[PLGIN] loaded plugin libbx_vga.so
00000000000i[ ] lt_dlhandle is 0x37d5830
00000000000i[PLGIN] loaded plugin libbx_floppy.so
00000000000i[ ] lt_dlhandle is 0x37d6450
00000000000i[PLGIN] loaded plugin libbx_pci.so
00000000000i[ ] lt_dlhandle is 0x37d6fd0
00000000000i[PLGIN] loaded plugin libbx_pci2isa.so
00000000000i[ ] lt_dlhandle is 0x37d7910
00000000000i[PLGIN] loaded plugin libbx_unmapped.so
00000000000i[ ] lt_dlhandle is 0x37d80d0
00000000000i[PLGIN] loaded plugin libbx_biosdev.so
00000000000i[ ] lt_dlhandle is 0x37d8b10
00000000000i[PLGIN] loaded plugin libbx_speaker.so
00000000000i[ ] lt_dlhandle is 0x37d92a0
00000000000i[PLGIN] loaded plugin libbx_extfpuirq.so
00000000000i[ ] lt_dlhandle is 0x37d9b10
00000000000i[PLGIN] loaded plugin libbx_gameport.so
00000000000i[ ] lt_dlhandle is 0x37da480
00000000000i[PLGIN] loaded plugin libbx_pci_ide.so
00000000000i[ ] lt_dlhandle is 0x37daed0
00000000000i[PLGIN] loaded plugin libbx_acpi.so
00000000000i[ ] lt_dlhandle is 0x37db7d0
00000000000i[PLGIN] loaded plugin libbx_ioapic.so
00000000000i[ ] lt_dlhandle is 0x37dc090
00000000000i[PLGIN] loaded plugin libbx_keyboard.so
00000000000i[ ] lt_dlhandle is 0x37dc8e0
00000000000i[PLGIN] loaded plugin libbx_harddrv.so
00000000000i[ ] lt_dlhandle is 0x37ee9a0
00000000000i[PLGIN] loaded plugin libbx_serial.so
00000000000i[ ] lt_dlhandle is 0x37ef850
00000000000i[PLGIN] loaded plugin libbx_parallel.so
00000000000i[CMOS ] Using local time for initial clock
00000000000i[CMOS ] Setting initial clock to: Thu May 13 11:38:14 2010 (time0=1273739894)
00000000000i[DMA ] channel 4 used by cascade
00000000000i[DMA ] channel 2 used by Floppy Drive
00000000000i[PCI ] 440FX Host bridge present at device 0, function 0
00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
00000000000i[VGA ] interval=50000
00000000000i[MEM0 ] Register memory access handlers: 0x000a0000 - 0x000bffff
00000000000i[MEM0 ] Register memory access handlers: 0xe0000000 - 0xe0ffffff
00000000000i[VGA ] VBE Bochs Display Extension Enabled
00000000000i[PLGIN] init_dev of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'speaker' plugin device by virtual method
00000000000i[SPEAK] Failed to open /dev/console: Ресурс временно недоступен
00000000000i[SPEAK] Deactivating beep on console
00000000000i[PLGIN] init_dev of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'gameport' plugin device by virtual method
00000000000i[PLGIN] init_dev of 'pci_ide' plugin device by virtual method
00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1
00000000000i[PLGIN] init_dev of 'acpi' plugin device by virtual method
00000000000i[PCI ] ACPI Controller present at device 1, function 3
00000000000i[PLGIN] init_dev of 'ioapic' plugin device by virtual method
00000000000i[IOAP ] initializing I/O APIC
00000000000i[MEM0 ] Register memory access handlers: 0xfec00000 - 0xfec00fff
00000000000i[PLGIN] init_dev of 'keyboard' plugin device by virtual method
00000000000i[KBD ] will paste characters every 1000 keyboard ticks
00000000000i[PLGIN] init_dev of 'harddrv' plugin device by virtual method
00000000000i[HD ] HD on ata0-0: 'c.img' 'flat' mode
00000000000i[HD ] ata0-0: autodetect geometry: CHS=20/16/63
00000000000i[HD ] translation on ata0-0 set to 'none'
00000000000i[HD ] Using boot sequence disk, none, none
00000000000i[HD ] Floppy boot signature check is enabled
00000000000i[PLGIN] init_dev of 'serial' plugin device by virtual method
00000000000i[SER ] com1 at 0x03f8 irq 4
00000000000i[PLGIN] init_dev of 'parallel' plugin device by virtual method
00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
00000000000i[PLGIN] register state of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] register state of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] register state of 'speaker' plugin device by virtual method
00000000000i[PLGIN] register state of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] register state of 'gameport' plugin device by virtual method
00000000000i[PLGIN] register state of 'pci_ide' plugin device by virtual method
00000000000i[PLGIN] register state of 'acpi' plugin device by virtual method
00000000000i[PLGIN] register state of 'ioapic' plugin device by virtual method
00000000000i[PLGIN] register state of 'keyboard' plugin device by virtual method
00000000000i[PLGIN] register state of 'harddrv' plugin device by virtual method
00000000000i[PLGIN] register state of 'serial' plugin device by virtual method
00000000000i[PLGIN] register state of 'parallel' plugin device by virtual method
00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00000000000i[CPU0 ] cpu hardware reset
00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0xfee00000
00000000000i[PLGIN] reset of 'unmapped' plugin device by virtual method
00000000000i[PLGIN] reset of 'biosdev' plugin device by virtual method
00000000000i[PLGIN] reset of 'speaker' plugin device by virtual method
00000000000i[PLGIN] reset of 'extfpuirq' plugin device by virtual method
00000000000i[PLGIN] reset of 'gameport' plugin device by virtual method
00000000000i[PLGIN] reset of 'pci_ide' plugin device by virtual method
00000000000i[PLGIN] reset of 'acpi' plugin device by virtual method
00000000000i[PLGIN] reset of 'ioapic' plugin device by virtual method
00000000000i[PLGIN] reset of 'keyboard' plugin device by virtual method
00000000000i[PLGIN] reset of 'harddrv' plugin device by virtual method
00000000000i[PLGIN] reset of 'serial' plugin device by virtual method
00000000000i[PLGIN] reset of 'parallel' plugin device by virtual method
Waiting for gdb connection on port 1234
Connected to 127.0.0.1
00000000000i[GDBST] addr 0 len 1
00000000000i[GDBST] addr 0 len 8
00000000000i[GDBST] addr 0 len 7
00000000000i[GDBST] addr 7c00 len 1
00000000000i[GDBST] setting breakpoint at 7c00
00000003305i[BIOS ] $Revision: 1.235 $ $Date: 2009/09/28 16:36:02 $
00000318060i[KBD ] reset-disable command received
00000436192i[VBIOS] VGABios $Id$
00000436263i[VGA ] VBE known Display Interface b0c0
00000436295i[VGA ] VBE known Display Interface b0c4
00000436964i[VBIOS] VBE Bios $Id$
00000748317i[BIOS ] Starting rombios32
00000748774i[BIOS ] Shutdown flag 0
00000749397i[BIOS ] ram_size=0x02000000
00000749846i[BIOS ] ram_end=32MB
00000790420i[BIOS ] Found 1 cpu(s)
00000806435i[BIOS ] bios_table_addr: 0x000fba98 end=0x000fcc00
00000806543i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001134237i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001462167i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b
00001462188i[P2I ] PCI IRQ routing: PIRQB# set to 0x09
00001462209i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b
00001462230i[P2I ] PCI IRQ routing: PIRQD# set to 0x09
00001462240i[P2I ] write: ELCR2 = 0x0a
00001463050i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
00001470814i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
00001473187i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
00001475399i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
00001475634i[PIDE ] new BM-DMA address: 0xc000
00001476289i[BIOS ] region 4: 0x0000c000
00001478410i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
00001478653i[ACPI ] new irq line = 11
00001478665i[ACPI ] new irq line = 9
00001478696i[ACPI ] new PM base address: 0xb000
00001478710i[ACPI ] new SM base address: 0xb100
00001478738i[PCI ] setting SMRAM control register to 0x4a
00001642829i[CPU0 ] Enter to System Management Mode
00001642839i[CPU0 ] RSM: Resuming from System Management Mode
00001806857i[PCI ] setting SMRAM control register to 0x0a
00001815654i[BIOS ] MP table addr=0x000fbb70 MPC table addr=0x000fbaa0 size=0xd0
00001817404i[BIOS ] SMBIOS table addr=0x000fbb80
00001820439i[BIOS ] Firmware waking vector 0x1ff00cc
00001861335i[BIOS ] ACPI tables: RSDP addr=0x000fbc90 ACPI DATA addr=0x01ff0000 size=0x1f18
00001861372i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
00001862124i[BIOS ] bios_table_cur_addr: 0x000fbcb4
00001874441i[BIOS ] ata0-0: PCHS=20/16/63 translation=none LCHS=20/16/63
00005754669i[BIOS ] IDE time out
00017824990i[BIOS ] Booting from 0000:7c00
00017825051i[GDBST] found breakpoint at 7c00
00017825051i[GDBST] stopped with ac1
00017825051i[GDBST] Removing breakpoint at 7c00
00017825051i[GDBST] addr e0000 len 1
00017825051i[GDBST] addr e0000 len 8
00017825051i[GDBST] addr e0000 len 7
00017825051i[GDBST] setting breakpoint at 7c00
00017825051i[GDBST] stepping
00017825052i[GDBST] stopped with ac2
00017825052i[GDBST] addr e0000 len 1
00017825052i[GDBST] addr e0000 len 8
00017825052i[GDBST] addr e0000 len 7
00017825052i[GDBST] Removing breakpoint at 7c00