Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/cddl/osnet/dist/lib/libdtrace/common Introduce dt_b...
details: https://anonhg.NetBSD.org/src/rev/fcf67e9fa89e
branches: trunk
changeset: 344924:fcf67e9fa89e
user: christos <christos%NetBSD.org@localhost>
date: Thu Apr 28 00:02:40 2016 +0000
description:
Introduce dt_bootfile() and use it to avoid hard-coded kernel values. Fixes
dtrace hang for kernels not named netbsd.
diffstat:
external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h | 4 +
external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c | 2 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c | 78 +++++++++-----
3 files changed, 55 insertions(+), 29 deletions(-)
diffs (133 lines):
diff -r 870881e76ac8 -r fcf67e9fa89e external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h
--- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h Wed Apr 27 21:15:40 2016 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h Thu Apr 28 00:02:40 2016 +0000
@@ -744,6 +744,10 @@
extern const char *_dtrace_libdir; /* default library directory */
extern const char *_dtrace_moddir; /* default kernel module directory */
+#ifndef illumos
+extern const char *dt_bootfile(char *, size_t);
+#endif
+
#if defined(__FreeBSD__) || defined(__NetBSD__)
extern int gmatch(const char *, const char *);
extern int yylex(void);
diff -r 870881e76ac8 -r fcf67e9fa89e external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c
--- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c Wed Apr 27 21:15:40 2016 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c Thu Apr 28 00:02:40 2016 +0000
@@ -1180,7 +1180,7 @@
if (strcmp("netbsd", name) == 0) {
/* want the kernel */
- strncpy(fname, "/netbsd", sizeof(fname));
+ dt_bootfile(fname, sizeof(fname));
} else {
/* build stand module path from system */
diff -r 870881e76ac8 -r fcf67e9fa89e external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c
--- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c Wed Apr 27 21:15:40 2016 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c Thu Apr 28 00:02:40 2016 +0000
@@ -1025,6 +1025,37 @@
}
#endif
+#ifndef illumos
+# ifdef __FreeBSD__
+# define DEFKERNEL "kernel"
+# define BOOTFILE "kern.bootfile"
+# endif
+# ifdef __NetBSD__
+# define DEFKERNEL "netbsd"
+# define BOOTFILE "machdep.booted_kernel"
+# endif
+
+const char *
+dt_bootfile(char *bootfile, size_t len)
+{
+ char *p;
+ size_t olen = len;
+
+ /* This call shouldn't fail, but use a default just in case.*/
+ if (sysctlbyname(BOOTFILE, bootfile, &len, NULL, 0) != 0)
+ strlcpy(bootfile, DEFKERNEL, olen);
+
+ if ((p = strrchr(bootfile, '/')) != NULL)
+ p++;
+ else
+ p = bootfile;
+ return p;
+}
+
+# undef DEFKERNEL
+# undef BOOTFILE
+#endif
+
static dtrace_hdl_t *
dt_vopen(int version, int flags, int *errp,
const dtrace_vector_t *vector, void *arg)
@@ -1309,37 +1340,25 @@
/*
* On FreeBSD the kernel module name can't be hard-coded. The
- * 'kern.bootfile' sysctl value tells us exactly which file is being
- * used as the kernel.
+ * 'kern.bootfile' sysctl value tells us exactly which file is
+ * being used as the kernel.
*/
#ifndef illumos
+# ifdef __FreeBSD__
+# define THREAD "struct thread"
+# define MUTEX "struct mtx"
+# define RWLOCK "struct rwlock"
+# endif
+# ifdef __NetBSD__
+# define THREAD "struct lwp"
+# define MUTEX "struct kmutex"
+# define RWLOCK "struct krwlock"
+# endif
{
- char bootfile[MAXPATHLEN];
- char *p;
- size_t len = sizeof(bootfile);
+ const char *p;
+ char kernname[512];
-#ifdef __FreeBSD__
-#define DEFKERNEL "kernel"
-#define BOOTFILE "kern.bootfile"
-#define THREAD "struct thread"
-#define MUTEX "struct mtx"
-#define RWLOCK "struct rwlock"
-#endif
-#ifdef __NetBSD__
-#define DEFKERNEL "netbsd"
-#define BOOTFILE "machdep.booted_kernel"
-#define THREAD "struct lwp"
-#define MUTEX "struct kmutex"
-#define RWLOCK "struct krwlock"
-#endif
- /* This call shouldn't fail, but use a default just in case. */
- if (sysctlbyname(BOOTFILE, bootfile, &len, NULL, 0) != 0)
- strlcpy(bootfile, DEFKERNEL, sizeof(bootfile));
-
- if ((p = strrchr(bootfile, '/')) != NULL)
- p++;
- else
- p = bootfile;
+ p = dt_bootfile(kernname, sizeof(kernname));
/*
* Format the global variables based on the kernel module name.
@@ -1349,8 +1368,11 @@
snprintf(threadmtx_str, sizeof(threadmtx_str), "%s *(%s`%s *)",
THREAD, p, MUTEX);
snprintf(rwlock_str, sizeof(rwlock_str), "int(%s`%s *)", p, RWLOCK);
- snprintf(sxlock_str, sizeof(sxlock_str), "int(%s`struct sxlock *)",p);
+ snprintf(sxlock_str, sizeof(sxlock_str), "int(%s`struct sxlock *)", p);
}
+# undef THREAD
+# undef MUTEX
+# undef RWLOCK
#endif
dtp->dt_macros = dt_idhash_create("macro", NULL, 0, UINT_MAX);
Home |
Main Index |
Thread Index |
Old Index