我如何使用LLDB在Apple Silicon Mac上在Qemu上调试RAW I386 MBR二进制运行?

发布于 2025-01-25 01:12:47 字数 1008 浏览 3 评论 0原文

我正在使用i386引导加载程序,并且在我的Apple Silicon机器上使用Qemu运行它,一切正常,除了我无法调试:GDB(尚未?加载原始二进制。这始于很好:

$ qemu-system-i386 -s -S -drive format=raw,file=boot.bin,media=disk,if=floppy -no-fd-bootchk

但是这是错误的:

$ lldb boot.bin
(lldb) target create "boot.bin"
error: '/Users/morpheu5/src/boots/cube/boot.bin' doesn't contain the architecture x86_64

我也尝试过,因为它应该是i386,而不是x86_64:

$ lldb --arch i386 boot.bin
(lldb) target create --arch=i386 "boot.bin"
error: '/Users/morpheu5/src/boots/cube/boot.bin' doesn't contain the architecture i386

但这并没有太大的不同。内联帮助并没有很大的帮助,我在网上搜索的成功零。

现在,我有替代方案:Bochs具有内部调试器,但是基于文本的接口有点笨拙,我什至无法弄清楚如何预设某些断点 - 我喜欢在0x7C00上进行中断或否则我必须踩踏通过整个BIOS代码 - 尽管将其配置为display_library:sdl2,options = gui_debug,但我什至无法运行GUI调试器。另一种选择是我可以使用GDB的覆盆子Pi,但我还没有尝试过,它是零,所以它甚至不是那么强大 - 不是我需要它,但我宁愿保持工作流程。顺利...

很明显,LLDB并没有识别二进制的格式,因此我想知道是否有一种要求它将其拆卸为32位二进制文​​件,而只用它滚动它。最后,我真正需要的只是一种查看内存,寄存器和堆栈中的内容的方法。

有什么想法吗?

I'm working on an i386 bootloader and I'm running it with QEMU on my Apple Silicon machine, and everything works just fine, except I can't debug it: GDB does not (yet?) work on AS and LLDB sternly refuses to load a raw binary. This starts up fine:

$ qemu-system-i386 -s -S -drive format=raw,file=boot.bin,media=disk,if=floppy -no-fd-bootchk

but this errors out:

$ lldb boot.bin
(lldb) target create "boot.bin"
error: '/Users/morpheu5/src/boots/cube/boot.bin' doesn't contain the architecture x86_64

and I also tried this, because well, it's supposed to be i386, not x86_64:

$ lldb --arch i386 boot.bin
(lldb) target create --arch=i386 "boot.bin"
error: '/Users/morpheu5/src/boots/cube/boot.bin' doesn't contain the architecture i386

but it didn't make much of a difference. The inline help is not greatly helpful and I am having zero success searching online.

Now, I have alternatives: bochs has an internal debugger but the text-based interface is a bit clunky and I can't even figure out how to pre-set certain breakpoints -- I like to break on 0x7c00 or otherwise I have to step through the entire BIOS code -- and I can't even run the gui debugger despite having configured it with display_library: sdl2, options=gui_debug. The other alternative is a Raspberry Pi in which I could probably use gdb but I haven't tried this out yet and it's a Zero so it's not even that powerful anyway -- not that I need it, but I'd rather keep my workflow smooth...

It seems clear that lldb isn't recognizing the binary's format so I'm wondering if there's a way of just asking it to disassemble it as a 32 bit binary and just roll with it the best it can. In the end, all I really need is a way of seeing what is in memory, in the registers, and in the stack.

Any ideas?

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

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

发布评论

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

评论(2

故事与诗 2025-02-01 01:12:47

经过几周的实验,看起来LLDB是一个可行的选择,但是Bochs的命令行调试器有些有用。遗憾的是,我无法让GUI在MacOS上运行。

After a few weeks of experimentation, it doesn't look like lldb is a viable option, but Bochs' command-line debugger was somewhat useful. Shame I couldn't get the GUI to run on macOS.

写下不归期 2025-02-01 01:12:47
brew install x86_64-elf-gdb
qemu-system-i386 -s -S result.bin
x86_64-elf-gdb -ex "target remote localhost:1234" -ex "set architecture i8086" -ex "set disassembly-flavor intel" ····

这对我有用,但这不使用LLDB。

brew install x86_64-elf-gdb
qemu-system-i386 -s -S result.bin
x86_64-elf-gdb -ex "target remote localhost:1234" -ex "set architecture i8086" -ex "set disassembly-flavor intel" ····

this works for me, but this don't use lldb.

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