zoukankan      html  css  js  c++  java
  • 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 (2015) 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 1, 10 1 void foo (void) 2 { 3 } 4 5 void bar (void) 6 { 7 ... 8 foo (); 9 ... 10 } (gdb) record function-call-history /ilc 1 bar inst 1,4 at foo.c:6,8 2 foo inst 5,10 at foo.c:2,3 3 bar inst 11,13 at foo.c:9,10 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?
  • 相关阅读:
    抓老鼠啊~亏了还是赚了?
    golang实现AES加密和解密-自已动手写个加解密软件
    安卓hello wolrd【未成功】
    go template修改定界符Delims的坑
    解决liteIDE没有代码提示及跳转问题
    go vue真是稀缺组合(cdn方式)
    golang ---查看进程(Windows)
    go 通过代理服务器获取网站内容
    go 不要通过共享内存来通信,相反,应该通过通信来共享内存
    用rod获取百度搜索结果的例子
  • 原文地址:https://www.cnblogs.com/zengkefu/p/5571500.html
Copyright © 2011-2022 走看看