如何在GDB中自动打印下一个执行的行? [英] How to print the next N executed lines automatically in GDB?
问题描述
即使只是一种简单的方式,也可以使用一种简单的方法自动化 n
命令,这样你就可以看到调用例程的顺序。
我意识到你可以发布 nx
其中x是GDB执行的次数,但麻烦在于它显示的是命令而不是程序的地址!但如果您在GDB中手动按 n
(然后按回车发出前一个命令),它将显示地址。
我在GDB中尝试了以下内容:
pre $ (在设置断点后,比如0x0123456)
b * 0x0123456
GDB表示<断点1在0x123456>
。我输入:
命令1
n 1000
c
结束
但它没有像预期的那样循环,并且不显示地址位置: - (。
任何帮助将不胜感激!当然,它必须很简单,自动记录的例程被称为??
(gdb)define nstep
> set $ foo = $ arg0
> while($ foo--)
> step
> end
> ; end
(gdb)nstep 100
我已经完成了很多次了。帮助!
I have been trying to find a way for some time to automate the progress in GDB of tracing the control flow of a program.
Even just a simple way of automating the n
command so you can see in what order routines are called.
I realise that you can issues n x
where x is the number of times GDB steps through, but the trouble with that is that it shows the command but not the address of the routine! But if you press n
manually in GDB (then press return to issue the previous command) it shows the address.
I have tried the following in GDB:
(after setting a breakpoint at say 0x0123456)
b *0x0123456
GDB says <breakpoint 1 at 0x123456>
. I type:
commands 1
n 1000
c
end
but it doesn't loop as expected, and it doesn't show the address location :-(.
Any help would be appreciated! Surely it must be simple to automatically log the order routines are called??
This is easy, actually. I'll give you the bare bones, and you can modify to suit.
(gdb) define nstep
> set $foo = $arg0
> while ($foo--)
> step
> end
> end
(gdb) nstep 100
I've done this many times. Hope this helps!
这篇关于如何在GDB中自动打印下一个执行的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!