在GDB的每一行设置断点 [英] Set breakpoint on every line in GDB
问题描述
b * addr
,所以我想知道是否有快速的方法来做到这一点。 编辑
请注意,我正在运行由其他人创建的二进制文件,并且我无法访问源代码。不幸的是,该二进制文件没有用-g标志编译。因此,我不能单步执行代码中的每一行。
进一步编辑
正如Jason指出的,您可以事实上,只要您使用 si
或 ni
,就可以单步执行代码,而不仅仅是<$ c $ (步骤)或 n
(下一步)。不过,如果源代码是用-g编译的,但是它会逐行执行,但是 n
或 s
的源代码,而不是逐步执行每个汇编指令,例如 ni
或 si
-g。
si
( stepi
)到代码的指令步骤。您可以使用 ni
( nexti
)来跳过您不感兴趣的库函数。如果您意外进入其中之一, finish
应该让你回到原来的程序。在这个级别工作的人通常会设置gdb来显示接下来要执行的几条指令,例如, disp / 3i $ pc
。 Is there a way to set a breakpoint at every line in the code with GDB? Obviously I don't want to hit b *addr
for every single line, so I'm wondering if there's a fast way to do this.
Edit Note that I am running a binary created by someone else and I do not have access to the source code. Unfortunately, that binary has not been compiled with the -g flag. Therefore, I cannot just single step through each line in the code.
Further Edit
As Jason points out below, you can indeed single step through the code so long as you use si
or ni
, as opposed to just simply s
(step) or n
(next). n
or s
work fine, though, if the source code had been compiled with -g, but it steps through lines of source code, as opposed to stepping through every assembly instruction like ni
or si
do in a binary that was compiled without -g.
Use si
(stepi
) to instruction step through the code. You can use ni
(nexti
) to step over library functions you're not interested in. If you accidentally step into one of them, finish
should get you back to your original routine. People working at this level typically have gdb set to display the next few instructions that are about to be executed, e.g. disp/3i $pc
.
这篇关于在GDB的每一行设置断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!