在应用程序中进行的所有函数调用的列表 [英] List of all function calls made in an application
问题描述
我们如何列出在应用程序中调用的所有函数。我尝试使用GDB,但它的回溯列表仅限于主函数调用。
我需要更深的列表,即主函数调用的所有函数的列表以及这些调用的函数调用的函数等等。
有没有办法在gdb中得到这个?或者你能给我一些关于如何获得这些信息的建议吗? 在应用程序中调用函数
对于任何实际大小的应用程序,此列表将包含数千个条目,这可能会使其无用。
您可以在 nm $>的应用程序中找到定义的所有函数(但不一定称为) c $ c>命令,例如
nm /path/to/a.out | egrep'[TW]'
您也可以使用GDB为每个函数设置断点: p>
(gdb)set logging on#collect trace in gdb.txt
(gdb)set confirm off#you would not想要确认他们中的每一个
(gdb)rbreak。 #为每个函数设置一个断点
一旦你继续,你会为每个函数调用一个断点。使用禁用
和继续
命令向前移动。我不相信有一个简单的方法来自动化,除非你想使用Python脚本。
已经提到 gprof
是另一个不错的选择。
How can we list all the functions being called in an application. I tried using GDB but its backtrace list only upto the main function call.
I need deeper list i.e list of all the functions being called by the main function and the function being called from these called functions and so on.
Is there a way to get this in gdb? Or could you give me suggestions on how to get this?
How can we list all the functions being called in an application
For any realistically sized application, this list will have thousands of entries, which will probably make it useless.
You can find out all functions defined (but not necessarily called) in an application with the nm
command, e.g.
nm /path/to/a.out | egrep ' [TW] '
You can also use GDB to set a breakpoint on each function:
(gdb) set logging on # collect trace in gdb.txt
(gdb) set confirm off # you wouldn't want to confirm every one of them
(gdb) rbreak . # set a breakpoint on each function
Once you continue, you'll hit a breakpoint for each function called. Use the disable
and continue
commands to move forward. I don't believe there is an easy way to automate that, unless you want to use Python scripting.
Already mentioned gprof
is another good option.
这篇关于在应用程序中进行的所有函数调用的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!