Debugging the FreeDOS kernel (1) (附中文)

本文介绍了如何使用Bochs调试器作为调试FreeDOS内核的起点。详细步骤包括安装虚拟软盘、配置Bochs调试器、在特定地址设置断点等,以实现对引导代码的深入分析。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Debugging the FreeDOS kernel

 

Bochs debugger can be a very good first step to debug the kernel. For simplicity, the FreeDOS kernel can be installed on a virtual floppy disk, and Bochs can boot from it. On Windows, to launch the Bochs debugger, use bochsdbg.exe in the Bochs installation. It will automatically break into the virtual machine as soon as it is started.

Bochs 调试器可以作为调试内核的一个很好的开头。为了简单起见,FreeDOS 内核可以被安装在一个虚拟软盘之上。在 Windows 上,要启动 Bochs 调试器的话,使用安装好的目录中的 bochsdbg.exe。它会自动在虚拟机启动的当口将它立即中断下来。

In my installation, "C:\Program Files\Bochs-2.4.6\docs\user\internal-debugger.html" contains the debugger documentation. Optionally, gdb can be used together with bochs. Note that unlike DOS Debug/WinDBG, the Bochs debugger requires explicit "0x" prefix to represent a hexadecimal value.

在我的安装中,“C:\Program Files\Bochs-2.4.6\docs\user\internal-debugger.html”里面是调试器的文档。另一个选项是将 gdb 与 Bochs 一起使用。注意与 DOS 的 Debug 及 WinDBG 不同的是,Bochs 调试器要求十六进制数必须显式标明 0x 前缀。

Common debugger commands: x (examine memory at a linear address), xp (examine memory at a physical address), set (set register value), show (sets options for CPU mode change, interrupt, etc.), trace, u|disasm (disassemble - show assembly instruction in memory), record (record console output into a file), playback (read console input from a file), ldsym/slist (symbol-related).

常用的调试器命令:x(检查内存中某线性地址的内容),xp(检查某物理地址的内容),set(设置寄存器值),show(设置 CPU 模式改变选项、中断等等),trace(跟踪),u|disasm (反汇编——显示内存中的汇编指令),record(记录命令行输出到文件中),playback(从文件中读取命令行输入),ldsym/slist(调试符号相关)。

More: c|cont|continue (like g in DEBUG/WinDBG), s|step (like t in DEBUG/WinDBG), p|n||next (like p in DEBUG/WinDBG), vb/lb/pb (break at virtual/linear/physical address, like bp in WinDBG), blist|info break (lists breakpoints), bpe/bpd (enable/disable breakpoint, like be/bd in WinDBG), d|del|delete (like bd in WinDBG), watch (like data breakpoints in WinDBG), setpmem (sets memory value, like e in DEBUG/WinDBG), crc (computes CRC for a region), info (lists various status information), r|reg|regs|registers (like r in DEBUG/WinDBG), page (converts between linear/physical address), set (options for auto-displaying debugging information), ?|calc (calculates simple expressions).

更多:c|cont|continue(类似于 DEBUG/WinDBG 中的 g),s|step(类似于 DEBUG/WinDBG 中的 t),p|n|next(类似于 DEBUG/WinDBG 中的 p),vb/lb/pb(中断于 虚拟/线性/物理 地址,类似于 WinDBG 中的 bp),d|del|delete(like WinDBG 中的 bd),watch(类似于 WinDBG 中的数据断点),setpmem(设置内存值,类似于 WinDBG 中的 e),r|reg|regs|registers(类似于 DEBUG/WinDBG 中的 r),page(在 线性/物理 地址之间转换),set(自动显示调试信息的选项),?|calc(计算简单表达式)。

To debug boot code, set a break point at 0x7C00, because the boot sector of the floppy disk or the MBR is loaded by the BIOS at 0000:7C00. This is a standard of the IBM PC, not a standard in Intel processors.

要调试引导代码,在 0x7C00 处设置一个断点,因为软盘引导扇区或者主引导记录(MBR)会被 BIOS 加载在 0000:7C00 处。这是 IBM PC(个人电脑)的标准,并非 Intel 处理器的标准。

To break the virtual machine into the debugger at anytime, press Ctrl+C in the bochsdbg console window.

要想在虚拟机运行的时候,中断它并陷入调试器,在 bochsdbg 的命令行窗口按 Ctrl+C 键即可。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值