.ASM文件调试工具

发布于 2025-01-03 14:10:53 字数 353 浏览 1 评论 0原文

我想知道我可以将哪种调试工具用于汇编程序以及如何使用它。

我用汇编编写了一个简单的引导加载程序。然而,尽管我认为逻辑是正确的,但它并没有完全按照我的意愿正常工作。所以,我尝试使用调试器,以便我可以单步执行引导加载程序,检查寄存器状态等。

我在 Ubuntu 上尝试了 GDB,将 .asm 编译为 .elf 和 .o (我需要这样做吗?如果是的,下一步是什么?)另外,我读到 Bochs 模拟器中有一个内部调试器,但我找不到任何如何使用它的文档。我也有 Visual Studio 2010、windbg,但我不知道如何使用它进行 .asm 文件调试。

如果您以前这样做过,那么这将是一个简单的答案。任何帮助将不胜感激。

真挚地

I am wondering which debugging tool I can use for an assembly program and how to use it.

I have written a simple bootloader in assembly. However, it is not quite working properly as I wished, even though I think the logic is correct. So, I am trying to use a debugger so that I can step through the bootloader, checking the register status and etc.

I tried GDB on Ubuntu, compiling my .asm to .elf and .o (Do I need to do it? If yes, what is the next step?) Also, I read that there is an internal debugger in Bochs simulator, but I can't quite find any document how to use it. I also have Visual Studio 2010, windbg, but I don't know how to use it for .asm file debugging.

If you have done this before, it would be an easy answer. Any help would be really appreciated.

Sincerely

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

卸妝后依然美 2025-01-10 14:10:53

如果您想调试引导加载程序代码,显然需要在代码本身将要运行的环境中运行它。我相信您已经知道,一旦 BIOS 完成以下操作,引导加载程序代码就会在实模式下执行邮政。然后引导加载程序被加载到 7c00h 处的内存中,并执行到该地址的跳转。

显然,一旦你的计算机开始运行并且已经加载了“真正的”操作系统,就无法可靠地模拟这种环境,因为那时你的 CPU 处于保护模式(或长模式,如果是 AMD64)。此时您唯一的选择是使用 QEMUBochs,以便在操作系统中模拟真实的 PC。我使用 Bochs 来调试我过去编写的一些引导加载程序代码,并且效果很好。查看手册页以获取更详细的说明。

If you want to debug bootloader code, you obviously need to run it in the same environment that the code itself is going to run in. As I'm sure you already know, bootloader code is executed in real mode once the BIOS finishes doing the POST. The bootloader is then loaded into memory at 7c00h and a jump to that address is executed.

Obviously, this kind of environment cannot be reliably emulated once you've got your computer running and a "real" operating system already loaded, since by that time your CPU is in protected mode (or long mode, if it's AMD64). Your only option at this point is to use QEMU or Bochs in order to emulate a real PC inside your operating system. I've used Bochs to debug some bootloader code I've written in the past and it worked quite well. Check the manual pages for more detailed instructions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文