首页 valgrind使用(Use valgrind)

valgrind使用(Use valgrind)

举报
开通vip

valgrind使用(Use valgrind)valgrind使用(Use valgrind) valgrind使用(Use valgrind) Valgrind is a GPL software For memory debugging and code profiling For Linux (For x86, amd64 and ppc32) programs. You can run your program in its environment to monitor memory usage, such as the malloc in C l...

valgrind使用(Use valgrind)
valgrind使用(Use valgrind) valgrind使用(Use valgrind) Valgrind is a GPL software For memory debugging and code profiling For Linux (For x86, amd64 and ppc32) programs. You can run your program in its environment to monitor memory usage, such as the malloc in C language and new and delete in free or C + +. With Valgrind's toolkit, you can automatically detect many bugs in memory management and threads, and avoid spending too much time looking for bugs, making your programs more secure. The main functions of Valgrind Valgrind kit contains multiple tools such as Memcheck, Cachegrind, Helgrind, Callgrind, Massif. The following are the tools: The Memcheck tool mainly checks for the following program error: Use of uninitialized memory Use memory after it has been free. Use the memory space allocated by malloc (Reading/writing off the end of malloc'd blocks) Illegal access to the stack (Reading/writing inappropriate areas on the stack) (Memory leaks - where Pointers to malloc'd blocks are lost forever) The malloc/free/new/delete application and release memory match (Mismatched use of malloc/new/new [] vs free/delete/delete []) SRC and DST overlap (Overlapping SRC and DST Pointers in memcpy () and related functions provides) Callgrind The Callgrind collects some data at run time, function calls, and so on, and optionally a cache simulation. At the end of the run, it writes the analysis data to a file. Callgrind_annotate can turn the contents of this file into readable form. Cachegrind It simulates a level of cache I1, D1, and L2 cache in the CPU, which can pinpoint the loss and hit of the cache in the program. If needed, it can also provide us with the number of cache misses, the number of memory references, and the number of instructions per line, per function, per module, and the entire program. This is a great help to the optimizer. Helgrind It is mainly used to check the competing problems in multi-threaded programs. Helgrind looks for areas of memory that are accessed by multiple threads without a consistent lock area, where they often lose synchronization between threads, and can lead to undiscovered errors. Helgrind implemented the competition detection algorithm called "Eraser" and made further improvements to reduce the number of reported errors. Massif The stack analyzer, which measures how much memory the program USES in the stack, tells us the size of the heap, heap management block, and stack. Massif can help us reduce memory usage, and in a modern system with virtual memory, it can also speed up the operation of our programs and reduce the chance of programs to stay in swap areas. Valgrind installation 1, to the WWW. Valgrind.org download the latest version of valgrind - 3.2.3. Tar.bz22, unpack the installation package: tar - JXVF valgrind - 3.2.3. Tar.bz23, the post-release form of the directory valgrind - 3.2.3 4, CD valgrind - 3.2.35,. / configure6, Make; Make install Use Valgrind Usage: valgrind [options] prog-and-args [options] : common options, applicable to all valgrind tools - tool = < name > is the most commonly used option. Run the tool called toolname in valgrind. The default memcheck. H-help displays help information. - version shows the version of the valgrind kernel, each with its own version. Q - quiet runs quietly, printing only error messages. V - verbose more detailed information, increasing error count. -trace - children = no | yes trace child thread? [no] - track - FDS = no | yes tracking open file description? [no] - time-stamp = no | yes adds time to LOG information? [no] Log - fd = < number > output log to descriptor file [2 = stderr] - log-file = < file > writes the output to filename. PID is the ID of the running program - log-file - exactly = < file > output log information to file - log-file - qualifier = < VAR > to get the value of the environment variable to be the filename of the output information. [none] - log-socket = ipaddr: port output log to socket, ipaddr: port LOG information output - XML = yes to export information in XML format, only memcheck is available -num - callers = < number > show < number > callers in stack traces [12] - error - limit = no | yes if too many errors, then stop displaying the new error? [yes] - error-exitcode = < number > if found error return error code [0 = disable] - db - attach = no | yes when there is an error, valgrind will automatically start the debugger GDB. [no] - command line options for starting the debugger with db - command = < command > Relevant options for the Memcheck tool: -leak check = no | summary | full request for details of leak? [summary] - leak - resolution = low | med | high how much bt merging in leak check [low] - show - reachable = no | yes show reachable blocks in leak check? [no] Valgrind USES examples The following is a problem C program code test.c # I nclude < stdlib. H BBB 0 void f (void) {int * x = malloc (10 * sizeof (int)); X [10] = 0; / / problem 1: array index overbounds} / / problem 2: memory is not released Int main (void) {(f); Return 0; } 1, the compiler test.cgcc - Wall test.c-g-o test2, using the Valgrind check program BUGvalgrind -- tool = memcheck = full -- log-file = val.log. / test3, 分析 定性数据统计分析pdf销售业绩分析模板建筑结构震害分析销售进度分析表京东商城竞争战略分析 输出的调试信息= = 3908 = = Memcheck,内存错误检测 器。==版权(C)2002-2007,以及GNU GPL,由Julian Seward等人使 用,使用LibVEX,1732,这是一个动态二进制翻译的库。版权 (C)2004-2007,以及由OpenWorks LLP的GNU GPL。使用 valgrind-3.2.3,一个动态的二进制插装框架。= = 3908 = =版权 (C)2000 - 2007,和GNU GPL,朱利安?苏华德et al。= = 3908 = = 更多细节,重新运行:- v = = 3908 = =——3908——DWARF2 CFI读 者:未处理的CFI指令0:50——3908——DWARF2 CFI读者:未处理的 CFI指令0:50 / *数组越界错误* / 3908 = = = =无效写的大小4 = = 3908 = = 0 x8048384:f(test.c:6)= = 3908 = = 0 x80483ac:主 要(test.c:11)= = 3908 = =地址0 x400c050后一块大小为0字节 40 alloc = = 3908 = = 0 x40046f2:malloc(vg_replace_malloc.c:149)= = 3908 = = 0 x8048377:f(test.c:5)= = 3908 = = 0 x80483ac:主要(test.c:11)= = 3908 = = = = 3908 = =错误 总结 初级经济法重点总结下载党员个人总结TXt高中句型全总结.doc高中句型全总结.doc理论力学知识点总结pdf :1错误上下文(从1抑制:14)= = 3908 = = malloc / free:在使用退出:40字节1块。====/free:1分 配,0释放,分配40个字节。对于被检测到的错误的计数,重新运 行:-v====搜索指向一个未被释放的块的指针。检查= = 3908 = = 59124字节。3908 = = = = = = = = 3908 / *有内存空间没有释放* / 3908 = = = = 40字节1块绝对是迷失在损失记录1 1 = = 3908 = = 0 x40046f2:malloc(vg_replace_malloc.c:149)= = 3908 = = 0 x8048377:f(test.c:5)= = 3908 = = 0 x80483ac:主要(test.c:11)= = 3908 = = = = 3908 = =泄漏简介:= = 3908 = =肯定失去了:40字节1块。可能在0块中丢失了:0字节。仍然可以到达:在0个块中0字节。被抑制的:0个字节的0个字节。
本文档为【valgrind使用(Use valgrind)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_792768
暂无简介~
格式:doc
大小:24KB
软件:Word
页数:0
分类:生活休闲
上传时间:2017-10-17
浏览量:10