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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Princekin
Posts: 15
Joined: Mon Jul 05, 2021 7:05 am

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

Post 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!
Princekin
Posts: 15
Joined: Mon Jul 05, 2021 7:05 am

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

Post 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?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.
Post Reply