Hello,

> I tried to run valgrind (3.3.1) on x86 target running. The package was
> build and installed fine (just adapted the /usr/lib/valgrind/uclibc.supp to
> ld-uClibc-0.9.29.so). But running valgrind gives:
>
> root@OpenWrt:/tmp# valgrind -d
> --5329:1:debuglog DebugLog system started by Stage 1, level 1 logging
> requested
> --5329:1:launcher no tool requested, defaulting to 'memcheck'
> --5329:1:launcher no client specified, defaulting platform to 'x86-linux'
> --5329:1:launcher launching /usr/lib/valgrind/x86-linux/memcheck
> valgrind: failed to start tool 'memcheck' for platform 'x86-linux': No such
> file or directory


> What could be wrong? I tried to set VALGRIND_LIB, LD_LIBRARY_PATH and so on
> but memcheck work start :(
>
> I'm lucky forward to any useful hints.

After some resarch I found the reason:

Valgrind was compiled with wrong flags:

$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
DESTDIR="$(PKG_INSTALL_DIR)" \
CFLAGS="$(TARGET_CFLAGS)" \
AM_CFLAGS_X86_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \ 
AM_CFLAGS_AMD64_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \         
      
AM_CFLAGS_PPC32_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \
AM_CFLAGS_PPC64_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \
TOOL_LDADD_COMMON="$(LIBGCC_A) $(PKG_BUILD_DIR)/abort.a"
all install

I changed it to:
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
DESTDIR="$(PKG_INSTALL_DIR)" \
CFLAGS="$(TARGET_CFLAGS) -m32 -mpreferred-stack-boundary=2 -O -g 
-Wmissing-prototypes -Winline -Wall -Wshadow -Wpointer-arith-Wstrict-proto" 
\
all install


Now it works (I had to symlink /usr/lib/valgrind/x86-linux/uclibc.supp 
to /usr/lib/valgrind/x86-linux/default.supp):
root@OpenWrt:~# valgrind ls
==4369== Memcheck, a memory error detector.
==4369== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==4369== Using LibVEX rev 1854, a library for dynamic binary translation.
==4369== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==4369== Using valgrind-3.3.1, a dynamic binary instrumentation framework.
==4369== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==4369== For more details, rerun with: -v
==4369==
==4369==
==4369== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==4369== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4369== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==4369== For counts of detected errors, rerun with: -v
==4369== All heap blocks were freed -- no leaks are possible.

The resulting patch is attached. It contains the flags change, support for 3.x 
kernel on host and the missing symlink to default.supp

Happy memchecking ;)


With best regards

Christoph
-- 
Linux User Group Wernigerode
http://www.lug-wr.de/
diff -burN openwrt-package-feeds/utils/valgrind/files/uclibc.supp valgrind/files/uclibc.supp
--- openwrt-package-feeds/utils/valgrind/files/uclibc.supp	2009-04-03 09:56:58.000000000 +0200
+++ valgrind/files/uclibc.supp	2012-04-25 09:58:35.000000000 +0200
@@ -201,12 +201,12 @@
 {
    <insert a suppression name here>
    Memcheck:Addr2
-   obj:/lib/ld-uClibc-0.9.28.so
+   obj:/lib/ld-uClibc-0.9.29.so
    fun:*
 }
 {
    <insert a suppression name here>
    Memcheck:Addr4
-   obj:/lib/ld-uClibc-0.9.28.so
+   obj:/lib/ld-uClibc-0.9.29.so
    fun:*
 }
diff -burN openwrt-package-feeds/utils/valgrind/Makefile valgrind/Makefile
--- openwrt-package-feeds/utils/valgrind/Makefile	2012-04-25 09:57:21.003173253 +0200
+++ valgrind/Makefile	2012-04-25 10:25:39.315217728 +0200
@@ -52,12 +52,7 @@
 	$(MAKE) -C $(PKG_BUILD_DIR) \
 		$(TARGET_CONFIGURE_OPTS) \
 		DESTDIR="$(PKG_INSTALL_DIR)" \
