Page 1 of 1

why use qemu '-kernel' option can't hit '0x7c00' breakpoint

Posted: Sat Aug 13, 2022 8:10 am
by Princekin
env:
qemu-system-i386
QEMU emulator version 7.0.0
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

hi:
I use "qemu-system-i386 -kernel Prekernel" to run my kernel and then I use lldb to debug it, I add '0x7c00' breakpoint, then I run 'c' in lldb,it was not hit the '0x7c00' breakpiont, but if I use qemu '-cdrom' option, it can hit '0x7c00' breakpoint! I don't know why, it confuse me! any help is greatly appreciated!

Re: why use qemu '-kernel' option can't hit '0x7c00' breakpo

Posted: Sat Aug 13, 2022 8:44 am
by Princekin
qemu-system-i386 -help


Linux/Multiboot boot specific:
-kernel bzImage use 'bzImage' as kernel image


https://qemu-project.gitlab.io/qemu/sys ... xboot.html

what is qemu Direct Linux Boot process?

Re: why use qemu '-kernel' option can't hit '0x7c00' breakpo

Posted: Sat Aug 13, 2022 1:26 pm
by Octocontrabass
Princekin wrote:I use "qemu-system-i386 -kernel Prekernel" to run my kernel and then I use lldb to debug it, I add '0x7c00' breakpoint, then I run 'c' in lldb,it was not hit the '0x7c00' breakpiont, but if I use qemu '-cdrom' option, it can hit '0x7c00' breakpoint! I don't know why, it confuse me! any help is greatly appreciated!
When booting from CD, the bootloader starts executing at 0x7C00, so you hit the breakpoint at the start of the bootloader. When booting using QEMU's "-kernel" option, there is no bootloader at 0x7C00, so you don't hit the breakpoint.

If you want to debug your kernel, set a breakpoint in your kernel instead of in your bootloader.