From barner@gmx.de  Thu Dec 23 15:35:09 2004
Return-Path: <barner@gmx.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 63D1816A4EC
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 23 Dec 2004 15:35:09 +0000 (GMT)
Received: from mail.gmx.net (mail.gmx.net [213.165.64.20])
	by mx1.FreeBSD.org (Postfix) with SMTP id 5719943D2F
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 23 Dec 2004 15:35:08 +0000 (GMT)
	(envelope-from barner@gmx.de)
Received: (qmail invoked by alias); 23 Dec 2004 15:35:07 -0000
Received: from unknown (EHLO zi025.glhnet.mhn.de) (129.187.19.157)
  by mail.gmx.net (mp018) with SMTP; 23 Dec 2004 16:35:07 +0100
Received: by zi025.glhnet.mhn.de (Postfix, from userid 1000)
	id 5C3AEC0F7; Thu, 23 Dec 2004 16:35:10 +0100 (CET)
Message-Id: <20041223153510.5C3AEC0F7@zi025.glhnet.mhn.de>
Date: Thu, 23 Dec 2004 16:35:10 +0100 (CET)
From: Simon Barner <barner@gmx.de>
Reply-To: Simon Barner <barner@gmx.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [maintainer] devel/valgrind*: Check for kernel option USER_LDT
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         75436
>Category:       ports
>Synopsis:       [maintainer] devel/valgrind*: Check for kernel option USER_LDT
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 23 15:40:19 GMT 2004
>Closed-Date:    Mon Dec 27 11:43:33 GMT 2004
>Last-Modified:  Mon Dec 27 11:43:33 GMT 2004
>Originator:     Simon Barner
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
>Environment:
FreeBSD zi025.glhnet.mhn.de 5.3-STABLE FreeBSD 5.3-STABLE #0: Fri Nov  5 02:17:53 CET 2004     root@zi025.glhnet.mhn.de:/usr/obj/usr/src/sys/KISTE  i386

>Description:

Valgrind needs a kernel that is built with option USER_LDT to perform some kind of pointer analysis.

The attached patches print a warning in case the running kernel does not
support i386_set_ldt() and advises the user to rebuilt her kernel accordingly.

Please note: These patches are cumulative to
http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/71832

>How-To-Repeat:

N/A

>Fix:

--- valgrind-USER_LDT.patch begins here ---
diff -ruN valgrind.orig/Makefile valgrind/Makefile
--- valgrind.orig/Makefile	Thu Dec 23 16:11:47 2004
+++ valgrind/Makefile	Thu Dec 23 16:12:38 2004
@@ -69,6 +69,16 @@
 	@${INSTALL_DATA} ${WRKSRC}/coregrind/vg_unistd.h \
 		${PREFIX}/include/valgrind
 
+# Check if kernel is built with USER_LDT option (FreeBSD 4 only)
+.if ${OSVERSION} < 500000
+	@${PREFIX}/bin/valgrind --tool=memcheck true 2> ${WRKDIR}/ldt.test
+	@${GREP} i386_set_ldt ${WRKDIR}/ldt.test >/dev/null &&\
+	${ECHO_CMD} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! && \
+	${ECHO_CMD} Please rebuild your kernel with ``options USER_LDT''! && \
+	${ECHO_CMD} Otherwise, valgrind will not be able to perform pointer analysis! && \
+	${ECHO_CMD} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! || true
+.endif
+
 	@yes | ${PREFIX}/bin/valgrind --tool=memcheck --gen-suppressions=yes true \
 		| ${SED} -e 's,.*{$$,{,'  \
 		| ${GREP} -v '^=' \
--- valgrind-USER_LDT.patch ends here ---

--- valgrind-snapshot-USER_LDT.patch begins here ---
diff -ruN valgrind-snapshot.orig/Makefile valgrind-snapshot/Makefile
--- valgrind-snapshot.orig/Makefile	Thu Dec 23 16:15:19 2004
+++ valgrind-snapshot/Makefile	Thu Dec 23 16:14:45 2004
@@ -32,18 +32,17 @@
 
 .include <bsd.port.pre.mk>
 
-.if ${OSVERSION} >= 500000 
-PLIST_SUB+=	RELENG_4="@comment"
-PLIST_SUB+=	RELENG_5=""
-.else
-PLIST_SUB+=	RELENG_4=""
-PLIST_SUB+=	PRELENG_5="@comment"
-.endif
-
 .if ${PERL_LEVEL} < 500601
 IGNORE=		"can\'t be built. Your Perl version is too old. Please use lang/perl5.8 port to upgrade your Perl"
 .endif
 
+.if ${OSVERSION} < 500000
+PLIST_SUB+=	RELENG_4="" \
+		RELENG_5="@comment "
+.else
+PLIST_SUB+=	RELENG_4="@comment " \
+		RELENG_5=""
+.endif
 PROCFS!=	/sbin/mount | ${GREP} '^procfs' | ${AWK} '{print $1}'
 
 pre-everything::
@@ -73,6 +72,17 @@
 	@${INSTALL_DATA} ${WRKSRC}/coregrind/vg_unistd.h \
 		${PREFIX}/include/valgrind
 
+# Check if kernel is built with USER_LDT option (FreeBSD 4 only)
+.if ${OSVERSION} < 500000
+	@${PREFIX}/bin/valgrind --tool=memcheck true 2> ${WRKDIR}/ldt.test
+	@${GREP} i386_set_ldt ${WRKDIR}/ldt.test >/dev/null &&\
+	${ECHO_CMD} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! && \
+	${ECHO_CMD} Please rebuild your kernel with ``options USER_LDT''! && \
+	${ECHO_CMD} Otherwise, valgrind will not be able to perform pointer analysis! && \
+	${ECHO_CMD} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! || true
+.endif
+
+# Generate suppression files
 	@yes | ${PREFIX}/bin/valgrind --tool=memcheck --gen-suppressions=yes true \
 		| ${SED} -e 's,.*{$$,{,'  \
 		| ${GREP} -v '^=' \
--- valgrind-snapshot-USER_LDT.patch ends here ---

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: vs 
State-Changed-When: Mon Dec 27 11:43:15 GMT 2004 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=75436 
>Unformatted:
