valgrind工具介紹

一、簡介

Valgrind是一個二進制插樁框架,可以用來制作二進制分析工具。利用Valgrind可以檢測二進制程序的內(nèi)存和線程漏洞。Valgrind框架目前包含以下幾種工具:

Memcheck?is a memory error detector. It helps you make your programs, particularly those written in C and C++, more correct.

Cachegrind?is a cache and branch-prediction profiler. It helps you make your programs run faster.

Callgrind?is a call-graph generating cache profiler. It has some overlap with Cachegrind, but also gathers some information that Cachegrind does not.

Helgrind?is a thread error detector. It helps you make your multi-threaded programs more correct.

DRD?is also a thread error detector. It is similar to Helgrind but uses different analysis techniques and so may find different problems.

Massif?is a heap profiler. It helps you make your programs use less memory.

DHAT?is a different kind of heap profiler. It helps you understand issues of block lifetimes, block utilisation, and layout inefficiencies.

SGcheck?is an experimental tool that can detect overruns of stack and global arrays. Its functionality is complementary to that of Memcheck: SGcheck finds problems that Memcheck can't, and vice versa..

BBV?is an experimental SimPoint basic block vector generator. It is useful to people doing computer architecture research and development.


二、安裝valgrind

valgrind官網(wǎng)上下載源碼,解壓后依次執(zhí)行

./configure

make

sudo make install

輸入valgrind -h查看是否安裝成功


三、使用

valgrind的默認命令結(jié)構(gòu)為:

valgrind [valgrind-options] your-prog [your prog options]

對C/C++程序,采用-g?編譯選項進行編譯得到二進制程序myprog

一般使用下面命令來運行程序myprog:

valgrind --tool=memcheck? --leak-check=yes myprog arg1 arg2?

默認使用的是Memcheck工具,如果要使用別的工具可以在--tool?選項中設(shè)置,? --leak-check選項默認打開memory leak detector

--toool=<toolname>

toolname?可以為:memcheck, cachegrind, callgrind, helgrind, drd, massif, lackey, none, exp-sgcheck, exp-bbv, exp-dhat, etc.

如果目標是檢查程序漏洞,則常使用的tool為:memcheck (內(nèi)存錯誤),?helgrind, drd(線程錯誤)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 有人說:生活如一團亂麻。 也有人說:生命如歌。 生活與生命,難道不是一件事嗎?沒有了生命,哪來的生活?沒有了生活,...
    愛的花園閱讀 768評論 0 4
  • 沒翻開的人間詞話 塞滿了的煙灰缸 亂劃下的鉛筆靈感 發(fā)了霉的餅干 我躺在床上 用中了彩票的夢麻醉入眠。 關(guān)燈吧,清...
    不在樓上閱讀 212評論 1 0
  • 說過很多話,沒刻意去記得什么,也就差不多都忘記了。一些應(yīng)該記得或者不想忘記的事情,自然而然的會留下來。 很羨慕世界...
    加七兒閱讀 350評論 0 0
  • 類似微軟visio的功能,可以做一些思維導(dǎo)圖之類的;還可以做Business, UML等等,很方便好用。 http...
    小雙2510閱讀 1,968評論 0 0
  • 作者:逗逗 原創(chuàng)作品,抄襲搬運必究。 01. 有一次,我和我對象吵架,我們各自坐在一邊誰也不理誰。 過了一會,我的...
    遇見逗逗閱讀 607評論 0 0

友情鏈接更多精彩內(nèi)容