gdb - 列出所有函数调用
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] '
EG:
[root@monitor ~]# nm ./test | egrep ' [TW] '
00000000004005f0 T __libc_csu_fini
0000000000400600 T __libc_csu_init
00000000004006c8 T _fini
00000000004003c8 T _init
0000000000400420 T _start
0000000000600990 W data_start
0000000000400504 T main
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.
record function-call-history should be a great hardware accelerated possibility if you are one of the few people () with a CPU that supports Intel Processor Tracing (Intel PT, intel_pt in /proc/cpuinfo). GDB docs claim that it can produce output like: (gdb) list ,
void foo (void)
{
} void bar (void)
{
...
foo ();
...
}
(gdb) record function-call-history /ilc
bar inst , at foo.c:,
foo inst , at foo.c:,
bar inst , at foo.c:,
Before using it you need to run: start
record btrace
which is where a non capable CPU fails with: Target does not support branch tracing.
CPU support is further discussed at: How to run record instruction-history and function-call-history in GDB?
gdb - 列出所有函数调用的更多相关文章
- GDB教程详解
GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具.或许,各位比较喜欢那种图形界面方式的,像VC.BCB等IDE的调试,但如果你是在UNIX平台下做软件,你会发现GDB这个调试工具有比VC ...
- GDB中文手册
用GDB调试程序GDB概述 2使用GDB 5GDB中运行UNIX的shell程序 8在GDB中运行程序 8调试已运行的程序 两种方法: 9暂停 / 恢复程序运行 9一.设置断点(BreakPoint) ...
- Linux高级编程--04.GDB调试程序(设置断点)
调试已运行的程序 在UNIX下用ps查看正在运行的程序的PID(进程ID),然后用gdb PID格式挂接正在运行的程序. 先用gdb 关联上源代码,并进行gdb,在gdb中用attach命令来挂接进程 ...
- linux下gcc编译多个源文件、gdb的使用方法
一. gcc常用编译命令选项 假设源程序文件名为test.c. 1. 无选项编译链接 用法:#gcc test.c 作用:将test.c预处理.汇编.编译并链接形成可执行文件.这里未指定输出文件,默认 ...
- GDB 使用大法
一.GDB 我用的是 GCC+POWERSHELL+GDB, GDB刚刚接触也有很多要记的. 二.一个调试示例 tst.c #include <stdio.h> int func(int ...
- linux c/c++ GDB教程详解
学习使用了GDB一段时间后,发现它真的好强大!好用! GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具.或许,各位比较喜欢那种图形界面方式的,像VC.BCB等IDE的调试,但如果你是在U ...
- 比较全面的gdb调试命令 (转载)
转自http://blog.csdn.net/dadalan/article/details/3758025 用GDB调试程序 GDB是一个强大的命令行调试工具.大家知道命令行的强大就是在于,其可以形 ...
- linux下的gdb调试工具--断点调试
到目前为止我们的调试手段只有一种: 根据程序执行时的出错现象假设错误原因,然后在代码中适当的位置插入printf,执行程序并分析打印结果,如果结果和预期的一样,就基本上证明了自己假设的错误原因,就可以 ...
- GDB单步调试程序
linux下gdb单步调试 用 GDB 调试程序 GDB 概述———— GDB 是 GNU开源组织发布的一个强大的 UNIX下的程序调试工具.或许,各位比较喜欢那种图形界面方式的,像 VC. BCB等 ...
随机推荐
- 2016021902 - linux解压缩命令
转载自:http://blog.csdn.net/luo86106/article/details/6946255 .gz 解压1:gunzip FileName.gz 解压2:gzip -d Fil ...
- Apache添加虚拟主机目录
<VirtualHost 127.0.0.2:80> DocumentRoot d:/abcd ServerName 127.0.0.2:80</VirtualHost> &l ...
- spoj 3885
简单的博弈题,用dp解: 每个人只能拿1,l,k个硬币: dp[i][j]表示第j个人拿是否能拿第i枚硬币: 代码: #include<cstdio> #define maxn 10000 ...
- Sed&awk笔记之sed篇
http://blog.csdn.net/a81895898/article/details/8482387 Sed是什么 <sed and awk>一书中(1.2 A Stream Ed ...
- Innodb和MyISAM比较
Innodb和MyISAM比较 (1)MyISAM类型的表强调的是性能,其执行速度比InnoDB类型更快 (2)MyISAM不支持事务.外键,InnoDB支持事务和外键 (3)MyISAM使用的表级锁 ...
- SQL Server 阻塞分析
一.加锁(locking).阻塞(blocking).死锁(deadlock)定义 加锁:用于管理多个连接的进程.当连接需要访问一块数据时,在这些数据上放置某种类型的锁. 阻塞 ...
- 疯狂VirtualBOX 实战讲学录:小耗子之VirtualBOX修炼全程重现
疯狂VirtualBOX 实战讲学录:小耗子之VirtualBOX修炼全程重现 神级虚拟技术&云计算专家”小耗子”老师震撼分享 全球第—部完整深入的中文VirtualBox技术全程实战手册 全 ...
- NOIP2014酱油记
尘埃落定,来补一下酱油记吧... day-1 晚上老师说有xyz的noip模拟赛,于是果断请假来做(shou)题(nve),题目真是理(S)性(X)愉(B)悦(K),然后就爆零了!感觉noip要爆零滚 ...
- 深入浅出Node.js (附录B) - 调试Node
B.1 Debugger B.2 Node Inspector B.2.1 安装Node Inspector B.2.2 错误堆栈
- 用Delphi 实现WebService 转
一编写服务程序 第一步:File----->New----->Other------>WebServices----->Soap Server Application 选择IS ...