• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Valgrind移植

互联网 diligentman 1周前 (10-18) 14次浏览

Valgrind移植与使用教程

源码版本:valgrind-3.16.1.tar.bz2

ubutun版本:20.04

交叉编译链:arm-none-linux-gnueabi-

交叉编译命令介绍:

configure配置说明 说明
–build 执行代码编译的主机
–host 程序最终要运行的主机
–target 用build主机上的编译器,编译一个新的编译器( 如gcc),这个新的编译器将来编译出来的其他程序将运行在target指定的系统上
–prefix 指定编译出来的版本存放路径,默认放在“/usr /local/bin”
CC CXX CPP 交叉编译器配置CC=arm-none-linux-gnueabi-cc CPP=arm-none-linux-gnueabi-cpp CXX=arm-none-linux-gnueabi-g++

安装步骤:

编译linux版本

1.解压并运行valgrind自动make脚本

vmuser@vmuser-virtual-machine:tar jxvf valgrind-3.16.1.tar.bz2
vmuser@vmuser-virtual-machine:~/valgrind-3.16.1$ sudo apt-get install automake
vmuser@vmuser-virtual-machine:~/valgrind-3.16.1$ ./autogen.sh

2.configure

vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ mkdir install 
vmuser@vmuser-virtual-machine:~/valgrind-3.16.1$ ./configure --prefix=/home/vmuser/valgrind-3.16.1/install/

3.make

vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ make
vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ make install

编译ARM版本

1.编译之前先make clean

2.修改 configure 文件:

vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ mkdir install_arm
vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ ./configure --host=arm-linux CC=arm-none-linux-gnueabi-cc CPP=arm-none-linux-gnueabi-cpp CXX=arm-none-linux-gnueabi-g++ --prefix= --prefix=/home/vmuser/valgrind-3.16.1/install_arm/

报错

checking host system type... arm-unknown-linux-gnu
checking for a supported CPU... no (arm)
configure: error: Unsupported host architecture. Sorry

修改configure 把armv7a* 改为 arm* 再次配置configure

vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ ./configure --host=arm-linux CC=arm-none-linux-gnueabi-cc CPP=arm-none-linux-gnueabi-cpp CXX=arm-none-linux-gnueabi-g++ --prefix= --prefix=/home/vmuser/valgrind-3.16.1/install_arm/

//注意:–prefix=/mnt指定的目录要与开发板上放置的目录一致,不然运行valgrind时可能会出现“valgrind: failed to start tool ‘memcheck’ for platform ‘arm-Linux’: No such file or directory”错误。

3.编译安装

vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ make
vmuser@vmuser-virtual-machine:~/valgrimakend-3.16.1$ make install

4.移植到arm开发

将/home/vmuser/valgrind-3.16.1/install_arm/目前下文件复制到arm同级目录下;

将/home/vmuser/valgrind-3.16.1/install_arm/bin/valgrind文件复制到/bin目录下。

root@freescale /home/vmuser/valgrind-3.16.1$ valgrind --help
usage: valgrind [options] prog-and-args

  tool-selection option, with default in [ ]:
    --tool=<name>             use the Valgrind tool named <name> [memcheck]

  basic user options for all Valgrind tools, with defaults in [ ]:
    -h --help                 show this message
    --help-debug              show this message, plus debugging options
    --help-dyn-options        show the dynamically changeable options
    --version                 show version
    -q --quiet                run silently; only print error msgs
    -v --verbose              be more verbose -- show misc extra info
    --trace-children=no|yes   Valgrind-ise child processes (follow execve)? [no]
    --trace-children-skip=patt1,patt2,...    specifies a list of executables
                              that --trace-children=yes should not trace into
    --trace-children-skip-by-arg=patt1,patt2,...   same as --trace-children-skip=
                              but check the argv[] entries for children, rather
                              than the exe name, to make a follow/no-follow decision
    --child-silent-after-fork=no|yes omit child output between fork & exec? [no]
    --vgdb=no|yes|full        activate gdbserver? [yes]
                              full is slower but provides precise watchpoint/step
    --vgdb-error=<number>     invoke gdbserver after <number> e


程序员灯塔
转载请注明原文链接:https://www.wangt.cc/2020/10/valgrind%e7%a7%bb%e6%a4%8d/
喜欢 (0)