GDB踪函数的完整调用过程 及原理
http://www.lenky.info/archives/2013/02/2202
Breakpoint , 0x0000003c4e417410 in open64 () from /lib64/ld-linux-x86-.so.
(gdb) bt
# 0x0000003c4e417410 in open64 () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e40f789 in _dl_sysdep_read_whole_file () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e408d78 in _dl_load_cache_lookup () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e408612 in _dl_map_object () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e40c3a2 in openaux () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e40e286 in _dl_catch_error () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e40ca85 in _dl_map_object_deps () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e403310 in dl_main () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e4160ae in _dl_sysdep_start () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e4014a4 in _dl_start () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e400b08 in _start () from /lib64/ld-linux-x86-.so.
# 0x0000000000000001 in ?? ()
# 0x00007fffffffe85b in ?? ()
# 0x0000000000000000 in ?? ()
(gdb) bt
# 0x0000003c4e417410 in open64 () from /lib64/ld-linux-x86-.so.
(More stack frames follow...)
(gdb) bt
# 0x0000003c4e417410 in open64 () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e40f789 in _dl_sysdep_read_whole_file () from /lib64/ld-linux-x86-.so.
(More stack frames follow...)
(gdb) bt
# 0x0000003c4e417410 in open64 () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e40f789 in _dl_sysdep_read_whole_file () from /lib64/ld-linux-x86-.so.
# 0x0000003c4e408d78 in _dl_load_cache_lookup () from /lib64/ld-linux-x86-.so.
(More stack frames follow...)
(gdb) bt -
# 0x0000000000000000 in ?? ()
(gdb) bt -
[root@monitor ~]# cat test.c #include <stdio.h>
#include <stdlib.h>
main()
{
int *p1=malloc();
int *p2=malloc();
int *p3=malloc();
int *p4=malloc();
int *p5=malloc();
printf("%p\n",p1);
printf("%p\n",p2);
printf("%p\n",p3);
printf("%p\n",p4);
printf("%p\n",p5);
printf("1231238888::"); }
[root@monitor ~]# readelf -s ./test Symbol table '.dynsym' contains entries:
Num: Value Size Type Bind Vis Ndx Name
: NOTYPE LOCAL DEFAULT UND
: FUNC GLOBAL DEFAULT UND printf@GLIBC_2.2.5 ()
: NOTYPE WEAK DEFAULT UND __gmon_start__
: FUNC GLOBAL DEFAULT UND malloc@GLIBC_2.2.5 ()
: FUNC GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.2.5 () Symbol table '.symtab' contains entries:
Num: Value Size Type Bind Vis Ndx Name
: NOTYPE LOCAL DEFAULT UND
: SECTION LOCAL DEFAULT
: 000000000040021c SECTION LOCAL DEFAULT
: 000000000040023c SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: 00000000004002f8 SECTION LOCAL DEFAULT
: 000000000040033e SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: 00000000004003c8 SECTION LOCAL DEFAULT
: 00000000004003e0 SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: 00000000004006c8 SECTION LOCAL DEFAULT
: 00000000004006d8 SECTION LOCAL DEFAULT
: 00000000004006fc SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: 00000000006007a0 SECTION LOCAL DEFAULT
: 00000000006007b0 SECTION LOCAL DEFAULT
: 00000000006007c0 SECTION LOCAL DEFAULT
: 00000000006007c8 SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: SECTION LOCAL DEFAULT
: 000000000040044c FUNC LOCAL DEFAULT call_gmon_start
: FILE LOCAL DEFAULT ABS crtstuff.c
: 00000000006007a0 OBJECT LOCAL DEFAULT __CTOR_LIST__
: 00000000006007b0 OBJECT LOCAL DEFAULT __DTOR_LIST__
: 00000000006007c0 OBJECT LOCAL DEFAULT __JCR_LIST__
: FUNC LOCAL DEFAULT __do_global_dtors_aux
: OBJECT LOCAL DEFAULT completed.
: 00000000006009a0 OBJECT LOCAL DEFAULT dtor_idx.
: 00000000004004e0 FUNC LOCAL DEFAULT frame_dummy
: FILE LOCAL DEFAULT ABS crtstuff.c
: 00000000006007a8 OBJECT LOCAL DEFAULT __CTOR_END__
: OBJECT LOCAL DEFAULT __FRAME_END__
: 00000000006007c0 OBJECT LOCAL DEFAULT __JCR_END__
: FUNC LOCAL DEFAULT __do_global_ctors_aux
: FILE LOCAL DEFAULT ABS test.c
: OBJECT LOCAL DEFAULT _GLOBAL_OFFSET_TABLE_
: 000000000060079c NOTYPE LOCAL DEFAULT __init_array_end
: 000000000060079c NOTYPE LOCAL DEFAULT __init_array_start
: 00000000006007c8 OBJECT LOCAL DEFAULT _DYNAMIC
: NOTYPE WEAK DEFAULT data_start
: FUNC GLOBAL DEFAULT UND printf@@GLIBC_2.2.5
: 00000000004005f0 FUNC GLOBAL DEFAULT __libc_csu_fini
: FUNC GLOBAL DEFAULT _start
: NOTYPE WEAK DEFAULT UND __gmon_start__
: NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
: 00000000004006c8 FUNC GLOBAL DEFAULT _fini
: FUNC GLOBAL DEFAULT UND malloc@@GLIBC_2.2.5
: FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
: 00000000004006d8 OBJECT GLOBAL DEFAULT _IO_stdin_used
: NOTYPE GLOBAL DEFAULT __data_start
: 00000000004006e0 OBJECT GLOBAL HIDDEN __dso_handle
: 00000000006007b8 OBJECT GLOBAL HIDDEN __DTOR_END__
: FUNC GLOBAL DEFAULT __libc_csu_init
: NOTYPE GLOBAL DEFAULT ABS __bss_start
: 00000000006009a8 NOTYPE GLOBAL DEFAULT ABS _end
: NOTYPE GLOBAL DEFAULT ABS _edata
: FUNC GLOBAL DEFAULT main
: 00000000004003c8 FUNC GLOBAL DEFAULT _init
[root@localhost trace]# readelf -s ./test | gawk '
{
if
($4 ==
"FUNC"
&& $2 != 0) {
print
"# code for "
$NF;
print
"b *0x"
$2;
print
"commands"
;
print
"silent"
;
print
"bt 1"
;
print
"c"
;
print
"end"
;
print
""
;
}
}' > sym;
[root@monitor ~]# cat sym
# code for call_gmon_start
b *0x000000000040044c
commands
silent
bt
c
end # code for __do_global_dtors_aux
b *0x0000000000400470
commands
silent
bt
c
end # code for frame_dummy
b *0x00000000004004e0
commands
silent
bt
c
end # code for __do_global_ctors_aux
b *0x0000000000400690
commands
silent
bt
c
end # code for __libc_csu_fini
b *0x00000000004005f0
commands
silent
bt
c
end # code for _start
b *0x0000000000400420
commands
silent
bt
c
end # code for _fini
b *0x00000000004006c8
commands
silent
bt
c
end # code for __libc_csu_init
b *0x0000000000400600
commands
silent
bt
c
end # code for main
b *0x0000000000400504
commands
silent
bt
c
end # code for _init
b *0x00000000004003c8
commands
silent
bt
c
end [root@monitor ~]# gdb --command=sym ./test -q
Reading symbols from /root/test...done.
Breakpoint at 0x40044c
Breakpoint at 0x400470
Breakpoint at 0x4004e0
Breakpoint at 0x400690
Breakpoint at 0x4005f0
Breakpoint at 0x400420
Breakpoint at 0x4006c8
Breakpoint at 0x400600
Breakpoint at 0x400504: file test.c, line .
Breakpoint at 0x4003c8
(gdb) r
Starting program: /root/test
# 0x0000000000400420 in _start ()
# 0x0000000000400600 in __libc_csu_init ()
# 0x00000000004003c8 in _init ()
# 0x000000000040044c in call_gmon_start ()
# 0x00000000004004e0 in frame_dummy ()
# 0x0000000000400690 in __do_global_ctors_aux ()
# main () at test.c:
0x601010
0x601030
0x601050
0x601070
0x601090
# 0x00000000004006c8 in _fini ()
# 0x0000000000400470 in __do_global_dtors_aux ()
::
Program exited with code .
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.166.el6_7..x86_64
GDB踪函数的完整调用过程 及原理的更多相关文章
- Presto 标量函数注册和调用过程简述
在Presto 函数开发一文中已经介绍过如何进行函数开发,本文主要讲述标量函数(Scalar Function)实现之后,是如何在Presto内部进行注册和被调用的.主要讲述标量函数是因为:三类函数的 ...
- AsyncTask中各个函数详细的调用过程,初步实现异步任务
AsyncTask内部类可能会产生内存泄露的问题 解决上述内部类可能引起的内存泄露问题的方法 将AsyncTask或者Thread的子类作为单独的类文件,不持有Activity的强引用 将Async ...
- [Android Pro] 深入理解函数的调用过程——栈帧
cp :http://blog.csdn.net/x_perseverance/article/details/78897637 每一个函数被调用时,都会为函数开辟一块空间,这块空间就称为栈帧. 首先 ...
- 最原始的COM组件调用过程(不使用注册表信息)
最原始的COM组件调用过程(不使用注册表信息) 最近因为项目的关系开始研究COM组件了,以前都认为COM过时了,所以也没怎么接触. 现在好好补补课了. 一般调用COM都是通过注册表找到它的位置, 然后 ...
- 你好,C++(27)在一个函数内部调用它自己本身 5.1.5 函数的递归调用
5.1.5 函数的递归调用 在函数调用中,通常我们都是在一个函数中调用另外一个函数,以此来完成其中的某部分功能.例如,我们在main()主函数中调用PowerSum()函数来计算两个数的平方和,而在P ...
- 代码 or 指令,浅析ARM架构下的函数的调用过程
摘要:linux程序运行的状态以及如何推导调用栈. 1.背景知识 1.ARM64寄存器介绍: 2.STP指令详解(ARMV8手册): 我们先看一下指令格式(64bit),以及指令对于寄存机执行结果的影 ...
- 使用IDA PRO+OllyDbg+PEview 追踪windows API 动态链接库函数的调用过程
使用IDA PRO+OllyDbg+PEview 追踪windows API 动态链接库函数的调用过程 http://blog.csdn.net/liujiayu2/article/details/5 ...
- 在C语言中函数及其调用过程
目录 函数 C语言中的变参函数 函数的本质是什么 内存区域的区分技巧 函数的调用过程 栈帧的概念 调用过程细节 按照约定传参 函数 如果一个函数有声明没实现,那么就会出现链接错误: 以上代码会出现链接 ...
- Arcgis GDB文件地理数据库、shapefile、coverage 和其他基于文件的数据源所支持的函数的完整列表
函数 以下是文件地理数据库.shapefile.coverage 和其他基于文件的数据源所支持的函数的完整列表.个人地理数据库和 ArcSDE 地理数据库也支持这些函数,但这些数据源可能使用不同的语法 ...
随机推荐
- QFTP走了以后QNetworkAccessManager出现了
QNetworkAccessManager Class Header: #include <QNetworkAccessManager>qmake: QT += networ ...
- C# 数据结构 线性表(顺序表 链表 IList 数组)
线性表 线性表是最简单.最基本.最常用的数据结构.数据元素 1 对 1的关系,这种关系是位置关系. 特点 (1)第一个元素和最后一个元素前后是没有数据元素,线性表中剩下的元素是近邻的,前后都有元素. ...
- win7下配置IIS服务器方法
网站爱好初学者必看的win7系统配置自己的IIS,可以在你自己的电脑上配置网站服务器发不到网上,下面就跟着我的步骤一起做吧100%成功. 步骤方法 1.点击开始-------控制面板这个就是打开的控制 ...
- JSON字符串序列化与反序列化浅试
一.添加引用(using Newtonsoft.Json.Linq;) 二. 1.生成json字符串源码 List<string> list = new List<string> ...
- 学习Swift -- 继承
继承 一个类可以继承另一个类的方法(methods),属性(properties)和其它特性.当一个类继承其它类时,继承类叫子类,被继承类叫超类(父类). 在 Swift 中,子类可以调用和访问父类的 ...
- 为什么这么多Python框架
原文:http://bitworking.org/news/Why_so_many_Python_web_frameworks BitWorking This is Joe Gregorio's wr ...
- Map迭代器
今天用到了,发现不会,随手谷歌之,整理如下. //Map是接口,刚才在那new Map,汗颜 Map<Character,Integer> mm = new HashMap ...
- 【Java】数据库连接池技术
JDBC的问题 在程序中,我们经常要建立与数据库的连接,之后再关闭这个连接.我们知道,数据库连接对象的创建是比较消耗系统性能的,这些频繁的操作势必会消耗大量的系统资源.因此我们需要采用更高效的数据库访 ...
- 当我们在谈论 DevOps,我们在谈论什么?
Cloud Insight 携手 BearyChat:打造适合运维人员的团队协作工具 走过 C 轮的 OneAPM,旗下的产品已经日渐丰满,从应用性能监控的 Application Insight 到 ...
- Android开源项目发现--- 安全篇(持续更新)
SQLCipher Sqlite加密工具 项目地址:https://github.com/sqlcipher/sqlcipher 帮助文档:http://sqlcipher.net/sqlcipher ...