最新バージョンの Valgrind 3.7.0 をダウンロードし、解凍してフォルダー「Valgrind-3.7.0」を作成しました。ここで、ターゲット マシンとの互換性のために gcc をエクスポートし、tls を無効にしてホストを与えるように構成しました。また、次のコマンドでコンパイルされた C プログラム「leak.c」とそのオブジェクト ファイル「a.out」を作成しました。
export CC=/usr/local/netd_tools_v1/powerpc/bin/powerpc-linux-gnu-gcc leak.c
それで
a. export CC=/usr/local/netd_tools_v1/powerpc/bin/powerpc-linux-gnu-gcc
b. ./configure --prefix=/netd --host=powerpc-linux --disable-tls
c. make
d. make install
- ライブラリ パスと valgrind 実行可能ファイルをリンクします (/netd/lib に移動して ln –s /u/netd/lib/valgrind を実行し、次に /netd/usr/sbin に移動して ln –s /u/netd/bin/valgrind を実行します)。ファイルは「Valgrind-3.7.0」で作成され、フォルダ「netd」が作成されました。「netd」には「lib」、「bin」、「share」、「include」が含まれていました
(/netd/lib と /netd/usr/sbin はプロジェクト固有のディレクトリです)
これらのファイル (「netd」内のファイル) をターゲット マシンにコピーし、次のコマンドでファイル「a.out」に対して Valgrind を実行しました。
valgrind --log-file=/u/july5.txt --leak-check=summary --tool=memcheck ./a.out
(/u
はマウント ポイント、july5
はログ ファイル)
出力は、報告されたリークが 0 であることを示しています
int main()
{
printf("I am leaking.");
int *a =(int *) malloc(100);
return 0;
}
これは Linux で問題なく実行され、メモリ リークが報告されました。これが機能していれば、プロジェクト固有のプロセスで Valgrind を実行していたでしょう。
a.out の LINUX でのログ ファイルの出力:
[asaini@OTN05 abhaysaini]$ vi xyz.txt
==14843== Memcheck, a memory error detector
==14843== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==14843== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==14843== Command: ./a.out
==14843== Parent PID: 51
61
==14843==
==14843==
==14843== HEAP SUMMARY:
==14843== in use at exit: 100 bytes in 1 blocks
==14843== total heap usage: 1 allocs, 0 frees, 100 bytes allocated
==14843==
==14843== LEAK SUMMARY:
==14843== definitely lost: 100 bytes in 1 blocks
==14843== indirectly lost: 0 bytes in 0 blocks
==14843== possibly lost: 0 bytes in 0 blocks
==14843== still reachable: 0 bytes in 0 blocks
==14843== suppressed: 0 bytes in 0 blocks
==14843== Rerun with --leak-check=full to see details of leaked memory
==14843==
==14843== For counts of detected and suppressed errors, rerun with: -v
==14843== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 11 from 6)
PowerPc でのログ ファイルの出力
[00002003-Unknown] Debug> cat leak.txt
==1208== Memcheck, a memory error detector
==1208== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==1208== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==1208== Command: ./a.out
==1208== Parent PID: 1195
==1208==
--1208-- WARNING: Serious error when reading debug info
--1208-- When reading debug info from /lib/ld-2.3.2.so:
--1208-- Can't make sense of .data section mapping
--1208-- WARNING: Serious error when reading debug info
--1208-- When reading debug info from /u/Leak/a.out:
--1208-- Can't make sense of .data section mapping
--1208-- WARNING: Serious error when reading debug info
--1208-- When reading debug info from /u/netd/lib/valgrind/vgpreload_core-ppc32-linux.so:
--1208-- Can't make sense of .eh_frame section mapping
==1208== Use of uninitialised value of size 4
==1208== at 0x4011E08: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4016517: ???
==1208== by 0x400917F: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4005083: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4006967: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4002C0F: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400DF03: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4001BD3: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400215F: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400EF2B: ??? (in /lib/ld-2.3.2.so)
==1208==
--1208-- WARNING: Serious error when reading debug info
--1208-- When reading debug info from /u/netd/lib/valgrind/vgpreload_memcheck-ppc32-linux.so:
--1208-- Can't make sense of .eh_frame section mapping
--1208-- WARNING: Serious error when reading debug info
--1208-- When reading debug info from /lib/libc-2.3.2.so:
--1208-- Can't make sense of .data section mapping
==1208== Use of uninitialised value of size 4
==1208== at 0x4011CC0: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x7: ???
==1208== by 0x400AB33: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4002ECB: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400DF03: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4001BD3: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400215F: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400EF2B: ??? (in /lib/ld-2.3.2.so)
==1208==
==1208== Use of uninitialised value of size 4
==1208== at 0x4011D38: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x7: ???
==1208== by 0x400AB33: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4002ECB: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400DF03: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4001BD3: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400215F: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400EF2B: ??? (in /lib/ld-2.3.2.so)
==1208==
==1208== Use of uninitialised value of size 4
==1208== at 0x4011D64: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x7: ???
==1208== by 0x400AB33: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4002ECB: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400DF03: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x4001BD3: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400215F: ??? (in /lib/ld-2.3.2.so)
==1208== by 0x400EF2B: ??? (in /lib/ld-2.3.2.so)
==1208==
==1208== Use of uninitialised value of size 4
==1208== at 0x400B958: ??? (in /lib/ld-2.3.2.so)
==1208== by 0xFE8ABE7: ??? (in /lib/libc-2.3.2.so)
==1208== by 0xFE7278B: ??? (in /lib/libc-2.3.2.so)
==1208==
... snip ...
==1208==
==1208== Use of uninitialised value of size 4
==1208== at 0x400BBE0: ??? (in /lib/ld-2.3.2.so)
==1208== by 0xFE8ABE7: ??? (in /lib/libc-2.3.2.so)
==1208== by 0xFE7278B: ??? (in /lib/libc-2.3.2.so)
==1208==
==1208== Use of uninitialised value of size 4
==1208== at 0x400BB0C: ??? (in /lib/ld-2.3.2.so)
==1208== by 0xFE8ABE7: ??? (in /lib/libc-2.3.2.so)
==1208== by 0xFE7278B: ??? (in /lib/libc-2.3.2.so)
==1208==
==1208==
==1208== HEAP SUMMARY:
==1208== in use at exit: 0 bytes in 0 blocks
==1208== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==1208==
==1208== All heap blocks were freed -- no leaks are possible
==1208==
==1208== For counts of detected and suppressed errors, rerun with: -v
==1208== Use --track-origins=yes to see where uninitialised values come from
==1208== ERROR SUMMARY: 40 errors from 20 contexts (suppressed: 3908 from 442)
エラー (リンクhttps://bugs.kde.org/show_bug.cgi?id=290066でパッチを試した後: (by iWerner)
[00002003-Unknown] Debug> cat 1.txt
==1134== Memcheck, a memory error detector
==1134== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==1134== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==1134== Command: ./Leak/a.out
==1134== Parent PID: 1071
==1134==
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: strlen
valgrind: in an object with soname matching: ld.so.1
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld.so.1
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.