如何在gdb命令中打印函数的进入和离开? [英] How to print Entering and Leaving for a function in gdb command?

查看:229
本文介绍了如何在gdb命令中打印函数的进入和离开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了以下内容,但是我只看到第一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