Welcome 微信登录

首页 / 操作系统 / Linux / Linux--- 进程跟踪手段

Linux--- 进程跟踪手段strace方法:
strace XXX -o ttt  --- 跟踪XXX执行过程调用的系统调用,结果保存到ttt文件strace -c XXX --- 跟踪XXX每次调用系统调用耗费时长strace -f XXX --- 跟踪XXX所有进程包括子进程的系统调用strace -e trace=open,write XXX ---跟踪XXX执行过程调用的open、write系统调用strace -e trace=network -p 24567  ---跟24567进程所有与网络有关的系统调用ltrace方法:
ltrace –s XXX  --- 跟踪系统调用和库函数调用ltrace –e strcpy,strlen XXX --- 跟踪进程调用的strcpy、strlen两种库函数ltrace -l /lib64/librt.so.1 XXX --- 跟踪XXX调用的指定动态库中的库函数valgrind方法:
默认没有安装,必须手工安装该工具。valgrind --tool=memcheck --trace-children=yes XXX--- 使用valgrind的memcheck工具对XXX命令执行内存检测。memcheckDetects memory errors. It helps you tune your programs to behave correctly.cachegrindProfiles cache prediction. It helps you tune your programs to run faster.callgrindWorks in a similar way to cachegrind but also gathers additional cache-profiling information.exp-drdDetects thread errors. It helps you tune your multi-threaded programs to behave correctly.helgrindAnother thread error detector. Similar to exp-drd but uses different techniques for problem analysis.massifA heap profiler. Heap is an area of memory used for dynamic memory allocation.This tool helps you tune your program to use less memory.lackeyAn example tool showing instrumentation basics本文永久更新链接地址