-		CFLAGS="$(TARGET_CFLAGS)" \
-		AM_CFLAGS_X86_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \
-		AM_CFLAGS_AMD64_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \
-		AM_CFLAGS_PPC32_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \
-		AM_CFLAGS_PPC64_LINUX="$(TARGET_CFLAGS) -I$(PKG_BUILD_DIR)/coregrind" \
-		TOOL_LDADD_COMMON="$(LIBGCC_A) $(PKG_BUILD_DIR)/abort.a" \
+		CFLAGS="$(TARGET_CFLAGS) -m32 -mpreferred-stack-boundary=2 -O -g -Wmissing-prototypes -Winline -Wall -Wshadow -Wpointer-arith-Wstrict-proto" \
 		all install
 endef
 
@@ -66,8 +61,10 @@
 	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
 	$(INSTALL_BIN) ./files/valgrind.sh $(1)/usr/bin/
 	$(INSTALL_DIR) $(1)/usr/lib/valgrind
-	$(CP) ./files/uclibc.supp $(1)/usr/lib/valgrind/
 	$(CP) $(PKG_INSTALL_DIR)/usr/lib/valgrind/*-linux $(1)/usr/lib/valgrind/
+	$(CP) ./files/uclibc.supp $(1)/usr/lib/valgrind/
+	cd $(1)/usr/lib/valgrind/ && ln -s uclibc.supp default.supp
+
 endef
 
 $(eval $(call BuildPackage,valgrind))
diff -burN openwrt-package-feeds/utils/valgrind/patches/000-kernel_3.x.patch valgrind/patches/000-kernel_3.x.patch
--- openwrt-package-feeds/utils/valgrind/patches/000-kernel_3.x.patch	1970-01-01 01:00:00.000000000 +0100
+++ valgrind/patches/000-kernel_3.x.patch	2012-04-16 19:06:38.000000000 +0200
@@ -0,0 +1,51 @@
+--- /dev/null
++++ b/meta/recipes-devtools/valgrind/valgrind-3.6.1/fix_unsupporting_kernel_3.patch
+@@ -0,0 +1,26 @@
++valgrind: Add 3.x statements to "case" for supporting the kernel 3.x
++
++Signed-off-by: Lin Tong <tong.lin at intel.com>
++
++Upstream-Status: Pending
++
++diff --git a/configure.in b/configure.in
++index 3878619..1cb7dc7 100644
++--- a/configure.in
+++++ b/configure.in
++@@ -229,10 +229,14 @@ case "${host_os}" in
++                   AC_MSG_RESULT([2.4 family (${kernel})])
++                   AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you're using Linux 2.4.x])
++                   ;;
+++             3.*)
+++                    AC_MSG_RESULT([3 family (${kernel})])
+++                    AC_DEFINE([KERNEL_3], 1, [Define to 1 if you're using Linux 3.x])
+++                    ;;
++ 
++              *) 
++                   AC_MSG_RESULT([unsupported (${kernel})])
++-                  AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6])
+++                  AC_MSG_ERROR([Valgrind works on kernels 2.4, 2.6, 3.x])
++                   ;;
++         esac
++ 
+
+--- a/configure	2012-04-16 19:04:30.056526021 +0200
++++ b/configure	2012-04-16 19:04:31.828526068 +0200
+@@ -4132,6 +4132,18 @@
+         kernel=`uname -r`
+ 
+         case "${kernel}" in
++
++             3.*)
++        	    echo "$as_me:$LINENO: result: 3.x family (${kernel})" >&5
++echo "${ECHO_T}3.x family (${kernel})" >&6
++
++cat >>confdefs.h <<\_ACEOF
++#define KERNEL_3 1
++_ACEOF
++
++        	    ;;
++
++
+              2.6.*)
+         	    echo "$as_me:$LINENO: result: 2.6 family (${kernel})" >&5
+ echo "${ECHO_T}2.6 family (${kernel})" >&6

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to