Valgrind 确实调试错误

Ayu*_*man 18 programming c 12.04 software-installation

我一直在尝试学习 Learn C The Hard Way的在线教程 。

但是,在设置 valgrind 之后(我遵循了帮助在 ubuntu 12.04 上设置 valgrind 的其他链接),当我尝试调试 c 可执行文件时,我发现了以下错误。

ayusman@ayusman-ubuntu:~/lcthw$ valgrind ./ex4
==1984== Memcheck, a memory error detector
==1984== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==1984== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==1984== Command: ./ex4
==1984== 

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-linux-x86-64.so.2
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux-x86-64.so.2
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.

ayusman@ayusman-ubuntu:~/lcthw$ 
Run Code Online (Sandbox Code Playgroud)

我可以做些什么来使 valgrind 最终起作用?

我在虚拟机上有 ubuntu 12.04。我的笔记本电脑是 Windows 7 64 位操作系统。

nob*_*bar 42

我得到了基本相同的消息(除了ld-linux-x86-64.so.2被替换为ld-linux.so.2)。我已经使用安装了 Valgrind,apt-get所以 libc6-dbg 已经作为依赖项包含在内。

我还没有完全解决这个问题,但一个线索是错误与我-m32在构建时的使用相关。

因此,在我的情况下,问题似乎是在 Ubuntu 12.04 的 64 位安装上构建时缺少 32 位版本的 libc6-dbg(或其某些组件)。


解决方案(对于我的情况)

对我来说,以下命令使事情起作用......

sudo apt-get install libc6-dbg:i386
Run Code Online (Sandbox Code Playgroud)

这在https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/881236 中讨论

注意:该包libc6-dbg:i386不会在 Synaptic 中显示为可用选项,也不会通过命令完成apt-get-- 但无论如何它都在那里。


Ayu*_*man 11

好的,我这样做了 intsall libc6-dbg

sudo apt-get install libc6-dbg
Run Code Online (Sandbox Code Playgroud)

和 valgrind 似乎工作正常。

感谢 ubuntu 论坛链接:

http://ubuntuforums.org/showthread.php?t=1017692