Linux--- 進程跟蹤手段

來源:互聯網
上載者:User

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

本文永久更新連結地址:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.