Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

valgrind asking for debuginfo libc6-dbg

Tags:

valgrind

I have gone through the answers related to this error. However, my question is once I have debuginfo of libc, what is the location that i should place this library, in order for valgrind to see it?

I have downloaded valgrind and cross compiled for my target environment. I tried all different combinations below:

  1. I placed libc in /lib and debuginfo in /lib/debug
  2. renamed debuginfo to libc.debug
  3. exported VALGRIND_LIB to include /lib, /lib/debug

Last but not least, below is the actual error:

==29946== Memcheck, a memory error detector
==29946== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==29946== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==29946== Command: /bin/my_prog
==29946==

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:      strcmp
valgrind:  in an object with soname matching:   ld-linux-armhf.so.3
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux-armhf.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:  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.
like image 668
lvad Avatar asked Oct 28 '22 23:10

lvad


1 Answers

I encountered the same problem, here is how I resolve it:
Replace the ld-xx.so in /lib path with a debug build.

Here is my case. I'm using Yocto to build rootfs, so copy poky/build/tmp/work/xxxx/glibc/2.26-r0/image/lib/ld-2.26.so from your build path to Linux FS path /lib, to replace original /lib/ld-2.26.so(and ld-linux-armhf.so.3) of release build.

After doing this, valgrind works fine.

WARNING: Exchanging the loader on a running system can brick it! These steps work:

  • Upload new loader to target to a path outside /lib
  • mark new loader as executable (chmod 755)
  • copy (don't move!) old loader
  • copy new loader to /lib
like image 169
HonanLi Avatar answered Nov 08 '22 05:11

HonanLi