gpt4 book ai didi

debugging - 如何手动插入 Bochs 内置调试​​器将停止的断点? INT3 不起作用

转载 作者:行者123 更新时间:2023-12-05 03:29:47 25 4
gpt4 key购买 nike

我正在使用 bochs 增强型调试器(bochs 带有 gui 的调试器),但它也在调试 BIOS 代码,这对我来说太复杂了。那么如何在代码开头手动设置断点呢?

我尝试了 int3 但它并没有就此停止。

最佳答案

The osdev wiki描述主要功能:

Magic Breakpoint

When you're using Bochs with the internal debugger, you can trigger the debugger via a facility called magic breakpoints. To trigger a breakpoint, you can insert xchg bx, bx (in GAS syntax, xchgw %bx, %bx) anywhere in the code and Bochs will trap into the debugger as soon as it executes it. On real hardware this has no effect as it merely replaces the BX register with itself.

You should put the following line in your Bochs configuration file to have it listen to magic breakpoints:

magic_break: enabled=1

大概 Bochs 不会捕获 int3,因为正常的访客代码可能正在使用它。 (例如,如果您使用 Bochs 来调试调试器或具有调试功能的内核,您需要了解 int3 在 guest 中的处理方式,而不是让 Bochs 吃掉它。)


显然还有一个 I/O debug-breakpoint使用 out 指令将两个字输出到特殊端口号 0x8A00 的机制,因此您可以让 Bochs 以这种方式中断而不使其在 xchg bx 上中断,bxxchg 方式绝对更易于使用(侵入性更小;无需寄存器设置即可插入 NOP)并且更紧凑。 OSdev.org 使用 C 来描述要输出的内容:

 //outputs a character to the debug console
#define BochsConsolePrintChar(c) outportb(0xe9, c)
//stops simulation and breaks into the debug console
#define BochsBreak() outportw(0x8A00,0x8A00); outportw(0x8A00,0x08AE0);

关于debugging - 如何手动插入 Bochs 内置调试​​器将停止的断点? INT3 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70955173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com