1. 下载最新的valgrind,一般是首页里直接下载即可。
3.
Oracle VM VirtualBox虚拟机启动fedora系统(最好用root登录,不行也要在终端中输入sudo -s成为超级用户)。
4.虚拟机加载共享文件夹进入命令行,mount -t vboxsf sharefile /mnt,即将共享文件夹挂载到了/mnt。
5.在fedora系统中,启动资源管理器,找到File System下面的mnt文件夹,拷贝其中的文件到UserHD下面(为交叉编译做准备,目录可以改)
6.命令行 cd /media/UserHD/valgrind-3.10.1
./autogen.sh
./configure
--host=arm-linux CC=arm-none-linux-gnueabi-gcc CPP=arm-none-linux-gnueabi-cpp
CXX=arm-none-linux-gnueabi-g++ --prefix=/mnt/sdcard/valgrind
make
make install
7.到/mnt/sdcard/valgrind中去查看生成好的valgrind,其包括4个文件夹:bin,include,lib,share.
8.拷贝/mnt/sdcard/valgrind文件夹到arm板的相同路径下,运行即可。
目前valgrind工具实现了交叉编译,但在使用时还有问题。
我编译后,发现无问题,并且发现生成了目标代码与/mnt/sdcard/valgrind中。
但是我在make后通过make check却发现有问题。显示如下:
///////////////////////////////////////////////////////////////////////
/tmp/ccwMn2TO.s: Assembler messages:
/tmp/ccwMn2TO.s:182: Error: selected processor does not support ARM mode `ldrexb r8,[r9]'
/tmp/ccwMn2TO.s:184: Error: selected processor does not support ARM mode `strexb r4,r8,[r9]'
/tmp/ccwMn2TO.s:244: Error: selected processor does not support ARM mode `ldrexh r8,[r9]'
/tmp/ccwMn2TO.s:246: Error: selected processor does not support ARM mode `strexh r4,r8,[r9]'
/tmp/ccwMn2TO.s:306: Error: selected processor does not support ARM mode `ldrex r8,[r9]'
/tmp/ccwMn2TO.s:308: Error: selected processor does not support ARM mode `strex r4,r8,[r9]'
/tmp/ccwMn2TO.s:372: Error: selected processor does not support ARM mode `ldrexd r0,r1,[r8]'
/tmp/ccwMn2TO.s:375: Error: selected processor does not support ARM mode `strexd r1,r2,r3,[r8]'
make[5]: *** [atomic_incs-atomic_incs.o] Error 1
make[5]: Leaving directory `/media/UserHD/valgrind-3.8.1/memcheck/tests'
make[4]: *** [check-am] Error 2
make[4]: Leaving directory `/media/UserHD/valgrind-3.8.1/memcheck/tests'
make[3]: *** [check-recursive] Error 1
make[3]: Leaving directory `/media/UserHD/valgrind-3.8.1/memcheck/tests'
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory `/media/UserHD/valgrind-3.8.1/memcheck'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/media/UserHD/valgrind-3.8.1'
make: *** [check] Error 2
/////////////////////////////////////////////////////////////////////////
由于make结束后没有报错,我即认为虽有错误但不至于影响使用,遂将代码拷贝到arm开发板中去,但执行出错,显示: "Illegal instruction."
root@scy:/app # strace valgrind ./scy -qws
execve("/usr/bin/valgrind", ["valgrind", "./scy", "-qws"], [/* 26 vars */]) = 0
brk(0) = 0x14000
uname({sys="Linux", node="scy", ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f5c000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/fast-mult/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v5l/fast-mult/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/fast-mult/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v5l/fast-mult", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v5l/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/v5l/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/v5l", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/fast-mult/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/fast-mult/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/fast-mult/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/fast-mult", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/tls/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/tls", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/v5l/fast-mult/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/v5l/fast-mult/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/v5l/fast-mult/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/v5l/fast-mult", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/v5l/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/v5l/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/v5l/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/v5l", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/fast-mult/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/fast-mult/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/fast-mult/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/fast-mult", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/half/libgcc_s.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat64("/lib/half", 0xbed67228) = -1 ENOENT (No such file or directory)
open("/lib/libgcc_s.so.1", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0p'\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=68281, ...}) = 0
mmap2(NULL, 77748, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f24000
mprotect(0xb6f2f000, 28672, PROT_NONE) = 0
mmap2(0xb6f36000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xa) = 0xb6f36000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\354V\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1743092, ...}) = 0
mmap2(NULL, 1344756, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6ddb000
mprotect(0xb6f16000, 32768, PROT_NONE) = 0
mmap2(0xb6f1e000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13b) = 0xb6f1e000
mmap2(0xb6f21000, 9460, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f21000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f5b000
set_tls(0xb6f5b6d0, 0xb6f5bda8, 0xb6f5be28, 0xb6f5b6d0, 0xb6f5e000) = 0
mprotect(0xb6f1e000, 8192, PROT_READ) = 0
mprotect(0xb6f5d000, 4096, PROT_READ) = 0
--- {si_signo=SIGILL, si_code=ILL_ILLOPC, si_addr=0x9010} (Illegal instruction) ---
+++ killed by SIGILL +++
Illegal instruction
以上使用strace分析得到的结果,应该是CPU配置的问题,但是还没有解决。
参考: />