List of all function calls made in an application

前端 未结 4 1974
甜味超标
甜味超标 2020-12-04 14:37

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

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 15:39

    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.

提交回复
热议问题