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 sync with FreeBSD
details: https://anonhg.NetBSD.org/src/rev/7a0af542cd8c
branches: trunk
changeset: 340668:7a0af542cd8c
user: christos <christos%NetBSD.org@localhost>
date: Thu Sep 24 14:25:29 2015 +0000
description:
sync with FreeBSD
diffstat:
external/cddl/osnet/dist/lib/libdtrace/common/drti.c | 32 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c | 453 +++-
external/cddl/osnet/dist/lib/libdtrace/common/dt_as.c | 15 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_cc.c | 366 ++-
external/cddl/osnet/dist/lib/libdtrace/common/dt_cg.c | 350 ++-
external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c | 1239 +++++++--
external/cddl/osnet/dist/lib/libdtrace/common/dt_decl.c | 14 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_decl.h | 7 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_dis.c | 42 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_dof.c | 81 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_error.c | 14 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_errtags.h | 31 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_grammar.y | 33 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_handle.c | 21 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_ident.c | 27 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_impl.h | 111 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_lex.l | 53 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_link.c | 354 ++-
external/cddl/osnet/dist/lib/libdtrace/common/dt_list.h | 4 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_map.c | 185 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c | 516 +++-
external/cddl/osnet/dist/lib/libdtrace/common/dt_module.h | 14 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c | 215 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c | 143 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_parser.c | 305 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_parser.h | 8 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c | 373 ++-
external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.h | 8 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_pq.c | 157 +
external/cddl/osnet/dist/lib/libdtrace/common/dt_pq.h | 51 +
external/cddl/osnet/dist/lib/libdtrace/common/dt_pragma.c | 87 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_print.c | 706 +++++
external/cddl/osnet/dist/lib/libdtrace/common/dt_printf.c | 155 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c | 304 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.h | 2 -
external/cddl/osnet/dist/lib/libdtrace/common/dt_program.c | 17 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_provider.c | 75 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_provider.h | 4 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_regset.c | 37 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_regset.h | 8 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_string.c | 24 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_string.h | 10 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c | 139 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_work.c | 14 +-
external/cddl/osnet/dist/lib/libdtrace/common/dt_xlator.c | 13 +-
external/cddl/osnet/dist/lib/libdtrace/common/dtrace.h | 40 +-
external/cddl/osnet/dist/lib/libdtrace/common/mkerrtags.sh | 6 +-
external/cddl/osnet/dist/lib/libdtrace/common/mknames.sh | 8 +-
48 files changed, 5314 insertions(+), 1557 deletions(-)
diffs (truncated from 12332 to 300 lines):
diff -r fc4a38643e56 -r 7a0af542cd8c external/cddl/osnet/dist/lib/libdtrace/common/drti.c
--- a/external/cddl/osnet/dist/lib/libdtrace/common/drti.c Thu Sep 24 14:23:39 2015 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/drti.c Thu Sep 24 14:25:29 2015 +0000
@@ -20,6 +20,7 @@
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2013 Voxer Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -34,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#include <libelf.h>
/*
* In Solaris 10 GA, the only mechanism for communicating helper information
@@ -53,7 +55,9 @@
*/
static const char *devnamep = "/dev/dtrace/helper";
+#ifdef illumos
static const char *olddevname = "/devices/pseudo/dtrace@0:helper";
+#endif
static const char *modname; /* Name of this load object */
static int gen; /* DOF helper generation */
@@ -83,7 +87,7 @@
va_end(ap);
}
-#if defined(sun)
+#ifdef illumos
#pragma init(dtrace_dof_init)
#else
static void dtrace_dof_init(void) __attribute__ ((constructor));
@@ -99,11 +103,10 @@
Elf32_Ehdr *elf;
#endif
dof_helper_t dh;
-#if defined(sun)
- Link_map *lmp;
+ Link_map *lmp = NULL;
+#ifdef illumos
Lmid_t lmid;
#else
- struct link_map *lmp;
u_long lmid = 0;
#endif
int fd;
@@ -120,7 +123,7 @@
return;
}
-#if defined(sun)
+#ifdef illumos
if (dlinfo(RTLD_SELF, RTLD_DI_LMID, &lmid) == -1) {
dprintf(1, "couldn't discover link map ID\n");
return;
@@ -144,6 +147,9 @@
dh.dofhp_dof = (uintptr_t)dof;
dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0;
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+ dh.dofhp_pid = getpid();
+#endif
if (lmid == 0) {
(void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod),
@@ -158,7 +164,7 @@
if ((fd = open64(devnamep, O_RDWR)) < 0) {
dprintf(1, "failed to open helper device %s", devnamep);
-
+#ifdef illumos
/*
* If the device path wasn't explicitly set, try again with
* the old device path.
@@ -172,17 +178,23 @@
dprintf(1, "failed to open helper device %s", devnamep);
return;
}
+#else
+ return;
+#endif
}
-
if ((gen = ioctl(fd, DTRACEHIOC_ADDDOF, &dh)) == -1)
dprintf(1, "DTrace ioctl failed for DOF at %p", dof);
- else
+ else {
dprintf(1, "DTrace ioctl succeeded for DOF at %p\n", dof);
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+ gen = dh.dofhp_gen;
+#endif
+ }
(void) close(fd);
}
-#if defined(sun)
+#ifdef illumos
#pragma fini(dtrace_dof_fini)
#else
static void dtrace_dof_fini(void) __attribute__ ((destructor));
@@ -198,7 +210,7 @@
return;
}
- if ((gen = ioctl(fd, DTRACEHIOC_REMOVE, gen)) == -1)
+ if ((gen = ioctl(fd, DTRACEHIOC_REMOVE, &gen)) == -1)
dprintf(1, "DTrace ioctl failed to remove DOF (%d)\n", gen);
else
dprintf(1, "DTrace ioctl removed DOF (%d)\n", gen);
diff -r fc4a38643e56 -r 7a0af542cd8c external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c
--- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c Thu Sep 24 14:23:39 2015 +0000
+++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c Thu Sep 24 14:25:29 2015 +0000
@@ -24,7 +24,10 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include <stdlib.h>
#include <strings.h>
@@ -32,10 +35,13 @@
#include <unistd.h>
#include <dt_impl.h>
#include <assert.h>
-#if defined(sun)
+#ifdef illumos
#include <alloca.h>
#else
#include <sys/sysctl.h>
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+#include <libproc_compat.h>
+#endif
#endif
#include <limits.h>
@@ -208,6 +214,83 @@
return (0);
}
+static void
+dt_aggregate_llquantize(int64_t *existing, int64_t *new, size_t size)
+{
+ int i;
+
+ for (i = 1; i < size / sizeof (int64_t); i++)
+ existing[i] = existing[i] + new[i];
+}
+
+static long double
+dt_aggregate_llquantizedsum(int64_t *llquanta)
+{
+ int64_t arg = *llquanta++;
+ uint16_t factor = DTRACE_LLQUANTIZE_FACTOR(arg);
+ uint16_t low = DTRACE_LLQUANTIZE_LOW(arg);
+ uint16_t high = DTRACE_LLQUANTIZE_HIGH(arg);
+ uint16_t nsteps = DTRACE_LLQUANTIZE_NSTEP(arg);
+ int bin = 0, order;
+ int64_t value = 1, next, step;
+ long double total;
+
+ assert(nsteps >= factor);
+ assert(nsteps % factor == 0);
+
+ for (order = 0; order < low; order++)
+ value *= factor;
+
+ total = (long double)llquanta[bin++] * (long double)(value - 1);
+
+ next = value * factor;
+ step = next > nsteps ? next / nsteps : 1;
+
+ while (order <= high) {
+ assert(value < next);
+ total += (long double)llquanta[bin++] * (long double)(value);
+
+ if ((value += step) != next)
+ continue;
+
+ next = value * factor;
+ step = next > nsteps ? next / nsteps : 1;
+ order++;
+ }
+
+ return (total + (long double)llquanta[bin] * (long double)value);
+}
+
+static int
+dt_aggregate_llquantizedcmp(int64_t *lhs, int64_t *rhs)
+{
+ long double lsum = dt_aggregate_llquantizedsum(lhs);
+ long double rsum = dt_aggregate_llquantizedsum(rhs);
+ int64_t lzero, rzero;
+
+ if (lsum < rsum)
+ return (DT_LESSTHAN);
+
+ if (lsum > rsum)
+ return (DT_GREATERTHAN);
+
+ /*
+ * If they're both equal, then we will compare based on the weights at
+ * zero. If the weights at zero are equal, then this will be judged a
+ * tie and will be resolved based on the key comparison.
+ */
+ lzero = lhs[1];
+ rzero = rhs[1];
+
+ if (lzero < rzero)
+ return (DT_LESSTHAN);
+
+ if (lzero > rzero)
+ return (DT_GREATERTHAN);
+
+ return (0);
+}
+
static int
dt_aggregate_quantizedcmp(int64_t *lhs, int64_t *rhs)
{
@@ -251,7 +334,6 @@
static void
dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data)
{
-#if 0 /* XXX TBD needs libproc */
uint64_t pid = data[0];
uint64_t *pc = &data[1];
struct ps_prochandle *P;
@@ -265,24 +347,16 @@
dt_proc_lock(dtp, P);
-#if defined(sun)
if (Plookup_by_addr(P, *pc, NULL, 0, &sym) == 0)
-#else
- if (proc_addr2sym(P, *pc, NULL, 0, &sym) == 0)
-#endif
*pc = sym.st_value;
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
-#else
- printf("XXX %s not implemented\n", __func__);
-#endif
}
static void
dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data)
{
-#if 0 /* XXX TBD needs libproc */
uint64_t pid = data[0];
uint64_t *pc = &data[1];
struct ps_prochandle *P;
@@ -296,18 +370,11 @@
dt_proc_lock(dtp, P);
-#if defined(sun)
if ((map = Paddr_to_map(P, *pc)) != NULL)
-#else
- if ((map = proc_addr2map(P, *pc)) != NULL)
-#endif
*pc = map->pr_vaddr;
dt_proc_unlock(dtp, P);
dt_proc_release(dtp, P);
-#else
- printf("XXX %s not implemented\n", __func__);
-#endif
}
static void
@@ -388,7 +455,7 @@
buf->dtbd_cpu = cpu;
-#if defined(sun)
+#ifdef illumos
if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, buf) == -1) {
#else
if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, &buf) == -1) {
@@ -415,15 +482,15 @@
return (0);
if (hash->dtah_hash == NULL) {
- size_t size1;
+ size_t size;
hash->dtah_size = DTRACE_AHASHSIZE;
- size1 = hash->dtah_size * sizeof (dt_ahashent_t *);
Home |
Main Index |
Thread Index |
Old Index