2021-05-12 14:32:11
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命令執行記憶體檢測。
memcheck
Detects memory errors. It helps you tune your programs to behave correctly.
cachegrind
Profiles cache prediction. It helps you tune your programs to run faster.
callgrind
Works in a similar way to cachegrind but also gathers additional cache-profiling information.
exp-drd
Detects thread errors. It helps you tune your multi-threaded programs to behave correctly.
helgrind
Another thread error detector. Similar to exp-drd but uses different techniques for problem analysis.
massif
A heap profiler. Heap is an area of memory used for dynamic memory allocation.This tool helps you tune your program to use less memory.
lackey
An example tool showing instrumentation basics
本文永久更新連結地址:http://www.linuxidc.com/Linux/2015-04/116393.htm
相關文章