如何在gdb命令中打印函数的进入和离开? [英] How to print Entering and Leaving for a function in gdb command?
问题描述
我已经尝试了以下内容,但是我只看到第一个printf语句,从未看到说"Leaveing"的语句.这可能吗?
I've tried the following, but I only see the first printf statement, never the one that says "Leaving". Is this possible?
break MyFunctionName
commands
silent
printf "Entering MyFunctionName\n"
finish
printf "Leaving MyFunctionName\n"
continue
end
推荐答案
这可能吗?
Is this possible?
否,这是 gdb的行为:>
No, it is documented behavior of gdb:
命令恢复后,命令列表中的任何其他命令 执行,被忽略.这是因为任何时候您恢复执行 (即使是简单的下一步或步骤),您可能还会遇到另一个 断点-可能具有自己的命令列表,导致 关于要执行哪个列表的不确定性.
Any other commands in the command list, after a command that resumes execution, are ignored. This is because any time you resume execution (even with a simple next or step), you may encounter another breakpoint—which could have its own command list, leading to ambiguities about which list to execute.
finish
是恢复执行的命令,因此将忽略命令列表中剩下的这两个命令:
finish
is the command that resumes execution, so these 2 remaining commands in command list are ignored:
printf "Leaving MyFunctionName\n"
continue
这篇关于如何在gdb命令中打印函数的进入和离开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!