Valgrind cross compile for arm 32 bit board - orange pi
Valgrind cross compile for arm 32 bit board - orange pi
Q. How to cross compile valgrind for ARM on x86 ubuntu machine ?
这是一个独立的过程,假设您正在 x86_64 Ubuntu Linux 机器上构建。如果不是这种情况,只需为 Linux 发行版中可用的 arm-none-linux-gnueabihf
目标安装交叉编译器,确保它在您的路径中,并相应地修改 configure
命令。
PC端:
# downloading/installing toolchain
wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz?revision=d0b90559-3960-4e4b-9297-7ddbc3e52783&la=en&hash=985078B758BC782BC338DB947347107FBCF8EF6B
sudo mkdir -p /opt/arm/10
sudo tar Jxf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz -C /opt/arm/10
# downloading/extracting valgrind
wget https://sourceware.org/pub/valgrind/valgrind-3.16.1.tar.bz2
tar jxf valgrind-3.16.1.tar.bz2
# building
export PATH=/opt/arm/10/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin:$PATH
mdkir valgrind
cd valgrind
../valgrind-3.16.1/configure --host=arm-none-linux-gnueabihf --prefix=$(pwd)/valgrind-3.16.1-arm-none-linux-gnueabihf
make all install
橙皮上:
将PC上valgrind-3.16.1-arm-none-linux-gnueabihf
目录及其子目录的内容复制到橙皮的/usr/local目录下。
安装libc6-dbg
(假设你是运行 Ubuntu or Debian on your Orangepi):apt-get install libc6-dbg
使用提供的程序进行测试here:
wget http://cs.ecs.baylor.edu/~donahoo/tools/valgrind/test.c
gcc -o test -g test.c
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./test
==2034== Memcheck, a memory error detector
==2034== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2034== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2034== Command: ./test
==2034==
==2034==
==2034== FILE DESCRIPTORS: 3 open at exit.
==2034== Open file descriptor 2: /dev/ttyS0
==2034== <inherited from parent>
==2034==
==2034== Open file descriptor 1: /dev/ttyS0
==2034== <inherited from parent>
==2034==
==2034== Open file descriptor 0: /dev/ttyS0
==2034== <inherited from parent>
==2034==
==2034==
==2034== HEAP SUMMARY:
==2034== in use at exit: 35 bytes in 2 blocks
==2034== total heap usage: 3 allocs, 1 frees, 47 bytes allocated
==2034==
==2034== 16 bytes in 1 blocks are definitely lost in loss record 1 of 2
==2034== at 0x484A4B0: malloc (vg_replace_malloc.c:307)
==2034== by 0x1087DB: main (test.c:15)
==2034==
==2034== 19 bytes in 1 blocks are definitely lost in loss record 2 of 2
==2034== at 0x484A4B0: malloc (vg_replace_malloc.c:307)
==2034== by 0x1087BB: main (test.c:8)
==2034==
==2034== LEAK SUMMARY:
==2034== definitely lost: 35 bytes in 2 blocks
==2034== indirectly lost: 0 bytes in 0 blocks
==2034== possibly lost: 0 bytes in 0 blocks
==2034== still reachable: 0 bytes in 0 blocks
Q. How to cross compile valgrind for ARM on x86 ubuntu machine ?
这是一个独立的过程,假设您正在 x86_64 Ubuntu Linux 机器上构建。如果不是这种情况,只需为 Linux 发行版中可用的 arm-none-linux-gnueabihf
目标安装交叉编译器,确保它在您的路径中,并相应地修改 configure
命令。
PC端:
# downloading/installing toolchain
wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz?revision=d0b90559-3960-4e4b-9297-7ddbc3e52783&la=en&hash=985078B758BC782BC338DB947347107FBCF8EF6B
sudo mkdir -p /opt/arm/10
sudo tar Jxf gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf.tar.xz -C /opt/arm/10
# downloading/extracting valgrind
wget https://sourceware.org/pub/valgrind/valgrind-3.16.1.tar.bz2
tar jxf valgrind-3.16.1.tar.bz2
# building
export PATH=/opt/arm/10/gcc-arm-10.2-2020.11-x86_64-arm-none-linux-gnueabihf/bin:$PATH
mdkir valgrind
cd valgrind
../valgrind-3.16.1/configure --host=arm-none-linux-gnueabihf --prefix=$(pwd)/valgrind-3.16.1-arm-none-linux-gnueabihf
make all install
橙皮上:
将PC上valgrind-3.16.1-arm-none-linux-gnueabihf
目录及其子目录的内容复制到橙皮的/usr/local目录下。
安装libc6-dbg
(假设你是运行 Ubuntu or Debian on your Orangepi):apt-get install libc6-dbg
使用提供的程序进行测试here:
wget http://cs.ecs.baylor.edu/~donahoo/tools/valgrind/test.c
gcc -o test -g test.c
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./test
==2034== Memcheck, a memory error detector
==2034== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==2034== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==2034== Command: ./test
==2034==
==2034==
==2034== FILE DESCRIPTORS: 3 open at exit.
==2034== Open file descriptor 2: /dev/ttyS0
==2034== <inherited from parent>
==2034==
==2034== Open file descriptor 1: /dev/ttyS0
==2034== <inherited from parent>
==2034==
==2034== Open file descriptor 0: /dev/ttyS0
==2034== <inherited from parent>
==2034==
==2034==
==2034== HEAP SUMMARY:
==2034== in use at exit: 35 bytes in 2 blocks
==2034== total heap usage: 3 allocs, 1 frees, 47 bytes allocated
==2034==
==2034== 16 bytes in 1 blocks are definitely lost in loss record 1 of 2
==2034== at 0x484A4B0: malloc (vg_replace_malloc.c:307)
==2034== by 0x1087DB: main (test.c:15)
==2034==
==2034== 19 bytes in 1 blocks are definitely lost in loss record 2 of 2
==2034== at 0x484A4B0: malloc (vg_replace_malloc.c:307)
==2034== by 0x1087BB: main (test.c:8)
==2034==
==2034== LEAK SUMMARY:
==2034== definitely lost: 35 bytes in 2 blocks
==2034== indirectly lost: 0 bytes in 0 blocks
==2034== possibly lost: 0 bytes in 0 blocks
==2034== still reachable: 0 bytes in 0 blocks