嵌入式软件开发杂谈:动态分析工具Valgrind的配置使用
Posted Stoneshen1211
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了嵌入式软件开发杂谈:动态分析工具Valgrind的配置使用相关的知识,希望对你有一定的参考价值。
文章目录
1 编译
1.1下载
http://valgrind.org
1.2编译
#./configure --prefix=/home/work/third_party/valgrind/valgrind-3.16.1/__install --host=arm-linux CC=arm-linux-gnueabihf-gcc
然后打开configure文件,搜索armv7* 字段,将其改写为 armv7* |arm
#make
#make install
至此,已经完成了valgrind的编译工作。
2 运行
将生成的bin以及lib放到设备上,并设置valgrind的共享库,使用如下指令即可:
#export VALGRIND_LIB=/mnt/usb1/lib/valgrind/
/mnt/usb1/lib/valgrind/为设备存放valgrind 库的路径。
使用如下指令运行valgrind:
#/mnt/usb1/valgrind --tool=memcheck --leak-check=full test_bin
如果出现如下的指令,则说明我们使用的glibc的库不匹配,需要重新交叉编译glibc,然后使用新的glibc库。
==2593== Memcheck, a memory error detector
==2593== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2593== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2593== Command: /mnt/usb1/sx_iot
==2593==
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-armhf.so.3
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld-linux-armhf.so.3
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: Note that if you are debugging a 32 bit process on a
valgrind: 64 bit system, you will need a corresponding 32 bit debuginfo
valgrind: package (e.g. libc6-dbg:i386).
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
交叉编译的glibc最好要和文件系统中原有的glibc库版本一致,并且使用-g选项进行交叉编译,将编译后的库替换到文件系统中去。
以上是关于嵌入式软件开发杂谈:动态分析工具Valgrind的配置使用的主要内容,如果未能解决你的问题,请参考以下文章
嵌入式软件开发杂谈:静态分析工具Pclint与source insight的整合
嵌入式软件开发杂谈:静态分析工具Pclint与source insight的整合
开发工具Valgrind内存问题检测工具(valgrind)的使用