Valgrind ARMv6 (working)


26 posts   Page 1 of 2   1, 2
by Baranyk » Wed Jun 06, 2012 10:56 pm
I'm starting this thread to post some information collected in the hope that anybody who might be working on the Valgrind ARMv6 port might gleam some information from it, or perhaps contribute some of their own.

Old Thread from Old Nabble:
http://old.nabble.com/Does-Valgrind--3.6.0-(or-3.6.1)-support-ARMv6---p30971334.html

Valgrind Manual Core:
http://valgrind.org/docs/manual/manual-core.html

I'll investigate the package itself a bit further tomorrow.
Posts: 7
Joined: Sat Jun 02, 2012 6:32 pm
Location: Pennsylvania, USA
by dom » Wed Jun 06, 2012 11:07 pm
I couldn't get valgrind running on ARM.

I did find electric fence (http://linux.die.net/man/3/efence) works and helped me find a bug with a freed buffer being used.
No profiling features though.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3993
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Baranyk » Thu Jun 07, 2012 2:55 pm
Found this gem.

http://old.nabble.com/for-the-poor-armv6-users-td31888031.html

If anybody gives this a shot, let post a reply here and let us know what you come up with. Otherwise, I'll give it a shot as soon as I can.
Posts: 7
Joined: Sat Jun 02, 2012 6:32 pm
Location: Pennsylvania, USA
by Baranyk » Thu Jun 07, 2012 3:28 pm
Apparently we can't edit our past posts, or if we can, I can't find it.

http://www.mail-archive.com/valgrind-users@lists.sourceforge.net/msg03218.html

Another person working on the ARMv6 port.
Posts: 7
Joined: Sat Jun 02, 2012 6:32 pm
Location: Pennsylvania, USA
by hawtshawt » Thu Jul 26, 2012 7:07 am
Has anyone had any luck with getting Valgrind to work yet? Each time i try to ./configure it throws up a red flag at

checking for a supported CPU... no (armv61)
configure: error: Unsupported host architecture. Sorry.

...at least they apologized though right?

I see the nabble.com link does have quite a promising outlook, but I'll be honest...i have no idea what to do with all of that code :/
Posts: 8
Joined: Tue Mar 20, 2012 7:06 am
by Serac » Sat Sep 01, 2012 9:33 pm
Baranyk wrote:Found this gem.

http://old.nabble.com/for-the-poor-armv6-users-td31888031.html

If anybody gives this a shot, let post a reply here and let us know what you come up with. Otherwise, I'll give it a shot as soon as I can.


Applied that patch along with a couple of minor tweaks to two of the Makefile.am files. It compiles and when running, appears to detect at least one fault in some code I'm debugging.
Posts: 124
Joined: Wed Jul 18, 2012 2:49 pm
by mahjongg » Sat Sep 01, 2012 9:58 pm
Baranyk wrote:Apparently we can't edit our past posts, or if we can, I can't find it.
You can only edit your post for a short time after you posted, or until someone else posts.
User avatar
Forum Moderator
Forum Moderator
Posts: 4902
Joined: Sun Mar 11, 2012 12:19 am
by apophys » Wed Dec 12, 2012 1:25 pm
Serac wrote:
Baranyk wrote:Found this gem.

http://old.nabble.com/for-the-poor-armv6-users-td31888031.html

If anybody gives this a shot, let post a reply here and let us know what you come up with. Otherwise, I'll give it a shot as soon as I can.


Applied that patch along with a couple of minor tweaks to two of the Makefile.am files. It compiles and when running, appears to detect at least one fault in some code I'm debugging.


Hi Serac,

Could you please give more details on how you proceeded? I'm trying to compile valgrind and I keep slamming on various errors.
Posts: 4
Joined: Wed Dec 12, 2012 1:22 pm
by kintrob » Fri Dec 21, 2012 1:36 pm
Hi,

Looks like valgrind does compile after applying the patch above. Leaving a step by step guide below for those who find it useful

1. Checking out revision 11823 (with VEX dependency)
{from http://church.cs.virginia.edu/genprog/index.php/Valgrind}
Code: Select all
$ mkdir valgrind-svn
$ cd valgrind-svn
$ svn co svn://svn.valgrind.org/valgrind/trunk valgrind
$ cd valgrind
$ svn up -r 11823
$ DATE=`svn info | sed -n '/^Last Changed Date/s/.*: \(.*\)(.*/\1/p' | awk '{print $1}'`
$ svn up --force -r "{$DATE}" VEX >& /dev/null


2. Applying the patch
{from http://valgrind.10908.n7.nabble.com/for-the-poor-armv6-users-td19828.html}
Code: Select all
$ sudo patch < armv6-reintr.patch
patching file Makefile.all.am
patching file configure.in
can't find file to patch at input line 64
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|Index: coregrind/m_dispatch/dispatch-arm-linux.S
|===================================================================
|--- coregrind/m_dispatch/dispatch-arm-linux.S   (revision 11823)
|+++ coregrind/m_dispatch/dispatch-arm-linux.S   (working copy)
--------------------------
File to patch: ./coregrind/m_dispatch/dispatch-arm-linux.S  [needed to type the location manually here]
patching file ./coregrind/m_dispatch/dispatch-arm-linux.S


3. Fixing Makefile.am
{from: http://bugs.mysql.com/bug.php?id=63898}
This step is to prevent this error:
coregrind/Makefile.am:473: `pkglibdir' is not a legitimate directory for `DATA'
Makefile.am:62: `pkglibdir' is not a legitimate directory for `DATA'
error: while running 'automake -a'

Run:
Code: Select all
$ fgrep -rlZ pkglib_DATA --include Makefile.am . | xargs -0 sed -i 's/pkglib_DATA/pkgdata_DATA/g'


4. Compiling
[autogen takes about 10 mins]
Code: Select all
$ sh autogen.sh
running: aclocal
running: autoheader
running: automake -a
running: autoconf


Code: Select all
$ sh configure --prefix=[choose your install location here, absolute path]
...
config.status: executing depfiles commands

         Maximum build arch: arm
         Primary build arch: arm
       Secondary build arch:
                   Build OS: linux
       Primary build target: ARM_LINUX
     Secondary build target:
         Default supp files: exp-sgcheck.supp xfree-3.supp xfree-4.supp glibc-2.X-drd.supp glibc-2.34567-NPTL-helgrind.supp glibc-2.X.supp


[go take a nap, this one below takes about 1 hour]
Code: Select all
$ sudo make --quiet
Making all in include
Making all in VEX
[About a dozen warnings here]
Making all in .
Making all in memcheck
Making all in .
Making all in tests
Making all in .
Making all in linux
Making all in perf
Making all in cachegrind
Making all in .
Making all in tests
Making all in .
Making all in callgrind
Making all in .
Making all in tests
Making all in .
Making all in massif
Making all in .
Making all in tests
Making all in perf
Making all in lackey
Making all in .
Making all in tests
Making all in none
Making all in .
Making all in tests
Making all in .
Making all in arm
Making all in linux
Making all in helgrind
Making all in .
Making all in tests
Making all in drd
Making all in .
Making all in tests
Making all in exp-sgcheck
Making all in .
Making all in tests
Making all in exp-bbv
Making all in .
Making all in tests
Making all in .
Making all in arm-linux
Making all in exp-dhat
Making all in .
Making all in tests
Making all in tests
Making all in perf
Making all in gdbserver_tests
Making all in auxprogs
Making all in mpi
Making all in docs


Code: Select all
$ sudo make install


5. Run

Code: Select all
$ valgrind date
==12035== Memcheck, a memory error detector
==12035== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==12035== Using Valgrind-3.7.0.SVN and LibVEX; rerun with -h for copyright info
==12035== Command: date
==12035==
==12035== Conditional jump or move depends on uninitialised value(s)
==12035==    at 0x400BE9C: ??? (in /lib/arm-linux-gnueabihf/ld-2.13.so)
==12035==
==12035== Conditional jump or move depends on uninitialised value(s)
==12035==    at 0x400BED8: ??? (in /lib/arm-linux-gnueabihf/ld-2.13.so)
==12035==
==12035== Conditional jump or move depends on uninitialised value(s)
==12035==    at 0x400CC10: ??? (in /lib/arm-linux-gnueabihf/ld-2.13.so)
==12035==
==12035== Conditional jump or move depends on uninitialised value(s)
==12035==    at 0x400BD38: ??? (in /lib/arm-linux-gnueabihf/ld-2.13.so)
==12035==
==12035== Conditional jump or move depends on uninitialised value(s)
==12035==    at 0x400BD40: ??? (in /lib/arm-linux-gnueabihf/ld-2.13.so)
==12035==
Fri Dec 21 10:22:01 ART 2012
==12035==
==12035== HEAP SUMMARY:
==12035==     in use at exit: 0 bytes in 0 blocks
==12035==   total heap usage: 37 allocs, 37 frees, 2,766 bytes allocated
==12035==
==12035== All heap blocks were freed -- no leaks are possible
==12035==
==12035== For counts of detected and suppressed errors, rerun with: -v
==12035== Use --track-origins=yes to see where uninitialised values come from
==12035== ERROR SUMMARY: 19 errors from 5 contexts (suppressed: 0 from 0)


If valgrind complaints about missing supp file, copy it over to the expected location:
Code: Select all
$ sudo cp valgrind/default.supp /usr/local/lib/valgrind
Posts: 3
Joined: Fri Dec 21, 2012 1:02 pm
by Unhban » Sun Dec 23, 2012 4:37 pm
Thanks! Would like to try this, but fell at the first hurdle! With the error:

svn: command not found

Googled it and needed to do a
Code: Select all
sudo apt-get install subversion


Hope this helps others ! :)
Posts: 53
Joined: Sun Oct 14, 2012 10:58 am
by apophys » Sun Dec 23, 2012 4:46 pm
kintrob wrote:Hi,

Looks like valgrind does compile after applying the patch above. Leaving a step by step guide below for those who find it useful



Thank you, your detailed guide was perfect! I finally got valgrind working on the Raspberry Pi.

I was missing the steps in panel #1, after `svn co`.

The specific Raspberry ioctl's are not implemented yet for valgrind, but that's only a minor detail.
Posts: 4
Joined: Wed Dec 12, 2012 1:22 pm
by Unhban » Sun Dec 23, 2012 4:53 pm
In Part 4 I got a

autogen.sh: 1: eval: aclocal: not found

Googling soon brought up I had to do a

Code: Select all
sudo apt-get install automake

:)
Posts: 53
Joined: Sun Oct 14, 2012 10:58 am
by Unhban » Sun Dec 23, 2012 11:24 pm
Hi! All seemed to work and make OK, but when I use

Code: Select all
valgrind date

I get

-bash: valgrind: command not found

Any ideas?
Posts: 53
Joined: Sun Oct 14, 2012 10:58 am
by apophys » Sun Dec 23, 2012 11:27 pm
did you do 'make install' ?
Posts: 4
Joined: Wed Dec 12, 2012 1:22 pm
by plugwash » Mon Dec 24, 2012 1:20 am
kintrob, do you know if it's possible to use the patch with one of the versions of valgrind currently in debian (either 3.7.0 or 3.8.1)?
Forum Moderator
Forum Moderator
Posts: 2170
Joined: Wed Dec 28, 2011 11:45 pm
by Unhban » Mon Dec 24, 2012 11:41 am
apophys wrote:did you do 'make install' ?

Hi! Yes, did make install.

Found the answer - I had to go into the bin directory and do a
Code: Select all
./valgrind date

Sorry, not very good with Linux! Fumbling.... :)

Unh.
Posts: 53
Joined: Sun Oct 14, 2012 10:58 am
by plugwash » Mon Dec 24, 2012 4:51 pm
Ok well I went ahead and applied the patch to the debian wheezy source package and after some work beating the packaging into submission I managed to get a valgrind package that passes our contamination checker and seems to work. So I uploaded it to the repository. It should be available after the next mirror pulse.
Forum Moderator
Forum Moderator
Posts: 2170
Joined: Wed Dec 28, 2011 11:45 pm
by dom » Mon Dec 24, 2012 4:54 pm
plugwash wrote:Ok well I went ahead and applied the patch to the debian wheezy source package and after some work beating the packaging into submission I managed to get a valgrind package that passes our contamination checker and seems to work. So I uploaded it to the repository. It should be available after the next mirror pulse.

Thanks. This could be useful.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 3993
Joined: Wed Aug 17, 2011 7:41 pm
Location: Cambridge
by Unhban » Mon Dec 24, 2012 4:59 pm
plugwash wrote:Ok well I went ahead and applied the patch to the debian wheezy source package and after some work beating the packaging into submission I managed to get a valgrind package that passes our contamination checker and seems to work. So I uploaded it to the repository. It should be available after the next mirror pulse.

@plugwash Can I ask if the Package will create the same directories and files as the ones I've produced following the above? Or doesn't it work like that?
Posts: 53
Joined: Sun Oct 14, 2012 10:58 am
by plugwash » Mon Dec 24, 2012 5:03 pm
The package will install the parts of valgrind in the standard debian locations. These are likely to be different from what you will end up with after a manual install from upstream sources
Forum Moderator
Forum Moderator
Posts: 2170
Joined: Wed Dec 28, 2011 11:45 pm
by Unhban » Mon Dec 24, 2012 5:22 pm
plugwash wrote:The package will install the parts of valgrind in the standard debian locations. These are likely to be different from what you will end up with after a manual install from upstream sources

Thanks plugwash. So from your experience would you say it's best to remove the present directories and files and install the package? From my limited experience perhaps it would be best to do this? So that if there's any updates/changes they automatically and easily get incorporated?
Posts: 53
Joined: Sun Oct 14, 2012 10:58 am
by aaa801 » Mon Dec 24, 2012 7:27 pm
I had valgrind working on armv6, it was part of the jellybean build, had to patch some of the asm functions
i believe this is the patch i used
http://valgrind.10908.n7.nabble.com/att ... intr.patch
Posts: 427
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire
by plugwash » Mon Dec 24, 2012 10:12 pm
plugwash wrote:Ok well I went ahead and applied the patch to the debian wheezy source package and after some work beating the packaging into submission I managed to get a valgrind package that passes our contamination checker and seems to work. So I uploaded it to the repository. It should be available after the next mirror pulse.

Unfortunately this hasn't made it into raspbian wheezy yet due to a number of issues on our end, i'll post back when I get it to go through.
Forum Moderator
Forum Moderator
Posts: 2170
Joined: Wed Dec 28, 2011 11:45 pm
by plugwash » Mon Dec 24, 2012 11:38 pm
Ok the new valgrind package is now in raspbian wheezy on the public server.
Forum Moderator
Forum Moderator
Posts: 2170
Joined: Wed Dec 28, 2011 11:45 pm
by kintrob » Wed Dec 26, 2012 12:13 pm
plugwash wrote:kintrob, do you know if it's possible to use the patch with one of the versions of valgrind currently in debian (either 3.7.0 or 3.8.1)?


Sorry plugwash...was out in the countryside during Christmas and just saw this. Happy to see you succeeded and made it available in the public server. Thanks!
Posts: 3
Joined: Fri Dec 21, 2012 1:02 pm