Mipsel平台valgrind使用,内存泄漏检测不出来!!!
版本 valgrind3.13.0
mipsel 32 位 小端模式
Ubuntu 16.04 虚拟机 64位
交叉编译工具链 /opt/toolchain-3.4.x/bin/mipsel-linux-uclibc-
交叉编译步骤:
1、./autogen.sh
2、./configure --host=mipsel-linux-gnu CFLAGS="-mips32r2" CC=/opt/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc CXX=/opt/toolchain-3.4.x/bin/mipsel-linux-uclibc-c++ --program-prefix=mipsel-linux-uclibc- --prefix=/opt/home/valgrind
3、make
4、make install
将/opt/home/valgrind目录全部移到开发板/opt/home/下
测试程序:
编写测试程序malloc(128),不释放退出。
在PC上用valgrind测试运行,结果显示有128字节的泄漏
用/opt/toolchain-3.4.x/bin/mipsel-linux-uclibc-gcc编译测试程序,在开发板上用mipsel-linux-uclibc-valgrind运行程序,显示
==1054== Memcheck, a memory error detector
==1054== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1054== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==1054== Command: ./main1
==1054== Parent PID: 968
==1054==
==1054== Invalid write of size 4
==1054== at 0x4000FC0: _start (in /lib/ld-uClibc-0.9.33.2.so)
==1054== by 0x4000F6C: _start (in /lib/ld-uClibc-0.9.33.2.so)
==1054== Address 0x7eeaecdc is on thread 1's stack
==1054== 4 bytes below stack pointer
==1054==
==1054==
==1054== HEAP SUMMARY:
==1054== in use at exit: 0 bytes in 0 blocks
==1054== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==1054==
==1054== All heap blocks were freed -- no leaks are possible
==1054==
==1054== For counts of detected and suppressed errors, rerun with: -v
==1054== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
128字节内存泄漏显示不出来,只是显示内存写错误。