1

I'm using Ubuntu 18.04 VM and trying to find a way to valgrind check an arm-Linux executable. I've tried compiling with local gcc but ran into some problems. The executable is created by Makefile provided from project. I've tried linaro emulator, following guides online, but faced multiple issues which for each one I've searched on online for solutions but all failed. What are the ways I can valgrind?

As long as I can check program for memory leak, any way is fine. What I get when I valgrind executable now:

valgrind: failed to start tool 'memcheck' for platform 'arm-linux': No such file or directory

The file it self is fyi: nrf52832_xxaa.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

I've searched through multiple posts for solutions but couldn't find any.

Anarchira
  • 13
  • 7

2 Answers2

2

Cross compile valgrind, and execute on the target. There are no other ways. Can't even use qemu to execute valgrind.

BЈовић
  • 62,405
  • 41
  • 173
  • 273
  • How would you go about cross compiling valgrind? I'm new to all this. – Anarchira Jan 13 '20 at 16:12
  • @Anarchira How do you build the image? With yocto? If yes, then just include the recipe in the build. If not, download valgrind source code, apply some patches (I know it does not compile for arm out of the box), and build with your cross compiler. – BЈовић Jan 13 '20 at 16:35
  • I'm not sure what you mean by build image, sorry I am beginner. I'm using gcc-arm-none-eabi-8-2019-q3-update-linux.tar and the target is nrf52832. I'm looking through the makefile but can't find what image it is. – Anarchira Jan 13 '20 at 17:05
  • Also, if I download valgrind source code and build with cross compiler (I don't know how) will I be able to call "valgrind ./executable" on my ubuntu vm? – Anarchira Jan 13 '20 at 17:21
  • @Anarchira yes, that's exactly what you need to do. – Marco Bonelli Jan 13 '20 at 17:36
  • @MarcoBonelli Should I make a new post about how to build with cross compiler to be able to do "valgrind ./executable" on ubuntu? I've been struggling for days and lost. – Anarchira Jan 13 '20 at 18:00
  • @Anarchira there already are various posts about it if you google it: here's one for example https://stackoverflow.com/questions/29514706/. I would suggest you to try doing it first, and ask about it if you get stuck. – Marco Bonelli Jan 13 '20 at 18:09
  • @MarcoBonelli Sorry I just realized, this answer saids to cross-compile valgrind and run n **target**. I'd like to run it on my ubuntu vm. Valgrind takes too much memory space. I found this https://stackoverflow.com/questions/55161252/valgrind-and-qemu-unable-to-detect-memory-leak similar problem that suggests only way is to emulate an arm OS and then get valgrind on it. Do you think that's true? – Anarchira Jan 13 '20 at 19:19
  • @Anarchira to run an ARM program under Valgrind, you will need Valgrind compiled for ARM. So yeah.. there's not much that you can do around it except compiling Valgridn yourself and then do some kind of virtualization. You could run it on an ARM Ubuntu VM or you could try using `qemu` for ARM, but that'd probably be the same in terms of speed. – Marco Bonelli Jan 13 '20 at 20:05
  • @MarcoBonelli running valgrind with qemu is not working. If the VM emulates ARM, and if it contains valgrind, it should work. I never used VM, so no idea – BЈовић Jan 20 '20 at 10:30
0

It is mandatory to run the executable on the device. Please consider the option to download the precompiled package for your arch example from https://packages.debian.org/search?keywords=valgrind, follow the mandatory dependencies, and install all on you embedded device. I use to base the version according to the installed version of libc.

AntDeMu
  • 9
  • 4