在 qemu 中使用 gdb 调试引导加载程序 [英] Debugging bootloader with gdb in qemu

查看:23
本文介绍了在 qemu 中使用 gdb 调试引导加载程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Freedos 引导加载程序似乎存在问题.(在某些情况下,引导代码似乎找不到内核.)

There seems to be a problem with the Freedos bootloader. (It appears that the bootcode can't find the kernel in certain circumstances.)

所以我正在尝试使用 gdb 调试 qemu 中的引导加载程序.按照在几个 wiki 和免费在线课程资料上找到的说明,我像这样运行 qemu

So I'm trying to debug the bootloader in qemu with gdb. Following the instructions found on several wiki and freely available online course materials, I run qemu like this

qemu-system-i386 -fda fdboot.img -boot a -s -S

然后像这样连接gdb

$ gdb
(gdb) target remote localhost:1234

我可以使用我认为是 SeaBIOS 的 si 逐步完成前 10 到 12 条指令.

I can step through the first 10 - 12 instructions with si which I assume is the SeaBIOS.

但除此之外,当我尝试进入引导加载程序代码时,它会继续执行而不会中断,一直到 FreeDos 菜单提示.这完全跳过了我想在执行时逐步检查的引导加载程序代码.

But past that, when I try to step into bootloader code, it continues execution without breaking, all the way up to the FreeDos menu prompt. This totally skips the bootloader code which I would like to examine step by step as it is executed.

我需要做什么才能逐步通过引导加载程序?

What do I need to do so that I can step though the bootloader?

[如果你想自己尝试,可以从项目网站下载freedos软盘镜像.]

[You can download the freedos floppy images from the project website if you want to try yourself.]

推荐答案

在这里使用 qemu 1.3 和 gdb 7.3.50.20111117 工作正常(你没有说你使用的是什么版本).我能够单步执行大量指令,直到我感到无聊并放置一个断点来捕获引导加载程序:

Works fine here using qemu 1.3 and gdb 7.3.50.20111117 (you didn't say what versions you used). I was able to single step tons of instructions until I got bored and placed a breakpoint to catch the bootloader:

(gdb) br *0x7c00
Breakpoint 1 at 0x7c00
(gdb) c
Continuing.

Breakpoint 1, 0x00007c00 in ?? ()
(gdb) x/i $eip
=> 0x7c00:      jmp    0x7c3e

请注意,我首先使用 set architecture i8086 将 gdb 设置为 16 位模式.

Note that I have set gdb to 16 bit mode first using set architecture i8086.

这篇关于在 qemu 中使用 gdb 调试引导加载程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