我如何获得调用函数的名字吗? [英] How do I get the name of the calling function?

查看:89
本文介绍了我如何获得调用函数的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的GNU工具链。我怎样才能在运行时,发现一个函数调用者的?例如函数B即()获取使用函数指针的许多功能调用。现在,每当B获得所谓的,我想打印的来电者的名字。我需要这个用于调试一定问题。

I am using gnu tool chain. How can I, at run time, find caller of a function? i.e for example function B() gets called by many functions using function pointers. Now, whenever B gets called, I want to print the callers name. I need this for debugging a certain issue.

推荐答案

如果你使用GNU,你可以使用的backtrace 功能。还有那个人页面上使用的一个例子。

If you're using GNU, you can use the backtrace functions. There's an example of the use on that man page.

这篇关于我如何获得调用函数的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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