valgrind 在mips平台移植编译+使用总结
2. 使用问题汇总说明
2.1. 问题1(Segmentation fault)
运行程序直接报“segmentation fault”,分析是valgrind本身运行mips平台的程序时出错导致。
# ./valgrind --tool=memcheck --leak-check=full --show-reachable=yes ./tz_packtoolpro
==17683== Memcheck, a memory error detector
==17683== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==17683== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==17683== Command: ./tz_packtoolpro
==17683==
Segmentation fault
#
解决办法:
原来编译OK的版本是3.11,更新到3.13的版本再进行编译,运行就不会出现这个错误了。初步怀疑,valgrind对mips平台的兼容性还是不够。
另外如果使用V3.14以上的版本,编译时则会报另外的错误(opcode)。
2.2. 问题2(at 0x4000FF0: ??? (in /lib/ld-uClibc-0.9.33.so))
解决问题1后,出现以下问题。
# ./valgrind --tool=memcheck --leak-check=full --show-reachable=yes /bin/tz_
tz_ftpserver tz_log_backup tz_mgr tz_upgrade_client
# ./valgrind --tool=memcheck --leak-check=full --show-reachable=yes /bin/getkmsg
==18639== Memcheck, a memory error detector
==18639== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==18639== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==18639== Command: /bin/getkmsg
==18639==
==18639== Invalid write of size 4
==18639== at 0x4000FF0: ??? (in /lib/ld-uClibc-0.9.33.so)
==18639== by 0x4000F9C: ??? (in /lib/ld-uClibc-0.9.33.so)
==18639== Address 0x7ee6be0c is on thread 1's stack
==18639== 4 bytes below stack pointer
==18639==
==18639== Conditional jump or move depends on uninitialised value(s)
==18639== at 0x4B0E058: ??? (in /lib/libuClibc-0.9.33.so)
==18639== by 0x4B0A0A0: ??? (in /lib/libuClibc-0.9.33.so)
==18639==
==18639== Conditional jump or move depends on uninitialised value(s)
==18639== at 0x4B0DD60: ??? (in /lib/libuClibc-0.9.33.so)
==18639== by 0x481A0AC: ??? (in /lib/libmdlbase.so)
==18639==
解决办法
1)需要将链接的库都改为 not stripped,另外最好在编译时增加-g的选项