gcc与as-ld用于调试目的,而不是命中gdb断点

时间:2023-01-18 11:23:45

My platform is ubuntu i686 (32 bits)

我的平台是ubuntu i686(32位)

If i compile a assembly source with gcc driver with debugging options :

如果我使用带有调试选项的gcc驱动程序编译汇编源:

gcc -nostartfiles -g -o toupper toupper.s 

I open the toupper executable with gdb debugger integrated on emacs editor

我用emacs编辑器上集成的gdb调试器打开toupper可执行文件

$ emacs toupper.s-> M-x gdb -> M-x gdb-many-windows

I generated a breakpoint on first instruccion with

我在第一个instruccion上生成了一个断点

(gdb) b _start
(gdb) run

When i start the execution wiht run command the debugger stop on _start label, correctly.

当我开始执行wiht run命令时,调试器会在_start标签上正确停止。

If I compile the same source toupper.s with as assembler and link with ld linker:

如果我使用汇编程序编译相同的源toupper.s并使用ld链接器链接:

as -g -o toupper.o toupper.s
ld -o toupper toupper.o

Now the steps for debugging matched the gcc case.

现在,调试步骤与gcc案例相匹配。

$ emacs toupper.s -> M-x gdb -> M-x gdb-many-windows
(gdb) b _start   -> mark with a red point the _start line
(gdb) run -> DONT HIT THE _start LINE ¿?

I see that the symbole table is correct, the breakpoints mark it is correct but the execution is NOT step by step.

我看到symbole表是正确的,断点标记它是正确的但执行不是一步一步的。

I have display de verbose steps on gcc case and tried it again with as/ld case but the result is the same

我在gcc案例中显示了详细的步骤并使用as / ld情况再次尝试但结果是相同的

¿ There is some default option on gcc case that not matched the as/ld case?

¿gcc案例中有一些默认选项与as / ld案例不匹配?

Thanks in advance

提前致谢

1 个解决方案

#1


0  

When you build with gcc -nostartfiles -g ..., GCC (at least my GCC on a Linux system) passes -gdwarf2 to as. You can see the actual as command if you add -v to gcc's invocation.

使用gcc -nostartfiles -g构建时,GCC(至少是Linux系统上的GCC)将-gdwarf2传递给as。如果将-v添加到gcc的调用,则可以看到实际的命令。

When you build with as -g ... directly, you are not passing -gdwarf2.

当您使用as -g直接构建时,您不会传递-gdwarf2。

I am guessing that is what explains the difference in behavior. I am not sure what -g means to your version of as, or why it should matter.

我猜这就是解释行为差异的原因。我不确定-g对你的版本是什么意思,或者为什么它应该重要。

#1


0  

When you build with gcc -nostartfiles -g ..., GCC (at least my GCC on a Linux system) passes -gdwarf2 to as. You can see the actual as command if you add -v to gcc's invocation.

使用gcc -nostartfiles -g构建时,GCC(至少是Linux系统上的GCC)将-gdwarf2传递给as。如果将-v添加到gcc的调用,则可以看到实际的命令。

When you build with as -g ... directly, you are not passing -gdwarf2.

当您使用as -g直接构建时,您不会传递-gdwarf2。

I am guessing that is what explains the difference in behavior. I am not sure what -g means to your version of as, or why it should matter.

我猜这就是解释行为差异的原因。我不确定-g对你的版本是什么意思,或者为什么它应该重要。