参考:http://stackoverflow.com/questions/311840/tool-to-trace-local-function-calls-in-linux
里面有一个对应的工具:
https://github.com/leviathansecurity/ftrace
接下来看一下对应的代码。
- main
- !opts.attach
- examine_process
- MapElf32 / MapElf64
- BuildSyms
- get_address_space
- callstack_init
- for (;;)
- ptrace (PTRACE_SINGLESTEP
- callstack_push
- set_breakpoint
- ptrace(PTRACE_PEEKTEXT
- opts.attach
- ptrace(PTRACE_ATTACH
- get_path
- validate_em_type
- examine_process