-g 不包含调试信息

发布于 2024-10-02 05:59:50 字数 854 浏览 9 评论 0原文

目前正在尝试使用 KDbg / gdb 调试来自 http: //www.kernelthread.com/projects/hanoi//html/asm.html(很棒的资源)

因为我想回顾一下在这个问题中如何使用堆栈,所以我用 NASM 组装它并使用 GCC 链接它。但是,我注意到在 KDbg 中,当前执行点没有更新(即,我无法判断我在文件中的位置)。由于 KDbg 依赖于 gdb,因此我在 gdb 中运行代码以查看是否遇到类似问题。

如果我在程序中的第 30 行(这是主函数中的一行)上设置断点,我会得到以下信息:

(gdb) break 30
Breakpoint 2 at 0x804840b: file hanoi.asm, line 30.
(gdb) next
Single stepping until exit from function main,
which has no line number information.

我当前正在使用我编写的以下小脚本编译程序集(我可能应该迁移到一个 make 文件,但这一直有效)

bschlinker@net1develop02:~/.scripts$ cat asmgcc
# /usr/bin/sh

nasm -f elf -g -F stabs $1.asm -l $1.lst
gcc -g $1.o -o $1

我刚刚从 CentOS 迁移到 Ubuntu,所以我不确定这是我不熟悉的操作系统环境问题还是另一个问题。

与往常一样,提前感谢您的任何帮助。

Currently attempting to debug with KDbg / gdb the source code for Towers of Hanoi from http://www.kernelthread.com/projects/hanoi//html/asm.html (great resource)

Since I wanted to review how the stack is used within this problem, I assembled it with NASM and used GCC to link it. However, I noticed that in KDbg, the current point of execution was not updating (i.e, I could not tell where I was within the file). Since KDbg relies on gdb, I ran the code within gdb to see if I experienced similar issues.

If I set a breakpoint on line #30 in the program (which is a line within the main function), I get the following:

(gdb) break 30
Breakpoint 2 at 0x804840b: file hanoi.asm, line 30.
(gdb) next
Single stepping until exit from function main,
which has no line number information.

I'm currently compiling the assembly with the following little script I've written (I should probably migrate to a make file, but this has been working up until now)

bschlinker@net1develop02:~/.scripts$ cat asmgcc
# /usr/bin/sh

nasm -f elf -g -F stabs $1.asm -l $1.lst
gcc -g $1.o -o $1

I just migrated from CentOS to Ubuntu, so I'm not sure if this is an OS environment issue I'm not familiar with, or another issue.

As always, thanks in advance for any assistance.

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

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

发布评论

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

评论(2

霊感 2024-10-09 05:59:50

尝试使用 -F dwarf 而不是 -F Stas

Try -F dwarf instead of -F stabs.

荒岛晴空 2024-10-09 05:59:50

您可以使用 as -o tmp.o some.s && 进行汇编ld -s -o 某事 tmp.o && rm tmp.o
在 gdb 中,只要 display/8i *$eip (或者 rip 如果是 64 位),它会在每一步的指令指针之后显示 8 条指令。所以你根本不需要调试信息;-)

You can assemble with as -o tmp.o something.s && ld -s -o something tmp.o && rm tmp.o.
In gdb just display/8i *$eip (or rip if 64 bit), it will display 8 instructions after instruction pointer with every step. So you don't need debugging info at all ;-)

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