PERFORCE change 152221 for review
Peter Wemm
peter at FreeBSD.org
Thu Oct 30 09:57:56 PDT 2008
http://perforce.freebsd.org/chv.cgi?CH=152221
Change 152221 by peter at 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 <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/sysctl.h>
/* #include <sys/user.h> */
#include <unistd.h>
@@ -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
More information about the p4-projects
mailing list