Memory leaks # # # valgrind # valgrind-3.15.0 compiler && cross compiler

Preparing the Environment

valgrind-3.15.0 official website Download: http://valgrind.org/
compiler environment: ubuntu16.04 x64
development platform: TDA2X

After decompressing the file download good valgrind-3.15.0.tar.bz2

tar xvf valgrind-3.15.0.tar.bz2

Install automake 

apt-get install automake 

Run autogen.sh start configuring

valgrind-3.15.0
./autogen.sh

 

Configuration

Modify the configuration file configure, otherwise the configuration specified cross compiler tools, the following error will be reported

checking host system type... arm-unknown-linux-gnu checking for a supported CPU... no (arm) configure: error: Unsupported host architecture. Sorry
 找到armv7修改为 armv7*|arm*

     armv7*)
	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok (${host_cpu})" >&5
$as_echo "ok (${host_cpu})" >&6; }
	ARCH_MAX="arm"
	;;
     armv7*|arm*)
	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok (${host_cpu})" >&5
$as_echo "ok (${host_cpu})" >&6; }
	ARCH_MAX="arm"
	;;

Since we need a cross-compiler compiler is required to specify the configuration tool

 ./configure --host=arm-linux CC=arm-linux-gnueabihf-gcc CPP=arm-linux-gnueabihf-cpp CXX=arm-linux-gnueabihf-g++ --prefix=/opt/valgrind
  1. CC, CPP, g ++ cross compiler arm designated as the version of the compiler
  2. --prefix: Specifies the save path valgrind compiled executable file, note that the path must be consistent with the development board is best stored valgrind's path, or may report " valgrind: failed The Start Tool to 'memcheck' Platform for 'ARM -linux ': No SUCH File or Directory "and other similar error. In fact, however, the problem is essentially the implementation of valgrind, did not find valgrind's lib library! ! ! We can see that there is a layer in the lib directory valgrind below, this time we add a line to the development board / etc / profile file
           
    export VALGRIND_LIB=/opt/valgrind-3.15.0/lib/valgrind
    The following is the lib / valgrind see related libraries
