This is how I prepared Valgrind for my ARM device:
1. Download valgrind 3.6.1 and untar the package
2. Download a version of the Code Sourcery toolchain
* I used the Sourcery G++ Lite 2010q1-202 for ARM GNU/Linux
3. Add the Code Sourcery toolchain to the PATH, you'll need it later
$ PATH=<somewhere>/arm-2010q1/bin:$PATH
4. How to cross compile Valgrind:
$ export CROSS_COMPILE=arm-none-linux-gnueabi-
$ export CC=${CROSS_COMPILE}gcc
$ export CPP=${CROSS_COMPILE}cpp
$ export CXX=${CROSS_COMPILE}g++
$ export LD=${CROSS_COMPILE}ld
$ export AR=${CROSS_COMPILE}ar
$
$ ./configure --target=arm-none-linux-gnueabi \
--host=armv7-none-linux-gnueabi \
--prefix=<installation-path> \
CFLAGS=-static
$ make
$ make install
5. Create a directory in your ARM device with the name of the installation path (see above for prefix)
# mkdir -p <installation-path>
6. Copy all the content from the installation in your host machine to the installation patch in your ARM device
7. Add Valgrind binary location to the PATH in your device:
# PATH=<installation-path>/bin:$PATH
8. Now, you are ready to play with Valgrind:
# cat /proc/cpuinfo
Processor: ARMv7 Processor rev 10 (v7l)
# valgrind
valgrind: no program specified
valgrind: Use --help for more information.
# valgrind --version
valgrind-3.6.1
9. Find memory leaks: Quick Start Guide
I got the folllwoing error when using the above command while doing configure :
ReplyDelete--------------------------------------------
checking for gcc... arm-none-linux-gnueabi-gcc
checking whether the C compiler works... no
configure: error: in `valgrind-3.7.0':
configure: error: C compiler cannot create executables
See `config.log' for more details.
------------------------------------------------
you need to be able to write to the . Try issueing the command as root. Or choose another ...
DeleteI think the issue is that you are trying to bit a 32-bit image on 64 bit compiler. You need to change some option to do that.
DeleteIt looks like that the toolchain is not in the Linux PATH variable. Can you confirm that?
ReplyDeleteI followed these steps to port on my ARM target using ArmV7, the porting steps did not give any error, but when i run it on the target board, it gives me error:
ReplyDeleteexplained in my post on stackoverflow: http://stackoverflow.com/questions/12456171/valgrind-port-for-armv7-not-working-properly
Please Advise. I really want to port valgrind successfully to Arm.
Hello
ReplyDeleteI am trying to get valgrind to work on the PANDAboard. I installed Sourcery code bench on my x86 machine and I followed your steps to cross compile valgrind and I did not have a problem. However when I try to run it on the device I get "cannot execute binary file" error. Could you please help
I followed the same steps.. and try running on my target ARM board... following error came... not able to find any solution... please help...
ReplyDeletevalgrind: 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: memcpy
valgrind: in an object with soname matching: ld-linux.so.3
valgrind: was not found whilst processing
valgrind: symbols from the object with soname: ld-linux.so.3
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.
I Really need this to solve.. any one have done this before please help out..
hey did u get the solution ? if yes can u share it with me; coz am also facing the same problem
DeleteThis comment has been removed by the author.
Deletei have cross compiled the valgrind for the Android
ReplyDeleteand copied to my target device, and while launch it's giving me below error
error:
shell@android:/ # valgrind
sh: /data/Inst/bin/valgrind: not executable: magic 7F45
please provide me the solution soon
Hello,
ReplyDeleteI followed the same step to build valgrind for ARM v7 target board. But while running valgrind on my target, i am getting error "valgrind: failed to start tool 'memcheck' for platform 'arm-linux': No such file or directory"
Please provide info to fix this
export VALGRIND_LIB to the location where you have copied lib/valgrind/
DeleteI HIGHLY recommend keeping prefix as / or /usr and using make DESTDIR= install. This keeps pathing errors from happening.
ReplyDeleteHi All,
ReplyDeleteI followed below steps:
root@rajesh-dt:/home/rajeshsingh/Downloads/valgrind-3.12.0# sudo ./configure --host=powerpc-pc-linux LDFLAGS=-static CC=/opt/ELDK42/usr/bin/ppc_85xx-gcc CXX=/opt/ELDK42/usr/bin/ppc_85xx-g++ --enable-tls --prefix=/home/rajeshsingh/valgrind_3101/ --exec-prefix=/home/rajeshsingh/valgrind_3101/
sudo make
sudo make install
Now on the device while running the valgrind getting below error:
bash-4.3#
bash-4.3# /etc/bin/valgrind /tmp/switch.d
==1934== Memcheck, a memory error detector
==1934== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==1934== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info
==1934== Command: /tmp/switch.d
==1934==
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: Note that if you are debugging a 32 bit process on a
valgrind: 64 bit system, you will need a corresponding 32 bit debuginfo
valgrind: package (e.g. libc6-dbg:i386).
valgrind:
valgrind: Cannot continue -- exiting now. Sorry.
bash-4.3#
I tried number of ways to solve it betting same error everytimes.
Please let me know if anyone have some solutions for it.
Thanks,
Rajesh
It's urgent for me to resolve this issue. Please let me know the solution.
ReplyDeleteI would like to thanks all of you.
I'm a beginner for open source porting, please give the idea for how to configure , cross compile and run the valgrind in ARMv7 platform.
ReplyDeleteThanks,
VMS
example: when u want to use hard float.
ReplyDeletefirst export your tool chain path as shownb below.
export PATH=/home/montavista/tools/armhfp-gnueabi/bin:$PATH
export CROSS=arm-montavista-linux-gnueabi-
export CC='arm-montavista-linux-gnueabi-gcc -mfloat-abi=hard'
export CXX='arm-montavista-linux-gnueabi-g++ -mfloat-abi=hard'
export LD=${CROSS}ld
export AR=${CROSS}ar
#dont modify below line
./configure --target=arm-none-linux-gnueabi --host=armv7-none-linux-gnueabi --prefix=/tmp/valgrind CFLAGS=-fPIC
make && make install
#u will find the binaries at /tmp/valgrind