From owner-p4-projects@FreeBSD.ORG Thu Oct 30 16:57:56 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 911A8106567C; Thu, 30 Oct 2008 16:57:56 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52B931065676 for ; Thu, 30 Oct 2008 16:57:56 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 4142D8FC17 for ; Thu, 30 Oct 2008 16:57:56 +0000 (UTC) (envelope-from peter-gmail@wemm.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id m9UGvupo070331 for ; Thu, 30 Oct 2008 16:57:56 GMT (envelope-from peter-gmail@wemm.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id m9UGvue8070329 for perforce@freebsd.org; Thu, 30 Oct 2008 16:57:56 GMT (envelope-from peter-gmail@wemm.org) Date: Thu, 30 Oct 2008 16:57:56 GMT Message-Id: <200810301657.m9UGvue8070329@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to peter-gmail@wemm.org using -f From: Peter Wemm To: Perforce Change Reviews Cc: Subject: PERFORCE change 152221 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2008 16:57:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=152221 Change 152221 by peter@peter_overcee on 2008/10/30 16:57:12 I'm tired of mounting /proc to run valgrind. Eliminate another consumer. Affected files ... .. //depot/projects/valgrind/coregrind/launcher-freebsd.c#4 edit Differences ... ==== //depot/projects/valgrind/coregrind/launcher-freebsd.c#4 (text+ko) ==== @@ -42,6 +42,7 @@ #include #include #include +#include /* #include */ #include @@ -185,6 +186,8 @@ char launcher_name[PATH_MAX+1]; char* new_line; char** new_env; + int oid[4]; + vki_size_t len; /* Start the debugging-log system ASAP. First find out how many "-d"s were specified. This is a pre-scan of the command line. @@ -255,6 +258,21 @@ we can tell stage2. stage2 will use the name for recursive invokations of valgrind on child processes. */ memset(launcher_name, 0, PATH_MAX+1); + +#if __FreeBSD__ >= 7 + oid[0] = CTL_KERN; + oid[1] = KERN_PROC; + oid[2] = KERN_PROC_PATHNAME; + oid[3] = getpid(); + len = PATH_MAX; + r = sysctl(oid, 4, launcher_name, &len, 0, 0); + if (r != 0) { + fprintf(stderr, "valgrind: warning (non-fatal): " + "sysctl(\"kern.proc.pathname\") failed.\n"); + fprintf(stderr, "valgrind: continuing, however --trace-children=yes " + "will not work.\n"); + } +#else r = readlink("/proc/curproc/file", launcher_name, PATH_MAX); if (r == -1) { /* If /proc/self/exe can't be followed, don't give up. Instead @@ -266,6 +284,7 @@ fprintf(stderr, "valgrind: continuing, however --trace-children=yes " "will not work.\n"); } +#endif /* tediously augment the env: VALGRIND_LAUNCHER=launcher_name */ new_line = malloc(strlen(VALGRIND_LAUNCHER) + 1