cll@cll-linux:/opt/valgrind-3.15.0/lib/valgrind $ pwd
/opt/valgrind-3.15.0/lib/valgrind
cll@cll-linux:/opt/valgrind-3.15.0/lib/valgrind $ ls
32bit-core-valgrind-s1.xml                mips-cp0-valgrind-s1.xml
32bit-core-valgrind-s2.xml                mips-cp0-valgrind-s2.xml
32bit-core.xml                            mips-cp0.xml
32bit-linux-valgrind-s1.xml               mips-cpu-valgrind-s1.xml
32bit-linux-valgrind-s2.xml               mips-cpu-valgrind-s2.xml
32bit-linux.xml                           mips-cpu.xml
32bit-sse-valgrind-s1.xml                 mips-fpu-valgrind-s1.xml
32bit-sse-valgrind-s2.xml                 mips-fpu-valgrind-s2.xml
32bit-sse.xml                             mips-fpu.xml
64bit-avx-valgrind-s1.xml                 mips-linux-valgrind.xml
64bit-avx-valgrind-s2.xml                 mips-linux.xml
64bit-avx.xml                             none-arm-linux
64bit-core-valgrind-s1.xml                power64-core2-valgrind-s1.xml
64bit-core-valgrind-s2.xml                power64-core2-valgrind-s2.xml
64bit-core.xml                            power64-core-valgrind-s1.xml
64bit-linux-valgrind-s1.xml               power64-core-valgrind-s2.xml
64bit-linux-valgrind-s2.xml               power64-core.xml
64bit-linux.xml                           power64-linux-valgrind-s1.xml
64bit-sse-valgrind-s1.xml                 power64-linux-valgrind-s2.xml
64bit-sse-valgrind-s2.xml                 power64-linux.xml
64bit-sse.xml                             power-altivec-valgrind-s1.xml
amd64-avx-coresse-valgrind.xml            power-altivec-valgrind-s2.xml
amd64-avx-coresse.xml                     power-altivec.xml
amd64-avx-linux-valgrind.xml              power-core-valgrind-s1.xml
amd64-avx-linux.xml                       power-core-valgrind-s2.xml
amd64-coresse-valgrind.xml                power-core.xml
amd64-linux-valgrind.xml                  power-fpu-valgrind-s1.xml
arm-core-valgrind-s1.xml                  power-fpu-valgrind-s2.xml
arm-core-valgrind-s2.xml                  power-fpu.xml
arm-core.xml                              power-linux-valgrind-s1.xml
arm-vfpv3-valgrind-s1.xml                 power-linux-valgrind-s2.xml
arm-vfpv3-valgrind-s2.xml                 power-linux.xml
arm-vfpv3.xml                             powerpc-altivec32l-valgrind.xml
arm-with-vfpv3-valgrind.xml               powerpc-altivec32l.xml
arm-with-vfpv3.xml                        powerpc-altivec64l-valgrind.xml
cachegrind-arm-linux                      powerpc-altivec64l.xml
callgrind-arm-linux                       power-vsx-valgrind-s1.xml
default.supp                              power-vsx-valgrind-s2.xml
dhat-arm-linux                            power-vsx.xml
drd-arm-linux                             s390-acr-valgrind-s1.xml
exp-bbv-arm-linux                         s390-acr-valgrind-s2.xml
exp-sgcheck-arm-linux                     s390-acr.xml
getoff-arm-linux                          s390-fpr-valgrind-s1.xml
helgrind-arm-linux                        s390-fpr-valgrind-s2.xml
i386-coresse-valgrind.xml                 s390-fpr.xml
i386-linux-valgrind.xml                   s390-vx-valgrind-s1.xml
lackey-arm-linux                          s390-vx-valgrind-s2.xml
libcoregrind-arm-linux.a                  s390-vx.xml
libmpiwrap-arm-linux.so                   s390x-core64-valgrind-s1.xml
libreplacemalloc_toolpreload-arm-linux.a  s390x-core64-valgrind-s2.xml
libvex-arm-linux.a                        s390x-core64.xml
libvexmultiarch-arm-linux.a               s390x-generic-valgrind.xml
massif-arm-linux                          s390x-generic.xml
memcheck-arm-linux                        s390x-linux64-valgrind-s1.xml
mips64-cp0-valgrind-s1.xml                s390x-linux64-valgrind-s2.xml
mips64-cp0-valgrind-s2.xml                s390x-linux64.xml
mips64-cp0.xml                            s390x-vx-linux-valgrind.xml
mips64-cpu-valgrind-s1.xml                s390x-vx-linux.xml
mips64-cpu-valgrind-s2.xml                vgpreload_core-arm-linux.so
mips64-cpu.xml                            vgpreload_dhat-arm-linux.so
mips64-fpu-valgrind-s1.xml                vgpreload_drd-arm-linux.so
mips64-fpu-valgrind-s2.xml                vgpreload_exp-sgcheck-arm-linux.so
mips64-fpu.xml                            vgpreload_helgrind-arm-linux.so
mips64-linux-valgrind.xml                 vgpreload_massif-arm-linux.so
mips64-linux.xml                          vgpreload_memcheck-arm-linux.so
cll@cll-linux:/opt/valgrind-3.15.0/lib/valgrind $ 

Of course, we can also = the PATH "/ usr / bin: / usr / sbin: / bin: / sbin: / App / bin: /opt/valgrind-3.15.0/bin ", black for the path of some system configuration (according to you their own profile inside the pATH), was added the red part of the back on the line, source / etc / profile under execution, the command can be used when valgrind

 

Compile

sudo make
sudo make install

run

Copy files to compile the development version, compiled the best directory for the directory can not be found to prevent the library, of course, can

export VALGRIND_LIB=/opt/valgrind-3.15.0/lib/valgrind

Add the path of the current valgrind

export PATH=/opt/valgrind-3.15.0/bin:$PATH

run....

    = the memcheck --leak---tool Valgrind Check = Full ./xxx (require monitoring program)

Published 170 original articles · won praise 207 · Views 4.59 million +

Guess you like

Origin blog.csdn.net/xiaoting451292510/article/details/104931772