Ubuntu下使用valgrind所遇问题

一、Valgrind的安装
a、直接使用sudo apt-get install valgrind
b、valgrind官网下载http://valgrind.org/

#解压
sudo tar xvf valgrind-3.8.1.tar.bz2 -C /home/worspace/
#安装
./configure
make
sudo make install

运行:
$valgrind ls -l
出现以下问题:

==18092== Memcheck, a memory error detector 
==18092== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. 
==18092== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info 
==18092== Command: ls -l
 
==18092== 
 
valgrind:  Fatal error at startup: a function redirection
valgrind:  which is mandatory for this platform-tool combination 
valgrind:  cannot be set up.  Details of the redirection are:
 
valgrind:  
 
valgrind:  A must-be-redirected function 
valgrind:  whose name matches the pattern:      index 
valgrind:  in an object with soname matching:   ld-linux.so.2 
valgrind:  was not found whilst processing 
valgrind:  symbols from the object with soname: ld-linux.so.2
 
valgrind:  
 
valgrind:  Possible fixes: (1, short term): install glibc's debuginfo
valgrind:  package on this machine.  (2, longer term): ask the packagers 
valgrind:  for your Linux distribution to please in future ship a non- 
valgrind:  stripped ld.so (or whatever the dynamic linker .so is called) 
valgrind:  that exports the above-named function using the standard 
valgrind:  calling conventions for this platform.  The package you need 
valgrind:  to install for fix (1) is called
 
valgrind:  
 
valgrind:    On Debian, Ubuntu:                 libc6-dbg 
valgrind:    On SuSE, openSuSE, Fedora, RHEL:   glibc-debuginfo
 
valgrind:   
valgrind:  Cannot continue -- exiting now.  Sorry.

二、解决办法
仔细阅读上边的log信息,
Possible fixes: (1, short term): install glibc's debuginfo
On Debian, Ubuntu:                 libc6-dbg 

ok,执行命令sudo apt-get install libc6-dbg
安装完成后,问题解决

三、使用方法(valgrind --help)
valgrind --leak-check=yes --show-reachable=yes ls -l
以下是截取的结果分析:

==11283== LEAK SUMMARY:
==11283==    definitely lost: 80 bytes in 2 blocks
==11283==    indirectly lost: 240 bytes in 20 blocks
==11283==      possibly lost: 0 bytes in 0 blocks
==11283==    still reachable: 13,405 bytes in 23 blocks
==11283==         suppressed: 0 bytes in 0 blocks
运行自己的app:
 valgrind --leak-check=full --track-origins=yes --show-reachable=yes ./packapp 0 0 HW9_Multimedia_256MDDR_128MFlash_CTT2_mnt.ini 
结果分析:
==11295== HEAP SUMMARY:
==11295==     in use at exit: 0 bytes in 0 blocks
==11295==   total heap usage: 29 allocs, 29 frees, 70,080,768 bytes allocated
可以看到堆栈heap分配了29次,释放了29次。没有reachable的block

四、遗留的问题
上述关于ld-linux.so.2,non stripped ld.so,应该是关于编译链接的问题,需要好好看看《编译原理》了。


转载于:https://my.oschina.net/mavericsoung/blog/139199

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值