在用make制作的锉刀上使用Valgrind

Using Valgrind on files made with make

本文关键字:Valgrind make 在用      更新时间:2024-09-23

我正试图在一个程序上使用valgrind,该程序是使用以下makefile的make命令的输出:

# Intlist makefile
P = intlist
C = g++
F = -m32 -g -O0 -Wall
O = IntListTest.o IntList.o
$(P): $(O)
$(C) $(F) -o $(P) $(O)
IntListTest.o: IntListTest.cpp IntList.h
$(C) $(F) -c IntListTest.cpp
IntList.o: IntList.cpp IntList.h
$(C) $(F) -c IntList.cpp
clean:
rm $(P) $(O)

当我在intlist上运行valgrind时,它会生成以下内容:

==130929== Memcheck, a memory error detector
==130929== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==130929== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==130929== Command: intlist
==130929==
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.so.2
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux.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:  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.

我觉得我的makefile有什么问题,但我不确定是什么。任何想法都非常感谢。然而,这发生在一个大学拥有的服务器上,我没有安装任何东西的权限,所以这不是我的解决方案。

您正在构建一个32位可执行文件(编译/链接行中的-m32选项(,但从valgrind提供的输出来看,您没有所有可用的支持库来在32位的可执行文件上运行valgrind。

你真的需要你的程序是32位吗?如果不是最简单的方法,那就是删除-m32选项并清理和重建所有内容。

如果你真的必须有一个32位二进制文件,那么仔细阅读上面valgrind提供的输出,以确定你缺少哪些额外的32位库,需要安装。