本文介绍了如何做到86 code源代码级调试,里面QEMU GDB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了MBR部分中的x86汇编程序。
我编译如下:
I wrote a x86 assembly program for MBR section.I compile it as follows:
nasm hellombr.asm -f bin -o hellombr.img
然后我在qemu的运行它:
Then I run it in qemu:
qemu -fda hellombr.img -boot a
问题是我如何调试我的程序在源代码级?
The question is how can I debug my program at source level?
推荐答案
您应该让 NASM
在ELF文件中创建调试符号,然后转储这平坦的二进制在MBR中使用。然后,您可以指示GDB从ELF文件中读取所需的符号。
You should let nasm
create the debugging symbols in an ELF file and then dump this to a flat binary to be used in the MBR. You can then instruct GDB to read the necessary symbols from the ELF file.
然后将整个过程将变得像这样:
The complete procedure would then become something like this:
$ nasm hellombr.asm -f elf -g -o hellombr.elf
$ objcopy -O binary hellombr.elf hellombr.img
$ qemu -s -S -fda hellombr.img -boot a
$ gdb
(gdb) symbol-file hellombr.elf
(gdb) target remote localhost:1234
有关我传递给 QEMU
看this的回答。
For an explanation of the flags I pass to qemu
see this answer.
这篇关于如何做到86 code源代码级调试,里面QEMU GDB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!