diff options
author | John Birrell <jb@FreeBSD.org> | 2008-04-26 00:54:52 +0000 |
---|---|---|
committer | John Birrell <jb@FreeBSD.org> | 2008-04-26 00:54:52 +0000 |
commit | 20594ebf9039b47ff078f8061765a1bd7aeb91e4 (patch) | |
tree | 24d646e40917d468e03d33d5425f93b94e78d6b1 /cddl/contrib/opensolaris/lib | |
parent | 89b5b33da21ff6dbab5e91c04d9a6d8e3b17405a (diff) | |
parent | 275928fc142e604d7d091feb5eff54c72f241964 (diff) | |
download | src-20594ebf9039b47ff078f8061765a1bd7aeb91e4.tar.gz src-20594ebf9039b47ff078f8061765a1bd7aeb91e4.zip |
This commit was generated by cvs2svn to compensate for changes in r178528,
which included commits to RCS files with non-trunk default branches.
Notes
Notes:
svn path=/head/; revision=178529
Diffstat (limited to 'cddl/contrib/opensolaris/lib')
33 files changed, 110 insertions, 1781 deletions
diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c index 6cd003663cac..6e599540a4f6 100644 --- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c +++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c @@ -29,25 +29,18 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/mman.h> -#include <sys/zmod.h> #include <ctf_impl.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> -#if defined(sun) #include <dlfcn.h> -#else -#include <zlib.h> -#endif #include <gelf.h> -#if defined(sun) #ifdef _LP64 static const char *_libctf_zlib = "/usr/lib/64/libz.so"; #else static const char *_libctf_zlib = "/usr/lib/libz.so"; #endif -#endif static struct { int (*z_uncompress)(uchar_t *, ulong_t *, const uchar_t *, ulong_t); @@ -58,20 +51,14 @@ static struct { static size_t _PAGESIZE; static size_t _PAGEMASK; -#if defined(sun) #pragma init(_libctf_init) -#else -void _libctf_init(void) __attribute__ ((constructor)); -#endif void _libctf_init(void) { -#if defined(sun) const char *p = getenv("LIBCTF_DECOMPRESSOR"); if (p != NULL) _libctf_zlib = p; /* use alternate decompression library */ -#endif _libctf_debug = getenv("LIBCTF_DEBUG") != NULL; @@ -87,7 +74,6 @@ _libctf_init(void) void * ctf_zopen(int *errp) { -#if defined(sun) ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib); if (zlib.z_dlp != NULL) @@ -99,21 +85,14 @@ ctf_zopen(int *errp) if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL) return (ctf_set_open_errno(errp, ECTF_ZINIT)); - zlib.z_uncompress = (int (*)(uchar_t *, ulong_t *, const uchar_t *, ulong_t)) dlsym(zlib.z_dlp, "uncompress"); - zlib.z_error = (const char *(*)(int)) dlsym(zlib.z_dlp, "zError"); + zlib.z_uncompress = (int (*)()) dlsym(zlib.z_dlp, "uncompress"); + zlib.z_error = (const char *(*)()) dlsym(zlib.z_dlp, "zError"); if (zlib.z_uncompress == NULL || zlib.z_error == NULL) { (void) dlclose(zlib.z_dlp); bzero(&zlib, sizeof (zlib)); return (ctf_set_open_errno(errp, ECTF_ZINIT)); } -#else - zlib.z_uncompress = uncompress; - zlib.z_error = zError; - - /* Dummy return variable as 'no error' */ - zlib.z_dlp = (void *) (uintptr_t) 1; -#endif return (zlib.z_dlp); } @@ -241,7 +220,7 @@ ctf_fdopen(int fd, int *errp) * If we have read enough bytes to form a CTF header and the magic * string matches, attempt to interpret the file as raw CTF. */ - if (nbytes >= (ssize_t) sizeof (ctf_preamble_t) && + if (nbytes >= sizeof (ctf_preamble_t) && hdr.ctf.ctp_magic == CTF_MAGIC) { if (hdr.ctf.ctp_version > CTF_VERSION) return (ctf_set_open_errno(errp, ECTF_CTFVERS)); @@ -271,7 +250,7 @@ ctf_fdopen(int fd, int *errp) * do our own largefile ELF processing, and convert everything to * GElf structures so that clients can operate on any data model. */ - if (nbytes >= (ssize_t) sizeof (Elf32_Ehdr) && + if (nbytes >= sizeof (Elf32_Ehdr) && bcmp(&hdr.e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) { #ifdef _BIG_ENDIAN uchar_t order = ELFDATA2MSB; @@ -283,7 +262,7 @@ ctf_fdopen(int fd, int *errp) void *strs_map; size_t strs_mapsz; - char *strs; + const char *strs; if (hdr.e32.e_ident[EI_DATA] != order) return (ctf_set_open_errno(errp, ECTF_ENDIAN)); @@ -291,7 +270,7 @@ ctf_fdopen(int fd, int *errp) return (ctf_set_open_errno(errp, ECTF_ELFVERS)); if (hdr.e32.e_ident[EI_CLASS] == ELFCLASS64) { - if (nbytes < (ssize_t) sizeof (GElf_Ehdr)) + if (nbytes < sizeof (GElf_Ehdr)) return (ctf_set_open_errno(errp, ECTF_FMT)); } else { Elf32_Ehdr e32 = hdr.e32; @@ -342,7 +321,7 @@ ctf_fdopen(int fd, int *errp) strs_map = mmap64(NULL, strs_mapsz, PROT_READ, MAP_PRIVATE, fd, sp[hdr.e64.e_shstrndx].sh_offset & _PAGEMASK); - strs = (char *)strs_map + + strs = (const char *)strs_map + (sp[hdr.e64.e_shstrndx].sh_offset & ~_PAGEMASK); if (strs_map == MAP_FAILED) { diff --git a/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c b/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c index e9f5ad7a1f71..467b6a8181a8 100644 --- a/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c +++ b/cddl/contrib/opensolaris/lib/libctf/common/ctf_subr.c @@ -27,6 +27,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <ctf_impl.h> +#include <libctf.h> #include <sys/mman.h> #include <stdarg.h> @@ -57,7 +58,7 @@ ctf_alloc(size_t size) /*ARGSUSED*/ void -ctf_free(void *buf, __unused size_t size) +ctf_free(void *buf, size_t size) { free(buf); } @@ -65,7 +66,7 @@ ctf_free(void *buf, __unused size_t size) const char * ctf_strerror(int err) { - return ((const char *) strerror(err)); + return (strerror(err)); } /*PRINTFLIKE1*/ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c index c983c5b595a8..f8570e686f5b 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/drti.c @@ -55,7 +55,7 @@ * DTRACE_DOF_INIT_DEVNAME set the path to the helper node */ -static const char *devnamep = "/dev/dtrace/helper"; +static const char *devname = "/dev/dtrace/helper"; static const char *olddevname = "/devices/pseudo/dtrace@0:helper"; static const char *modname; /* Name of this load object */ @@ -85,12 +85,7 @@ dprintf(int debug, const char *fmt, ...) va_end(ap); } -#if defined(sun) #pragma init(dtrace_dof_init) -#else -static void dtrace_dof_init(void) __attribute__ ((constructor)); -#endif - static void dtrace_dof_init(void) { @@ -101,13 +96,8 @@ dtrace_dof_init(void) Elf32_Ehdr *elf; #endif dof_helper_t dh; -#if defined(sun) Link_map *lmp; Lmid_t lmid; -#else - struct link_map *lmp; - u_long lmid = 0; -#endif int fd; const char *p; @@ -119,12 +109,10 @@ dtrace_dof_init(void) return; } -#if defined(sun) if (dlinfo(RTLD_SELF, RTLD_DI_LMID, &lmid) == -1) { dprintf(1, "couldn't discover link map ID\n"); return; } -#endif if ((modname = strrchr(lmp->l_name, '/')) == NULL) modname = lmp->l_name; @@ -142,7 +130,7 @@ dtrace_dof_init(void) elf = (void *)lmp->l_addr; dh.dofhp_dof = (uintptr_t)dof; - dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0; + dh.dofhp_addr = elf->e_type == ET_DYN ? lmp->l_addr : 0; if (lmid == 0) { (void) snprintf(dh.dofhp_mod, sizeof (dh.dofhp_mod), @@ -153,10 +141,10 @@ dtrace_dof_init(void) } if ((p = getenv("DTRACE_DOF_INIT_DEVNAME")) != NULL) - devnamep = p; + devname = p; - if ((fd = open64(devnamep, O_RDWR)) < 0) { - dprintf(1, "failed to open helper device %s", devnamep); + if ((fd = open64(devname, O_RDWR)) < 0) { + dprintf(1, "failed to open helper device %s", devname); /* * If the device path wasn't explicitly set, try again with @@ -165,10 +153,10 @@ dtrace_dof_init(void) if (p != NULL) return; - devnamep = olddevname; + devname = olddevname; - if ((fd = open64(devnamep, O_RDWR)) < 0) { - dprintf(1, "failed to open helper device %s", devnamep); + if ((fd = open64(devname, O_RDWR)) < 0) { + dprintf(1, "failed to open helper device %s", devname); return; } } @@ -181,19 +169,14 @@ dtrace_dof_init(void) (void) close(fd); } -#if defined(sun) #pragma fini(dtrace_dof_fini) -#else -static void dtrace_dof_fini(void) __attribute__ ((destructor)); -#endif - static void dtrace_dof_fini(void) { int fd; - if ((fd = open64(devnamep, O_RDWR)) < 0) { - dprintf(1, "failed to open helper device %s", devnamep); + if ((fd = open64(devname, O_RDWR)) < 0) { + dprintf(1, "failed to open helper device %s", devname); return; } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c index ac32f769a934..2e66250b88d7 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_aggregate.c @@ -32,11 +32,7 @@ #include <unistd.h> #include <dt_impl.h> #include <assert.h> -#if defined(sun) #include <alloca.h> -#else -#include <sys/sysctl.h> -#endif #include <limits.h> #define DTRACE_AHASHSIZE 32779 /* big 'ol prime */ @@ -58,7 +54,7 @@ static int dt_keypos; static void dt_aggregate_count(int64_t *existing, int64_t *new, size_t size) { - uint_t i; + int i; for (i = 0; i < size / sizeof (int64_t); i++) existing[i] = existing[i] + new[i]; @@ -211,10 +207,9 @@ dt_aggregate_lquantizedcmp(int64_t *lhs, int64_t *rhs) static int dt_aggregate_quantizedcmp(int64_t *lhs, int64_t *rhs) { - int nbuckets = DTRACE_QUANTIZE_NBUCKETS; + int nbuckets = DTRACE_QUANTIZE_NBUCKETS, i; long double ltotal = 0, rtotal = 0; int64_t lzero, rzero; - uint_t i; for (i = 0; i < nbuckets; i++) { int64_t bucketval = DTRACE_QUANTIZE_BUCKETVAL(i); @@ -264,11 +259,7 @@ dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data) 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); @@ -291,11 +282,7 @@ dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data) 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); @@ -380,11 +367,7 @@ dt_aggregate_snap_cpu(dtrace_hdl_t *dtp, processorid_t cpu) buf->dtbd_cpu = cpu; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, buf) == -1) { -#else - if (dt_ioctl(dtp, DTRACEIOC_AGGSNAP, &buf) == -1) { -#endif if (errno == ENOENT) { /* * If that failed with ENOENT, it may be because the @@ -653,7 +636,7 @@ dtrace_aggregate_snap(dtrace_hdl_t *dtp) return (0); for (i = 0; i < agp->dtat_ncpus; i++) { - if ((rval = dt_aggregate_snap_cpu(dtp, agp->dtat_cpus[i]))) + if (rval = dt_aggregate_snap_cpu(dtp, agp->dtat_cpus[i])) return (rval); } @@ -1131,7 +1114,7 @@ dt_aggwalk_rval(dtrace_hdl_t *dtp, dt_ahashent_t *h, int rval) case DTRACE_AGGWALK_REMOVE: { dtrace_aggdata_t *aggdata = &h->dtahe_data; - int max_cpus = agp->dtat_maxcpu; + int i, max_cpus = agp->dtat_maxcpu; /* * First, remove this hash entry from its hash chain. diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c index 8bd09151d1c4..64b29220491e 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -87,7 +87,6 @@ #include <sys/wait.h> #include <assert.h> -#include <string.h> #include <strings.h> #include <signal.h> #include <unistd.h> @@ -949,77 +948,6 @@ dt_action_speculate(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) } static void -dt_action_printm(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) -{ - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp); - - dt_node_t *size = dnp->dn_args; - dt_node_t *addr = dnp->dn_args->dn_list; - - char n[DT_TYPE_NAMELEN]; - - if (dt_node_is_posconst(size) == 0) { - dnerror(size, D_PRINTM_SIZE, "printm( ) argument #1 must " - "be a non-zero positive integral constant expression\n"); - } - - if (dt_node_is_pointer(addr) == 0) { - dnerror(addr, D_PRINTM_ADDR, - "printm( ) argument #2 is incompatible with " - "prototype:\n\tprototype: pointer\n" - "\t argument: %s\n", - dt_node_type_name(addr, n, sizeof (n))); - } - - dt_cg(yypcb, addr); - ap->dtad_difo = dt_as(yypcb); - ap->dtad_kind = DTRACEACT_PRINTM; - - ap->dtad_difo->dtdo_rtype.dtdt_flags |= DIF_TF_BYREF; - ap->dtad_difo->dtdo_rtype.dtdt_size = size->dn_value + sizeof(uintptr_t); -} - -static void -dt_action_printt(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) -{ - dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp); - - dt_node_t *size = dnp->dn_args; - dt_node_t *addr = dnp->dn_args->dn_list; - - char n[DT_TYPE_NAMELEN]; - - if (dt_node_is_posconst(size) == 0) { - dnerror(size, D_PRINTT_SIZE, "printt( ) argument #1 must " - "be a non-zero positive integral constant expression\n"); - } - - if (addr == NULL || addr->dn_kind != DT_NODE_FUNC || - addr->dn_ident != dt_idhash_lookup(dtp->dt_globals, "typeref")) { - dnerror(addr, D_PRINTT_ADDR, - "printt( ) argument #2 is incompatible with " - "prototype:\n\tprototype: typeref()\n" - "\t argument: %s\n", - dt_node_type_name(addr, n, sizeof (n))); - } - - dt_cg(yypcb, addr); - ap->dtad_difo = dt_as(yypcb); - ap->dtad_kind = DTRACEACT_PRINTT; - - ap->dtad_difo->dtdo_rtype.dtdt_flags |= DIF_TF_BYREF; - - /* - * Allow additional buffer space for the data size, type size, - * type string length and a stab in the dark (32 bytes) for the - * type string. The type string is part of the typeref() that - * this action references. - */ - ap->dtad_difo->dtdo_rtype.dtdt_size = size->dn_value + 3 * sizeof(uintptr_t) + 32; - -} - -static void dt_action_commit(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) { dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp); @@ -1085,12 +1013,6 @@ dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp) case DT_ACT_PRINTF: dt_action_printflike(dtp, dnp->dn_expr, sdp, DTRACEACT_PRINTF); break; - case DT_ACT_PRINTM: - dt_action_printm(dtp, dnp->dn_expr, sdp); - break; - case DT_ACT_PRINTT: - dt_action_printt(dtp, dnp->dn_expr, sdp); - break; case DT_ACT_RAISE: dt_action_raise(dtp, dnp->dn_expr, sdp); break; @@ -1667,9 +1589,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp) char **argv = malloc(sizeof (char *) * (argc + 5)); FILE *ofp = tmpfile(); -#if defined(sun) char ipath[20], opath[20]; /* big enough for /dev/fd/ + INT_MAX + \0 */ -#endif char verdef[32]; /* big enough for -D__SUNW_D_VERSION=0x%08x + \0 */ struct sigaction act, oact; @@ -1677,11 +1597,7 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp) int wstat, estat; pid_t pid; -#if defined(sun) off64_t off; -#else - off_t off = 0; -#endif int c; if (argv == NULL || ofp == NULL) { @@ -1708,10 +1624,8 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp) (void) fseeko64(ifp, off, SEEK_SET); } -#if defined(sun) (void) snprintf(ipath, sizeof (ipath), "/dev/fd/%d", fileno(ifp)); (void) snprintf(opath, sizeof (opath), "/dev/fd/%d", fileno(ofp)); -#endif bcopy(dtp->dt_cpp_argv, argv, sizeof (char *) * argc); @@ -1719,7 +1633,6 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp) "-D__SUNW_D_VERSION=0x%08x", dtp->dt_vmax); argv[argc++] = verdef; -#if defined(sun) switch (dtp->dt_stdcmode) { case DT_STDC_XA: case DT_STDC_XT: @@ -1732,9 +1645,6 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp) argv[argc++] = ipath; argv[argc++] = opath; -#else - argv[argc++] = "-P"; -#endif argv[argc] = NULL; /* @@ -1761,12 +1671,6 @@ dt_preproc(dtrace_hdl_t *dtp, FILE *ifp) } if (pid == 0) { -#if !defined(sun) - if (isatty(fileno(ifp)) == 0) - lseek(fileno(ifp), off, SEEK_SET); - dup2(fileno(ifp), 0); - dup2(fileno(ofp), 1); -#endif (void) execvp(dtp->dt_cpp_path, argv); _exit(errno == ENOENT ? 127 : 126); } @@ -2106,10 +2010,8 @@ dt_load_libs_dir(dtrace_hdl_t *dtp, const char *path) dt_dprintf("skipping library %s: %s\n", dld->dtld_library, dtrace_errmsg(dtp, dtrace_errno(dtp))); - } else { - dld->dtld_loaded = B_TRUE; + } else dt_program_destroy(dtp, pgp); - } } dt_lib_depend_free(dtp); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c index a33cccd676d2..4557c6f85cfa 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cg.c @@ -267,7 +267,7 @@ dt_cg_field_get(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp, * properties are used to compute shift as USHIFT or SSHIFT, below. */ if (dnp->dn_flags & DT_NF_SIGNED) { -#if BYTE_ORDER == _BIG_ENDIAN +#ifdef _BIG_ENDIAN shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY - mp->ctm_offset % NBBY; #else @@ -281,7 +281,7 @@ dt_cg_field_get(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp, instr = DIF_INSTR_FMT(DIF_OP_SRA, r1, r2, r1); dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr)); } else { -#if BYTE_ORDER == _BIG_ENDIAN +#ifdef _BIG_ENDIAN shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY - (mp->ctm_offset % NBBY + e.cte_bits); #else @@ -369,7 +369,7 @@ dt_cg_field_set(dt_node_t *src, dt_irlist_t *dlp, * input register to width cte_bits, and cmask as the mask used to * pass through the containing bits and zero the field bits. */ -#if BYTE_ORDER == _BIG_ENDIAN +#ifdef _BIG_ENDIAN shift = clp2(P2ROUNDUP(e.cte_bits, NBBY) / NBBY) * NBBY - (m.ctm_offset % NBBY + e.cte_bits); #else @@ -1339,40 +1339,6 @@ dt_cg_inline(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) } static void -dt_cg_func_typeref(dtrace_hdl_t *dtp, dt_node_t *dnp) -{ - dtrace_typeinfo_t dtt; - dt_node_t *addr = dnp->dn_args; - dt_node_t *nelm = addr->dn_list; - dt_node_t *strp = nelm->dn_list; - dt_node_t *typs = strp->dn_list; - char buf[DT_TYPE_NAMELEN]; - char *p; - - ctf_type_name(addr->dn_ctfp, addr->dn_type, buf, sizeof (buf)); - - /* - * XXX Hack alert! XXX - * The prototype has two dummy args that we munge to represent - * the type string and the type size. - * - * Yes, I hear your grumble, but it works for now. We'll come - * up with a more elegant implementation later. :-) - */ - free(strp->dn_string); - - if ((p = strchr(buf, '*')) != NULL) - *p = '\0'; - - strp->dn_string = strdup(buf); - - if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_EVERY, buf, &dtt) < 0) - return; - - typs->dn_value = ctf_type_size(dtt.dtt_ctfp, dtt.dtt_type); -} - -static void dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) { ctf_file_t *ctfp = dnp->dn_ctfp; @@ -1827,9 +1793,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) } switch (dnp->dn_kind) { - case DT_NODE_FUNC: { - dtrace_hdl_t *dtp = yypcb->pcb_hdl; - + case DT_NODE_FUNC: if ((idp = dnp->dn_ident)->di_kind != DT_IDENT_FUNC) { dnerror(dnp, D_CG_EXPR, "%s %s( ) may not be " "called from a D expression (D program " @@ -1837,15 +1801,6 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) dt_idkind_name(idp->di_kind), idp->di_name); } - switch (idp->di_id) { - case DIF_SUBR_TYPEREF: - dt_cg_func_typeref(dtp, dnp); - break; - - default: - break; - } - dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp); if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1) @@ -1858,7 +1813,6 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp) dt_cg_node_alloc(DT_LBL_NONE, instr)); break; - } case DT_NODE_VAR: if (dnp->dn_ident->di_kind == DT_IDENT_XLSOU || diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index 776fd17c0309..62d39e07dd41 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -32,9 +32,7 @@ #include <limits.h> #include <assert.h> #include <ctype.h> -#if defined(sun) #include <alloca.h> -#endif #include <dt_impl.h> #define DT_MASK_LO 0x00000000FFFFFFFFULL @@ -712,7 +710,7 @@ dt_print_stddev(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, /*ARGSUSED*/ int dt_print_bytes(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, - size_t nbytes, int width, int quiet, int raw) + size_t nbytes, int width, int quiet) { /* * If the byte stream is a series of printable characters, followed by @@ -725,7 +723,7 @@ dt_print_bytes(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, if (nbytes == 0) return (0); - if (raw || dtp->dt_options[DTRACEOPT_RAWBYTES] != DTRACEOPT_UNSET) + if (dtp->dt_options[DTRACEOPT_RAWBYTES] != DTRACEOPT_UNSET) goto raw; for (i = 0; i < nbytes; i++) { @@ -860,7 +858,7 @@ dt_print_stack(dtrace_hdl_t *dtp, FILE *fp, const char *format, return (dt_set_errno(dtp, EDT_BADSTACKPC)); } - if (pc == 0) + if (pc == NULL) break; addr += size; @@ -948,23 +946,15 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, if (P != NULL) dt_proc_lock(dtp, P); /* lock handle while we perform lookups */ - for (i = 0; i < depth && pc[i] != 0; i++) { + for (i = 0; i < depth && pc[i] != NULL; i++) { const prmap_t *map; if ((err = dt_printf(dtp, fp, "%*s", indent, "")) < 0) break; -#if defined(sun) if (P != NULL && Plookup_by_addr(P, pc[i], -#else - if (P != NULL && proc_addr2sym(P, pc[i], -#endif name, sizeof (name), &sym) == 0) { -#if defined(sun) (void) Pobjname(P, pc[i], objname, sizeof (objname)); -#else - (void) proc_objname(P, pc[i], objname, sizeof (objname)); -#endif if (pc[i] > sym.st_value) { (void) snprintf(c, sizeof (c), @@ -975,12 +965,8 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, "%s`%s", dt_basename(objname), name); } } else if (str != NULL && str[0] != '\0' && str[0] != '@' && -#if defined(sun) (P != NULL && ((map = Paddr_to_map(P, pc[i])) == NULL || (map->pr_mflags & MA_WRITE)))) { -#else - (P != NULL && ((map = proc_addr2map(P, pc[i])) == NULL))) { -#endif /* * If the current string pointer in the string table * does not point to an empty string _and_ the program @@ -996,12 +982,8 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, */ (void) snprintf(c, sizeof (c), "%s", str); } else { -#if defined(sun) if (P != NULL && Pobjname(P, pc[i], objname, -#else - if (P != NULL && proc_objname(P, pc[i], objname, -#endif - sizeof (objname)) != 0) { + sizeof (objname)) != NULL) { (void) snprintf(c, sizeof (c), "%s`0x%llx", dt_basename(objname), (u_longlong_t)pc[i]); } else { @@ -1070,11 +1052,7 @@ dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act) 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); @@ -1117,11 +1095,7 @@ dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) if (P != NULL) dt_proc_lock(dtp, P); /* lock handle while we perform lookups */ -#if defined(sun) - if (P != NULL && Pobjname(P, pc, objname, sizeof (objname)) != 0) { -#else - if (P != NULL && proc_objname(P, pc, objname, sizeof (objname)) != 0) { -#endif + if (P != NULL && Pobjname(P, pc, objname, sizeof (objname)) != NULL) { (void) snprintf(c, sizeof (c), "%s", dt_basename(objname)); } else { (void) snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc); @@ -1137,314 +1111,6 @@ dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) return (err); } -int -dt_print_memory(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr) -{ - int quiet = (dtp->dt_options[DTRACEOPT_QUIET] != DTRACEOPT_UNSET); - size_t nbytes = *((uintptr_t *) addr); - - return (dt_print_bytes(dtp, fp, addr + sizeof(uintptr_t), - nbytes, 50, quiet, 1)); -} - -typedef struct dt_type_cbdata { - dtrace_hdl_t *dtp; - dtrace_typeinfo_t dtt; - caddr_t addr; - caddr_t addrend; - const char *name; - int f_type; - int indent; - int type_width; - int name_width; - FILE *fp; -} dt_type_cbdata_t; - -static int dt_print_type_data(dt_type_cbdata_t *, ctf_id_t); - -static int -dt_print_type_member(const char *name, ctf_id_t type, ulong_t off, void *arg) -{ - dt_type_cbdata_t cbdata; - dt_type_cbdata_t *cbdatap = arg; - ssize_t ssz; - - if ((ssz = ctf_type_size(cbdatap->dtt.dtt_ctfp, type)) <= 0) - return (0); - - off /= 8; - - cbdata = *cbdatap; - cbdata.name = name; - cbdata.addr += off; - cbdata.addrend = cbdata.addr + ssz; - - return (dt_print_type_data(&cbdata, type)); -} - -static int -dt_print_type_width(const char *name, ctf_id_t type, ulong_t off, void *arg) -{ - char buf[DT_TYPE_NAMELEN]; - char *p; - dt_type_cbdata_t *cbdatap = arg; - size_t sz = strlen(name); - - ctf_type_name(cbdatap->dtt.dtt_ctfp, type, buf, sizeof (buf)); - - if ((p = strchr(buf, '[')) != NULL) - p[-1] = '\0'; - else - p = ""; - - sz += strlen(p); - - if (sz > cbdatap->name_width) - cbdatap->name_width = sz; - - sz = strlen(buf); - - if (sz > cbdatap->type_width) - cbdatap->type_width = sz; - - return (0); -} - -static int -dt_print_type_data(dt_type_cbdata_t *cbdatap, ctf_id_t type) -{ - caddr_t addr = cbdatap->addr; - caddr_t addrend = cbdatap->addrend; - char buf[DT_TYPE_NAMELEN]; - char *p; - int cnt = 0; - uint_t kind = ctf_type_kind(cbdatap->dtt.dtt_ctfp, type); - ssize_t ssz = ctf_type_size(cbdatap->dtt.dtt_ctfp, type); - - ctf_type_name(cbdatap->dtt.dtt_ctfp, type, buf, sizeof (buf)); - - if ((p = strchr(buf, '[')) != NULL) - p[-1] = '\0'; - else - p = ""; - - if (cbdatap->f_type) { - int type_width = roundup(cbdatap->type_width + 1, 4); - int name_width = roundup(cbdatap->name_width + 1, 4); - - name_width -= strlen(cbdatap->name); - - dt_printf(cbdatap->dtp, cbdatap->fp, "%*s%-*s%s%-*s = ",cbdatap->indent * 4,"",type_width,buf,cbdatap->name,name_width,p); - } - - while (addr < addrend) { - dt_type_cbdata_t cbdata; - ctf_arinfo_t arinfo; - ctf_encoding_t cte; - uintptr_t *up; - void *vp = addr; - cbdata = *cbdatap; - cbdata.name = ""; - cbdata.addr = addr; - cbdata.addrend = addr + ssz; - cbdata.f_type = 0; - cbdata.indent++; - cbdata.type_width = 0; - cbdata.name_width = 0; - - if (cnt > 0) - dt_printf(cbdatap->dtp, cbdatap->fp, "%*s", cbdatap->indent * 4,""); - - switch (kind) { - case CTF_K_INTEGER: - if (ctf_type_encoding(cbdatap->dtt.dtt_ctfp, type, &cte) != 0) - return (-1); - if ((cte.cte_format & CTF_INT_SIGNED) != 0) - switch (cte.cte_bits) { - case 8: - if (isprint(*((char *) vp))) - dt_printf(cbdatap->dtp, cbdatap->fp, "'%c', ", *((char *) vp)); - dt_printf(cbdatap->dtp, cbdatap->fp, "%d (0x%x);\n", *((char *) vp), *((char *) vp)); - break; - case 16: - dt_printf(cbdatap->dtp, cbdatap->fp, "%hd (0x%hx);\n", *((short *) vp), *((u_short *) vp)); - break; - case 32: - dt_printf(cbdatap->dtp, cbdatap->fp, "%d (0x%x);\n", *((int *) vp), *((u_int *) vp)); - break; - case 64: - dt_printf(cbdatap->dtp, cbdatap->fp, "%jd (0x%jx);\n", *((long long *) vp), *((unsigned long long *) vp)); - break; - default: - dt_printf(cbdatap->dtp, cbdatap->fp, "CTF_K_INTEGER: format %x offset %u bits %u\n",cte.cte_format,cte.cte_offset,cte.cte_bits); - break; - } - else - switch (cte.cte_bits) { - case 8: - dt_printf(cbdatap->dtp, cbdatap->fp, "%u (0x%x);\n", *((uint8_t *) vp) & 0xff, *((uint8_t *) vp) & 0xff); - break; - case 16: - dt_printf(cbdatap->dtp, cbdatap->fp, "%hu (0x%hx);\n", *((u_short *) vp), *((u_short *) vp)); - break; - case 32: - dt_printf(cbdatap->dtp, cbdatap->fp, "%u (0x%x);\n", *((u_int *) vp), *((u_int *) vp)); - break; - case 64: - dt_printf(cbdatap->dtp, cbdatap->fp, "%ju (0x%jx);\n", *((unsigned long long *) vp), *((unsigned long long *) vp)); - break; - default: - dt_printf(cbdatap->dtp, cbdatap->fp, "CTF_K_INTEGER: format %x offset %u bits %u\n",cte.cte_format,cte.cte_offset,cte.cte_bits); - break; - } - break; - case CTF_K_FLOAT: - dt_printf(cbdatap->dtp, cbdatap->fp, "CTF_K_FLOAT: format %x offset %u bits %u\n",cte.cte_format,cte.cte_offset,cte.cte_bits); - break; - case CTF_K_POINTER: - dt_printf(cbdatap->dtp, cbdatap->fp, "%p;\n", *((void **) addr)); - break; - case CTF_K_ARRAY: - if (ctf_array_info(cbdatap->dtt.dtt_ctfp, type, &arinfo) != 0) - return (-1); - dt_printf(cbdatap->dtp, cbdatap->fp, "{\n%*s",cbdata.indent * 4,""); - dt_print_type_data(&cbdata, arinfo.ctr_contents); - dt_printf(cbdatap->dtp, cbdatap->fp, "%*s};\n",cbdatap->indent * 4,""); - break; - case CTF_K_FUNCTION: - dt_printf(cbdatap->dtp, cbdatap->fp, "CTF_K_FUNCTION:\n"); - break; - case CTF_K_STRUCT: - cbdata.f_type = 1; - if (ctf_member_iter(cbdatap->dtt.dtt_ctfp, type, - dt_print_type_width, &cbdata) != 0) - return (-1); - dt_printf(cbdatap->dtp, cbdatap->fp, "{\n"); - if (ctf_member_iter(cbdatap->dtt.dtt_ctfp, type, - dt_print_type_member, &cbdata) != 0) - return (-1); - dt_printf(cbdatap->dtp, cbdatap->fp, "%*s};\n",cbdatap->indent * 4,""); - break; - case CTF_K_UNION: - cbdata.f_type = 1; - if (ctf_member_iter(cbdatap->dtt.dtt_ctfp, type, - dt_print_type_width, &cbdata) != 0) - return (-1); - dt_printf(cbdatap->dtp, cbdatap->fp, "{\n"); - if (ctf_member_iter(cbdatap->dtt.dtt_ctfp, type, - dt_print_type_member, &cbdata) != 0) - return (-1); - dt_printf(cbdatap->dtp, cbdatap->fp, "%*s};\n",cbdatap->indent * 4,""); - break; - case CTF_K_ENUM: - dt_printf(cbdatap->dtp, cbdatap->fp, "%s;\n", ctf_enum_name(cbdatap->dtt.dtt_ctfp, type, *((int *) vp))); - break; - case CTF_K_TYPEDEF: - dt_print_type_data(&cbdata, ctf_type_reference(cbdatap->dtt.dtt_ctfp,type)); - break; - case CTF_K_VOLATILE: - if (cbdatap->f_type) - dt_printf(cbdatap->dtp, cbdatap->fp, "volatile "); - dt_print_type_data(&cbdata, ctf_type_reference(cbdatap->dtt.dtt_ctfp,type)); - break; - case CTF_K_CONST: - if (cbdatap->f_type) - dt_printf(cbdatap->dtp, cbdatap->fp, "const "); - dt_print_type_data(&cbdata, ctf_type_reference(cbdatap->dtt.dtt_ctfp,type)); - break; - case CTF_K_RESTRICT: - if (cbdatap->f_type) - dt_printf(cbdatap->dtp, cbdatap->fp, "restrict "); - dt_print_type_data(&cbdata, ctf_type_reference(cbdatap->dtt.dtt_ctfp,type)); - break; - default: - break; - } - - addr += ssz; - cnt++; - } - - return (0); -} - -static int -dt_print_type(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr) -{ - caddr_t addrend; - char *p; - dtrace_typeinfo_t dtt; - dt_type_cbdata_t cbdata; - int num = 0; - int quiet = (dtp->dt_options[DTRACEOPT_QUIET] != DTRACEOPT_UNSET); - ssize_t ssz; - - if (!quiet) - dt_printf(dtp, fp, "\n"); - - /* Get the total number of bytes of data buffered. */ - size_t nbytes = *((uintptr_t *) addr); - addr += sizeof(uintptr_t); - - /* - * Get the size of the type so that we can check that it matches - * the CTF data we look up and so that we can figure out how many - * type elements are buffered. - */ - size_t typs = *((uintptr_t *) addr); - addr += sizeof(uintptr_t); - - /* - * Point to the type string in the buffer. Get it's string - * length and round it up to become the offset to the start - * of the buffered type data which we would like to be aligned - * for easy access. - */ - char *strp = (char *) addr; - int offset = roundup(strlen(strp) + 1, sizeof(uintptr_t)); - - /* - * The type string might have a format such as 'int [20]'. - * Check if there is an array dimension present. - */ - if ((p = strchr(strp, '[')) != NULL) { - /* Strip off the array dimension. */ - *p++ = '\0'; - - for (; *p != '\0' && *p != ']'; p++) - num = num * 10 + *p - '0'; - } else - /* No array dimension, so default. */ - num = 1; - - /* Lookup the CTF type from the type string. */ - if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_EVERY, strp, &dtt) < 0) - return (-1); - - /* Offset the buffer address to the start of the data... */ - addr += offset; - - ssz = ctf_type_size(dtt.dtt_ctfp, dtt.dtt_type); - - if (typs != ssz) { - printf("Expected type size from buffer (%lu) to match type size looked up now (%ld)\n", (u_long) typs, (long) ssz); - return (-1); - } - - cbdata.dtp = dtp; - cbdata.dtt = dtt; - cbdata.name = ""; - cbdata.addr = addr; - cbdata.addrend = addr + nbytes; - cbdata.indent = 1; - cbdata.f_type = 1; - cbdata.type_width = 0; - cbdata.name_width = 0; - cbdata.fp = fp; - - return (dt_print_type_data(&cbdata, dtt.dtt_type)); -} - static int dt_print_sym(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) { @@ -1764,7 +1430,7 @@ dt_print_datum(dtrace_hdl_t *dtp, FILE *fp, dtrace_recdesc_t *rec, (uint32_t)normal); break; default: - err = dt_print_bytes(dtp, fp, addr, size, 50, 0, 0); + err = dt_print_bytes(dtp, fp, addr, size, 50, 0); break; } @@ -2139,18 +1805,6 @@ again: goto nextrec; } - if (act == DTRACEACT_PRINTM) { - if (dt_print_memory(dtp, fp, addr) < 0) - return (-1); - goto nextrec; - } - - if (act == DTRACEACT_PRINTT) { - if (dt_print_type(dtp, fp, addr) < 0) - return (-1); - goto nextrec; - } - if (DTRACEACT_ISPRINTFLIKE(act)) { void *fmtdata; int (*func)(dtrace_hdl_t *, FILE *, void *, @@ -2281,7 +1935,7 @@ nofmt: break; default: n = dt_print_bytes(dtp, fp, addr, - rec->dtrd_size, 33, quiet, 0); + rec->dtrd_size, 33, quiet); break; } @@ -2410,20 +2064,13 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf, dt_begin_t begin; processorid_t cpu = dtp->dt_beganon; dtrace_bufdesc_t nbuf; -#if !defined(sun) - dtrace_bufdesc_t *pbuf; -#endif int rval, i; static int max_ncpus; dtrace_optval_t size; dtp->dt_beganon = -1; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) { -#else - if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) { -#endif /* * We really don't expect this to fail, but it is at least * technically possible for this to fail with ENOENT. In this @@ -2485,12 +2132,7 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf, if (i == cpu) continue; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &nbuf) == -1) { -#else - pbuf = &nbuf; - if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &pbuf) == -1) { -#endif /* * If we failed with ENOENT, it may be because the * CPU was unconfigured -- this is okay. Any other @@ -2597,11 +2239,7 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, if (dtp->dt_stopped && (i == dtp->dt_endedon)) continue; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) { -#else - if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) { -#endif /* * If we failed with ENOENT, it may be because the * CPU was unconfigured -- this is okay. Any other @@ -2622,11 +2260,7 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp, buf->dtbd_cpu = dtp->dt_endedon; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) { -#else - if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &buf) == -1) { -#endif /* * This _really_ shouldn't fail, but it is strictly speaking * possible for this to return ENOENT if the CPU that called diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c index f35a386c5d7d..075001157618 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_dof.c @@ -27,14 +27,10 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/types.h> -#if defined(sun) #include <sys/sysmacros.h> -#endif #include <strings.h> -#if defined(sun) #include <alloca.h> -#endif #include <assert.h> #include <stdlib.h> #include <errno.h> diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c index 263f70c85ecc..5005f593a43d 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_error.c @@ -25,7 +25,6 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#include <string.h> #include <strings.h> #include <dt_impl.h> @@ -139,29 +138,12 @@ dtrace_errno(dtrace_hdl_t *dtp) return (dtp->dt_errno); } -#if defined(sun) int dt_set_errno(dtrace_hdl_t *dtp, int err) { dtp->dt_errno = err; return (-1); } -#else -int -_dt_set_errno(dtrace_hdl_t *dtp, int err, const char *errfile, int errline) -{ - dtp->dt_errno = err; - dtp->dt_errfile = errfile; - dtp->dt_errline = errline; - return (-1); -} - -void dt_get_errloc(dtrace_hdl_t *dtp, const char **p_errfile, int *p_errline) -{ - *p_errfile = dtp->dt_errfile; - *p_errline = dtp->dt_errline; -} -#endif void dt_set_errmsg(dtrace_hdl_t *dtp, const char *errtag, const char *region, diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h index 62f955505711..9e32dfdf2492 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_errtags.h @@ -235,11 +235,7 @@ typedef enum { D_FREOPEN_INVALID, /* frename() filename is invalid */ D_LQUANT_MATCHBASE, /* lquantize() mismatch on base */ D_LQUANT_MATCHLIM, /* lquantize() mismatch on limit */ - D_LQUANT_MATCHSTEP, /* lquantize() mismatch on step */ - D_PRINTM_ADDR, /* printm() memref bad type */ - D_PRINTM_SIZE, /* printm() size bad type */ - D_PRINTT_ADDR, /* printt() typeref bad type */ - D_PRINTT_SIZE /* printt() size bad type */ + D_LQUANT_MATCHSTEP /* lquantize() mismatch on step */ } dt_errtag_t; extern const char *dt_errtag(dt_errtag_t); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c index ea039e993bd2..9d27aee4ded2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_handle.c @@ -31,9 +31,7 @@ #include <errno.h> #include <unistd.h> #include <assert.h> -#if defined(sun) #include <alloca.h> -#endif #include <dt_impl.h> #include <dt_program.h> @@ -249,7 +247,7 @@ dt_handle_liberr(dtrace_hdl_t *dtp, const dtrace_probedata_t *data, err.dteda_action = -1; err.dteda_offset = -1; err.dteda_fault = DTRACEFLT_LIBRARY; - err.dteda_addr = 0; + err.dteda_addr = NULL; len = strlen(faultstr) + strlen(errpd->dtpd_provider) + strlen(errpd->dtpd_mod) + diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c index 13adbb45e1a7..c437e0ab031a 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_ident.c @@ -26,20 +26,14 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#if defined(sun) #include <sys/sysmacros.h> -#endif #include <strings.h> #include <stdlib.h> -#if defined(sun) #include <alloca.h> -#endif #include <assert.h> #include <errno.h> #include <ctype.h> -#if defined(sun) #include <sys/procfs_isa.h> -#endif #include <limits.h> #include <dt_ident.h> diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h index 6bcc5bc49ab0..2454e3b7cd02 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h @@ -18,7 +18,6 @@ * * CDDL HEADER END */ - /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -31,13 +30,6 @@ #include <sys/param.h> #include <sys/objfs.h> -#if !defined(sun) -#include <sys/bitmap.h> -#include <sys/utsname.h> -#include <sys/ioccom.h> -#include <sys/time.h> -#include <string.h> -#endif #include <setjmp.h> #include <libctf.h> #include <dtrace.h> @@ -135,9 +127,6 @@ typedef struct dt_module { GElf_Addr dm_bss_va; /* virtual address of BSS */ GElf_Xword dm_bss_size; /* size in bytes of BSS */ dt_idhash_t *dm_extern; /* external symbol definitions */ -#if !defined(sun) - caddr_t dm_reloc_offset; /* Symbol relocation offset. */ -#endif } dt_module_t; #define DT_DM_LOADED 0x1 /* module symbol and type data is loaded */ @@ -194,7 +183,6 @@ typedef struct dt_lib_depend { char *dtld_libpath; /* library pathname */ uint_t dtld_finish; /* completion time in tsort for lib */ uint_t dtld_start; /* starting time in tsort for lib */ - uint_t dtld_loaded; /* boolean: is this library loaded */ dt_list_t dtld_dependencies; /* linked-list of lib dependencies */ dt_list_t dtld_dependents; /* linked-list of lib dependents */ } dt_lib_depend_t; @@ -277,20 +265,12 @@ struct dtrace_hdl { int dt_version; /* library version requested by client */ int dt_ctferr; /* error resulting from last CTF failure */ int dt_errno; /* error resulting from last failed operation */ -#if !defined(sun) - const char *dt_errfile; - int dt_errline; -#endif int dt_fd; /* file descriptor for dtrace pseudo-device */ int dt_ftfd; /* file descriptor for fasttrap pseudo-device */ int dt_fterr; /* saved errno from failed open of dt_ftfd */ int dt_cdefs_fd; /* file descriptor for C CTF debugging cache */ int dt_ddefs_fd; /* file descriptor for D CTF debugging cache */ -#if defined(sun) int dt_stdout_fd; /* file descriptor for saved stdout */ -#else - FILE *dt_freopen_fp; /* file pointer for freopened stdout */ -#endif dtrace_handle_err_f *dt_errhdlr; /* error handler, if any */ void *dt_errarg; /* error handler argument */ dtrace_prog_t *dt_errprog; /* error handler program, if any */ @@ -432,8 +412,6 @@ struct dtrace_hdl { #define DT_ACT_UMOD DT_ACT(26) /* umod() action */ #define DT_ACT_UADDR DT_ACT(27) /* uaddr() action */ #define DT_ACT_SETOPT DT_ACT(28) /* setopt() action */ -#define DT_ACT_PRINTM DT_ACT(29) /* printm() action */ -#define DT_ACT_PRINTT DT_ACT(30) /* printt() action */ /* * Sentinel to tell freopen() to restore the saved stdout. This must not @@ -561,21 +539,11 @@ extern int dt_version_defined(dt_version_t); extern char *dt_cpp_add_arg(dtrace_hdl_t *, const char *); extern char *dt_cpp_pop_arg(dtrace_hdl_t *); -#if defined(sun) extern int dt_set_errno(dtrace_hdl_t *, int); -#else -int _dt_set_errno(dtrace_hdl_t *, int, const char *, int); -void dt_get_errloc(dtrace_hdl_t *, const char **, int *); -#define dt_set_errno(_a,_b) _dt_set_errno(_a,_b,__FILE__,__LINE__) -#endif extern void dt_set_errmsg(dtrace_hdl_t *, const char *, const char *, const char *, int, const char *, va_list); -#if defined(sun) extern int dt_ioctl(dtrace_hdl_t *, int, void *); -#else -extern int dt_ioctl(dtrace_hdl_t *, u_long, void *); -#endif extern int dt_status(dtrace_hdl_t *, processorid_t); extern long dt_sysconf(dtrace_hdl_t *, int); extern ssize_t dt_write(dtrace_hdl_t *, int, const void *, size_t); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l index 48975274dede..fc74df15e0a6 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l @@ -41,32 +41,12 @@ * We need to undefine lex's input and unput macros so that references to these * call the functions provided at the end of this source file. */ -#if defined(sun) #undef input #undef unput -#else -/* - * Define YY_INPUT for flex since input() can't be re-defined. - */ -#define YY_INPUT(buf,result,max_size) \ - if (yypcb->pcb_fileptr != NULL) { \ - if (((result = fread(buf, 1, max_size, yypcb->pcb_fileptr)) == 0) \ - && ferror(yypcb->pcb_fileptr)) \ - longjmp(yypcb->pcb_jmpbuf, EDT_FIO); \ - } else { \ - int n; \ - for (n = 0; n < max_size && \ - yypcb->pcb_strptr < yypcb->pcb_string + yypcb->pcb_strlen; n++) \ - buf[n] = *yypcb->pcb_strptr++; \ - result = n; \ - } -#endif static int id_or_type(const char *); -#if defined(sun) static int input(void); static void unput(int); -#endif /* * We first define a set of labeled states for use in the D lexer and then a @@ -428,7 +408,7 @@ if (yypcb->pcb_token != 0) { xyerror(D_CHR_OFLOW, "character constant is " "too long"); } -#if BYTE_ORDER == _LITTLE_ENDIAN +#ifdef _LITTLE_ENDIAN p = ((char *)&yylval.l_int) + nbytes - 1; for (q = s; nbytes != 0; nbytes--) *p-- = *q++; @@ -717,9 +697,7 @@ yyinit(dt_pcb_t *pcb) yypcb = pcb; yylineno = 1; yypragma = NULL; -#if defined(sun) yysptr = yysbuf; -#endif } /* @@ -815,7 +793,6 @@ id_or_type(const char *s) return (ttok); } -#if defined(sun) static int input(void) { @@ -857,4 +834,3 @@ unput(int c) *yysptr++ = c; yytchar = c; } -#endif diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c index bc46df577a27..957d8f8bc3df 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -30,28 +30,18 @@ #include <elf.h> #include <sys/types.h> -#if defined(sun) #include <sys/sysmacros.h> -#else -#define P2ROUNDUP(x, align) (-(-(x) & -(align))) -#endif #include <unistd.h> #include <strings.h> -#if defined(sun) #include <alloca.h> -#endif #include <limits.h> #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <fcntl.h> #include <errno.h> -#if defined(sun) #include <wait.h> -#else -#include <sys/wait.h> -#endif #include <assert.h> #include <sys/ipc.h> @@ -224,23 +214,11 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep) s = &dofs[dofrh->dofr_tgtsec]; for (j = 0; j < nrel; j++) { -#if defined(__arm__) -/* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#elif defined(__ia64__) -/* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#elif defined(__i386) || defined(__amd64) +#if defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; rel->r_info = ELF32_R_INFO(count + dep->de_global, R_386_32); -#elif defined(__mips__) -/* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#elif defined(__powerpc__) -/* XXX */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); #elif defined(__sparc) /* * Add 4 bytes to hit the low half of this 64-bit @@ -412,17 +390,7 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep) s = &dofs[dofrh->dofr_tgtsec]; for (j = 0; j < nrel; j++) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD -#if defined(__arm__) -/* XXX */ -#elif defined(__ia64__) -/* XXX */ -#elif defined(__mips__) -/* XXX */ -#elif defined(__powerpc__) -/* XXX */ -#elif defined(__i386) || defined(__amd64) +#if defined(__i386) || defined(__amd64) rel->r_offset = s->dofs_offset + dofr[j].dofr_offset; rel->r_info = ELF64_R_INFO(count + dep->de_global, @@ -435,7 +403,6 @@ printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); #else #error unknown ISA #endif -#endif sym->st_name = base + dofr[j].dofr_name - 1; sym->st_value = 0; @@ -513,24 +480,13 @@ dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) elf_file.ehdr.e_ident[EI_MAG3] = ELFMAG3; elf_file.ehdr.e_ident[EI_VERSION] = EV_CURRENT; elf_file.ehdr.e_ident[EI_CLASS] = ELFCLASS32; -#if BYTE_ORDER == _BIG_ENDIAN +#if defined(_BIG_ENDIAN) elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2MSB; -#else +#elif defined(_LITTLE_ENDIAN) elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2LSB; #endif -#if defined(__FreeBSD__) - elf_file.ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; -#endif elf_file.ehdr.e_type = ET_REL; -#if defined(__arm__) - elf_file.ehdr.e_machine = EM_ARM; -#elif defined(__ia64__) - elf_file.ehdr.e_machine = EM_IA_64; -#elif defined(__mips__) - elf_file.ehdr.e_machine = EM_MIPS; -#elif defined(__powerpc__) - elf_file.ehdr.e_machine = EM_PPC; -#elif defined(__sparc) +#if defined(__sparc) elf_file.ehdr.e_machine = EM_SPARC; #elif defined(__i386) || defined(__amd64) elf_file.ehdr.e_machine = EM_386; @@ -661,24 +617,13 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd) elf_file.ehdr.e_ident[EI_MAG3] = ELFMAG3; elf_file.ehdr.e_ident[EI_VERSION] = EV_CURRENT; elf_file.ehdr.e_ident[EI_CLASS] = ELFCLASS64; -#if BYTE_ORDER == _BIG_ENDIAN +#if defined(_BIG_ENDIAN) elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2MSB; -#else +#elif defined(_LITTLE_ENDIAN) elf_file.ehdr.e_ident[EI_DATA] = ELFDATA2LSB; #endif -#if defined(__FreeBSD__) - elf_file.ehdr.e_ident[EI_OSABI] = ELFOSABI_FREEBSD; -#endif elf_file.ehdr.e_type = ET_REL; -#if defined(__arm__) - elf_file.ehdr.e_machine = EM_ARM; -#elif defined(__ia64__) - elf_file.ehdr.e_machine = EM_IA_64; -#elif defined(__mips__) - elf_file.ehdr.e_machine = EM_MIPS; -#elif defined(__powerpc__) - elf_file.ehdr.e_machine = EM_PPC; -#elif defined(__sparc) +#if defined(__sparc) elf_file.ehdr.e_machine = EM_SPARCV9; #elif defined(__i386) || defined(__amd64) elf_file.ehdr.e_machine = EM_AMD64; @@ -794,44 +739,7 @@ dt_symtab_lookup(Elf_Data *data_sym, int nsym, uintptr_t addr, uint_t shn, return (ret); } -#if defined(__arm__) -/* XXX */ -static int -dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, - uint32_t *off) -{ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); - return (0); -} -#elif defined(__ia64__) -/* XXX */ -static int -dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, - uint32_t *off) -{ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); - return (0); -} -#elif defined(__mips__) -/* XXX */ -static int -dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, - uint32_t *off) -{ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); - return (0); -} -#elif defined(__powerpc__) -/* XXX */ -static int -dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, - uint32_t *off) -{ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); - return (0); -} - -#elif defined(__sparc) +#if defined(__sparc) #define DT_OP_RET 0x81c7e008 #define DT_OP_NOP 0x01000000 @@ -942,9 +850,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, #elif defined(__i386) || defined(__amd64) #define DT_OP_NOP 0x90 -#define DT_OP_RET 0xc3 #define DT_OP_CALL 0xe8 -#define DT_OP_JMP32 0xe9 #define DT_OP_REX_RAX 0x48 #define DT_OP_XOR_EAX_0 0x33 #define DT_OP_XOR_EAX_1 0xc0 @@ -954,7 +860,6 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, uint32_t *off) { uint8_t *ip = (uint8_t *)(p + rela->r_offset - 1); - uint8_t ret; /* * On x86, the first byte of the instruction is the call opcode and @@ -978,43 +883,38 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, * We may have already processed this object file in an earlier linker * invocation. Check to see if the present instruction sequence matches * the one we would install. For is-enabled probes, we advance the - * offset to the first nop instruction in the sequence to match the - * text modification code below. + * offset to the first nop instruction in the sequence. */ if (!isenabled) { - if ((ip[0] == DT_OP_NOP || ip[0] == DT_OP_RET) && - ip[1] == DT_OP_NOP && ip[2] == DT_OP_NOP && - ip[3] == DT_OP_NOP && ip[4] == DT_OP_NOP) + if (ip[0] == DT_OP_NOP && ip[1] == DT_OP_NOP && + ip[2] == DT_OP_NOP && ip[3] == DT_OP_NOP && + ip[4] == DT_OP_NOP) return (0); } else if (dtp->dt_oflags & DTRACE_O_LP64) { if (ip[0] == DT_OP_REX_RAX && ip[1] == DT_OP_XOR_EAX_0 && ip[2] == DT_OP_XOR_EAX_1 && - (ip[3] == DT_OP_NOP || ip[3] == DT_OP_RET) && - ip[4] == DT_OP_NOP) { + ip[3] == DT_OP_NOP && ip[4] == DT_OP_NOP) { (*off) += 3; return (0); } } else { if (ip[0] == DT_OP_XOR_EAX_0 && ip[1] == DT_OP_XOR_EAX_1 && - (ip[2] == DT_OP_NOP || ip[2] == DT_OP_RET) && - ip[3] == DT_OP_NOP && ip[4] == DT_OP_NOP) { + ip[2] == DT_OP_NOP && ip[3] == DT_OP_NOP && + ip[4] == DT_OP_NOP) { (*off) += 2; return (0); } } /* - * We expect either a call instrution with a 32-bit displacement or a - * jmp instruction with a 32-bit displacement acting as a tail-call. + * We only expect a call instrution with a 32-bit displacement. */ - if (ip[0] != DT_OP_CALL && ip[0] != DT_OP_JMP32) { - dt_dprintf("found %x instead of a call or jmp instruction at " - "%llx\n", ip[0], (u_longlong_t)rela->r_offset); + if (ip[0] != DT_OP_CALL) { + dt_dprintf("found %x instead of a call instruction at %llx\n", + ip[0], (u_longlong_t)rela->r_offset); return (-1); } - ret = (ip[0] == DT_OP_JMP32) ? DT_OP_RET : DT_OP_NOP; - /* * Establish the instruction sequence -- all nops for probes, and an * instruction to clear the return value register (%eax/%rax) followed @@ -1023,7 +923,7 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, * for more readable disassembly when the probe is enabled. */ if (!isenabled) { - ip[0] = ret; + ip[0] = DT_OP_NOP; ip[1] = DT_OP_NOP; ip[2] = DT_OP_NOP; ip[3] = DT_OP_NOP; @@ -1032,13 +932,13 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, ip[0] = DT_OP_REX_RAX; ip[1] = DT_OP_XOR_EAX_0; ip[2] = DT_OP_XOR_EAX_1; - ip[3] = ret; + ip[3] = DT_OP_NOP; ip[4] = DT_OP_NOP; (*off) += 3; } else { ip[0] = DT_OP_XOR_EAX_0; ip[1] = DT_OP_XOR_EAX_1; - ip[2] = ret; + ip[2] = DT_OP_NOP; ip[3] = DT_OP_NOP; ip[4] = DT_OP_NOP; (*off) += 2; @@ -1133,13 +1033,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) if (dtp->dt_oflags & DTRACE_O_LP64) { eclass = ELFCLASS64; -#if defined(__ia64__) - emachine1 = emachine2 = EM_IA_64; -#elif defined(__mips__) - emachine1 = emachine2 = EM_MIPS; -#elif defined(__powerpc__) - emachine1 = emachine2 = EM_PPC64; -#elif defined(__sparc) +#if defined(__sparc) emachine1 = emachine2 = EM_SPARCV9; #elif defined(__i386) || defined(__amd64) emachine1 = emachine2 = EM_AMD64; @@ -1147,16 +1041,10 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) symsize = sizeof (Elf64_Sym); } else { eclass = ELFCLASS32; -#if defined(__arm__) - emachine1 = emachine2 = EM_ARM; -#elif defined(__mips__) - emachine1 = emachine2 = EM_MIPS; -#elif defined(__powerpc__) - emachine1 = emachine2 = EM_PPC; -#elif defined(__sparc) +#if defined(__sparc) emachine1 = EM_SPARC; emachine2 = EM_SPARC32PLUS; -#elif defined(__i386) || defined(__amd64) || defined(__ia64__) +#elif defined(__i386) || defined(__amd64) emachine1 = emachine2 = EM_386; #endif symsize = sizeof (Elf32_Sym); @@ -1519,13 +1407,10 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp) * already been processed by an earlier link * invocation. */ -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD if (rsym.st_shndx != SHN_SUNW_IGNORE) { rsym.st_shndx = SHN_SUNW_IGNORE; (void) gelf_update_sym(data_sym, ndx, &rsym); } -#endif } } @@ -1553,9 +1438,6 @@ int dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, const char *file, int objc, char *const objv[]) { -#if !defined(sun) - char tfile[PATH_MAX]; -#endif char drti[PATH_MAX]; dof_hdr_t *dof; int fd, status, i, cur; @@ -1563,11 +1445,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, size_t len; int eprobes = 0, ret = 0; -#if !defined(sun) - /* XXX Should get a temp file name here. */ - snprintf(tfile, sizeof(tfile), "%s.tmp", file); -#endif - /* * A NULL program indicates a special use in which we just link * together a bunch of object files specified in objv and then @@ -1629,7 +1506,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, if ((dof = dtrace_dof_create(dtp, pgp, dflags)) == NULL) return (-1); /* errno is set for us */ -#if defined(sun) /* * Create a temporary file and then unlink it if we're going to * combine it with drti.o later. We can still refer to it in child @@ -1639,11 +1515,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, return (dt_link_error(dtp, NULL, -1, NULL, "failed to open %s: %s", file, strerror(errno))); } -#else - if ((fd = open(tfile, O_RDWR | O_CREAT | O_TRUNC, 0666)) == -1) - return (dt_link_error(dtp, NULL, -1, NULL, - "failed to open %s: %s", tfile, strerror(errno))); -#endif /* * If -xlinktype=DOF has been selected, just write out the DOF. @@ -1673,10 +1544,8 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, } -#if defined(sun) if (!dtp->dt_lazyload) (void) unlink(file); -#endif if (dtp->dt_oflags & DTRACE_O_LP64) status = dump_elf64(dtp, dof, fd); @@ -1689,7 +1558,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, } if (!dtp->dt_lazyload) { -#if defined(sun) const char *fmt = "%s -o %s -r -Blocal -Breduce /dev/fd/%d %s"; if (dtp->dt_oflags & DTRACE_O_LP64) { @@ -1706,37 +1574,6 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, cmd = alloca(len); (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti); -#else - const char *fmt = "%s -o %s -r %s %s"; - -#if defined(__amd64__) - /* - * Arches which default to 64-bit need to explicitly use - * the 32-bit library path. - */ - int use_32 = !(dtp->dt_oflags & DTRACE_O_LP64); -#else - /* - * Arches which are 32-bit only just use the normal - * library path. - */ -#if defined(__i386__) - int use_32 = 1; /* use /usr/lib/... -sson */ -#else - int use_32 = 0; -#endif -#endif - - (void) snprintf(drti, sizeof (drti), "/usr/lib%s/dtrace/drti.o", - use_32 ? "":"32"); - - len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile, - drti) + 1; - - cmd = alloca(len); - - (void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, tfile, drti); -#endif if ((status = system(cmd)) == -1) { ret = dt_link_error(dtp, NULL, -1, NULL, @@ -1766,9 +1603,5 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags, done: dtrace_dof_destroy(dtp, dof); - -#if !defined(sun) - unlink(tfile); -#endif return (ret); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c index 1c5c868bb4b0..15361862de8f 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_map.c @@ -82,11 +82,7 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id) enabled->dtepd_epid = id; enabled->dtepd_nrecs = 1; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled) == -1) { -#else - if (dt_ioctl(dtp, DTRACEIOC_EPROBE, &enabled) == -1) { -#endif rval = dt_set_errno(dtp, errno); free(enabled); return (rval); @@ -106,11 +102,7 @@ dt_epid_add(dtrace_hdl_t *dtp, dtrace_epid_t id) if ((enabled = nenabled) == NULL) return (dt_set_errno(dtp, EDT_NOMEM)); -#if defined(sun) rval = dt_ioctl(dtp, DTRACEIOC_EPROBE, enabled); -#else - rval = dt_ioctl(dtp, DTRACEIOC_EPROBE, &enabled); -#endif if (rval == -1) { rval = dt_set_errno(dtp, errno); @@ -330,11 +322,7 @@ dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id) agg->dtagd_id = id; agg->dtagd_nrecs = 1; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg) == -1) { -#else - if (dt_ioctl(dtp, DTRACEIOC_AGGDESC, &agg) == -1) { -#endif rval = dt_set_errno(dtp, errno); free(agg); return (rval); @@ -353,11 +341,7 @@ dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id) if ((agg = nagg) == NULL) return (dt_set_errno(dtp, EDT_NOMEM)); -#if defined(sun) rval = dt_ioctl(dtp, DTRACEIOC_AGGDESC, agg); -#else - rval = dt_ioctl(dtp, DTRACEIOC_AGGDESC, &agg); -#endif if (rval == -1) { rval = dt_set_errno(dtp, errno); @@ -375,7 +359,7 @@ dt_aggid_add(dtrace_hdl_t *dtp, dtrace_aggid_t id) * provide the compiler-generated aggregation information. */ if (dtp->dt_options[DTRACEOPT_GRABANON] == DTRACEOPT_UNSET && - agg->dtagd_rec[0].dtrd_uarg != 0) { + agg->dtagd_rec[0].dtrd_uarg != NULL) { dtrace_stmtdesc_t *sdp; dt_ident_t *aid; diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c index af175012b3be..25197031ce11 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c @@ -26,23 +26,15 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/types.h> -#if defined(sun) #include <sys/modctl.h> #include <sys/kobj.h> #include <sys/kobj_impl.h> #include <sys/sysmacros.h> #include <sys/elf.h> #include <sys/task.h> -#else -#include <sys/param.h> -#include <sys/linker.h> -#include <sys/stat.h> -#endif #include <unistd.h> -#if defined(sun) #include <project.h> -#endif #include <strings.h> #include <stdlib.h> #include <libelf.h> @@ -50,9 +42,6 @@ #include <assert.h> #include <errno.h> #include <dirent.h> -#if !defined(sun) -#include <fcntl.h> -#endif #include <dt_strtab.h> #include <dt_module.h> @@ -77,7 +66,7 @@ dt_module_symhash_insert(dt_module_t *dmp, const char *name, uint_t id) static uint_t dt_module_syminit32(dt_module_t *dmp) { - Elf32_Sym *sym = dmp->dm_symtab.cts_data; + const Elf32_Sym *sym = dmp->dm_symtab.cts_data; const char *base = dmp->dm_strtab.cts_data; size_t ss_size = dmp->dm_strtab.cts_size; uint_t i, n = dmp->dm_nsymelems; @@ -94,14 +83,9 @@ dt_module_syminit32(dt_module_t *dmp) continue; /* skip null or invalid names */ if (sym->st_value != 0 && - (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + (ELF32_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) asrsv++; /* reserve space in the address map */ -#if !defined(sun) - sym->st_value += (Elf_Addr) dmp->dm_reloc_offset; -#endif - } - dt_module_symhash_insert(dmp, name, i); } @@ -111,7 +95,7 @@ dt_module_syminit32(dt_module_t *dmp) static uint_t dt_module_syminit64(dt_module_t *dmp) { - Elf64_Sym *sym = dmp->dm_symtab.cts_data; + const Elf64_Sym *sym = dmp->dm_symtab.cts_data; const char *base = dmp->dm_strtab.cts_data; size_t ss_size = dmp->dm_strtab.cts_size; uint_t i, n = dmp->dm_nsymelems; @@ -128,14 +112,9 @@ dt_module_syminit64(dt_module_t *dmp) continue; /* skip null or invalid names */ if (sym->st_value != 0 && - (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) { + (ELF64_ST_BIND(sym->st_info) != STB_LOCAL || sym->st_size)) asrsv++; /* reserve space in the address map */ -#if !defined(sun) - sym->st_value += (Elf_Addr) dmp->dm_reloc_offset; -#endif - } - dt_module_symhash_insert(dmp, name, i); } @@ -510,13 +489,7 @@ dt_module_load_sect(dtrace_hdl_t *dtp, dt_module_t *dmp, ctf_sect_t *ctsp) if (sp == NULL || (dp = elf_getdata(sp, NULL)) == NULL) return (0); -#if defined(sun) ctsp->cts_data = dp->d_buf; -#else - if ((ctsp->cts_data = malloc(dp->d_size)) == NULL) - return (0); - memcpy(ctsp->cts_data, dp->d_buf, dp->d_size); -#endif ctsp->cts_size = dp->d_size; dt_dprintf("loaded %s [%s] (%lu bytes)\n", @@ -692,18 +665,6 @@ dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp) ctf_close(dmp->dm_ctfp); dmp->dm_ctfp = NULL; -#if !defined(sun) - if (dmp->dm_ctdata.cts_data != NULL) { - free(dmp->dm_ctdata.cts_data); - } - if (dmp->dm_symtab.cts_data != NULL) { - free(dmp->dm_symtab.cts_data); - } - if (dmp->dm_strtab.cts_data != NULL) { - free(dmp->dm_strtab.cts_data); - } -#endif - bzero(&dmp->dm_ctdata, sizeof (ctf_sect_t)); bzero(&dmp->dm_symtab, sizeof (ctf_sect_t)); bzero(&dmp->dm_strtab, sizeof (ctf_sect_t)); @@ -729,11 +690,11 @@ dt_module_unload(dtrace_hdl_t *dtp, dt_module_t *dmp) dmp->dm_asrsv = 0; dmp->dm_aslen = 0; - dmp->dm_text_va = 0; + dmp->dm_text_va = NULL; dmp->dm_text_size = 0; - dmp->dm_data_va = 0; + dmp->dm_data_va = NULL; dmp->dm_data_size = 0; - dmp->dm_bss_va = 0; + dmp->dm_bss_va = NULL; dmp->dm_bss_size = 0; if (dmp->dm_extern != NULL) { @@ -820,16 +781,9 @@ dt_module_modelname(dt_module_t *dmp) /* * Update our module cache by adding an entry for the specified module 'name'. * We create the dt_module_t and populate it using /system/object/<name>/. - * - * On FreeBSD, the module name is passed as the full module file name, - * including the path. */ static void -#if defined(sun) dt_module_update(dtrace_hdl_t *dtp, const char *name) -#else -dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) -#endif { char fname[MAXPATHLEN]; struct stat64 st; @@ -842,17 +796,8 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) Elf_Data *dp; Elf_Scn *sp; -#if defined(sun) (void) snprintf(fname, sizeof (fname), "%s/%s/object", OBJFS_ROOT, name); -#else - GElf_Phdr ph; - char name[MAXPATHLEN]; - int i = 0; - - (void) strlcpy(name, k_stat->name, sizeof(name)); - (void) strlcpy(fname, k_stat->pathname, sizeof(fname)); -#endif if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 || (dmp = dt_module_create(dtp, name)) == NULL) { @@ -924,23 +869,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) } dmp->dm_flags |= DT_DM_KERNEL; -#if defined(sun) dmp->dm_modid = (int)OBJFS_MODID(st.st_ino); -#else -#if defined(__i386__) - /* - * Find the first load section and figure out the relocation - * offset for the symbols. The kernel module will not need - * relocation, but the kernel linker modules will. - */ - for (i = 0; gelf_getphdr(dmp->dm_elf, i, &ph) != NULL; i++) { - if (ph.p_type == PT_LOAD) { - dmp->dm_reloc_offset = k_stat->address - ph.p_vaddr; - break; - } - } -#endif -#endif if (dmp->dm_info.objfs_info_primary) dmp->dm_flags |= DT_DM_PRIMARY; @@ -958,15 +887,11 @@ dtrace_update(dtrace_hdl_t *dtp) { dt_module_t *dmp; DIR *dirp; -#if defined(__FreeBSD__) - int fileid; -#endif for (dmp = dt_list_next(&dtp->dt_modlist); dmp != NULL; dmp = dt_list_next(dmp)) dt_module_unload(dtp, dmp); -#if defined(sun) /* * Open /system/object and attempt to create a libdtrace module for * each kernel module that is loaded on the current system. @@ -982,18 +907,6 @@ dtrace_update(dtrace_hdl_t *dtp) (void) closedir(dirp); } -#elif defined(__FreeBSD__) - /* - * Use FreeBSD's kernel loader interface to discover what kernel - * modules are loaded and create a libdtrace module for each one. - */ - for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) { - struct kld_file_stat k_stat; - k_stat.version = sizeof(k_stat); - if (kldstat(fileid, &k_stat) == 0) - dt_module_update(dtp, &k_stat); - } -#endif /* * Look up all the macro identifiers and set di_id to the latest value. @@ -1006,13 +919,9 @@ dtrace_update(dtrace_hdl_t *dtp) dt_idhash_lookup(dtp->dt_macros, "pid")->di_id = getpid(); dt_idhash_lookup(dtp->dt_macros, "pgid")->di_id = getpgid(0); dt_idhash_lookup(dtp->dt_macros, "ppid")->di_id = getppid(); -#if defined(sun) dt_idhash_lookup(dtp->dt_macros, "projid")->di_id = getprojid(); -#endif dt_idhash_lookup(dtp->dt_macros, "sid")->di_id = getsid(0); -#if defined(sun) dt_idhash_lookup(dtp->dt_macros, "taskid")->di_id = gettaskid(); -#endif dt_idhash_lookup(dtp->dt_macros, "uid")->di_id = getuid(); /* diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c index ec7dec090533..5c04bee77e5b 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c @@ -27,17 +27,13 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/types.h> -#if defined(sun) #include <sys/modctl.h> #include <sys/systeminfo.h> -#endif #include <sys/resource.h> #include <libelf.h> #include <strings.h> -#if defined(sun) #include <alloca.h> -#endif #include <limits.h> #include <unistd.h> #include <stdlib.h> @@ -56,13 +52,6 @@ #include <dt_printf.h> #include <dt_string.h> #include <dt_provider.h> -#if !defined(sun) -#include <sys/sysctl.h> -#include <string.h> -#endif -#if defined(__i386__) -#include <ieeefp.h> -#endif /* * Stability and versioning definitions. These #defines are used in the tables @@ -114,9 +103,8 @@ #define DT_VERS_1_4_1 DT_VERSION_NUMBER(1, 4, 1) #define DT_VERS_1_5 DT_VERSION_NUMBER(1, 5, 0) #define DT_VERS_1_6 DT_VERSION_NUMBER(1, 6, 0) -#define DT_VERS_1_6_1 DT_VERSION_NUMBER(1, 6, 1) -#define DT_VERS_LATEST DT_VERS_1_6_1 -#define DT_VERS_STRING "Sun D 1.6.1" +#define DT_VERS_LATEST DT_VERS_1_6 +#define DT_VERS_STRING "Sun D 1.6" const dt_version_t _dtrace_versions[] = { DT_VERS_1_0, /* D API 1.0.0 (PSARC 2001/466) Solaris 10 FCS */ @@ -129,22 +117,10 @@ const dt_version_t _dtrace_versions[] = { DT_VERS_1_4_1, /* D API 1.4.1 Solaris Express 4/07 */ DT_VERS_1_5, /* D API 1.5 Solaris Express 7/07 */ DT_VERS_1_6, /* D API 1.6 */ - DT_VERS_1_6_1, /* D API 1.6.1 */ 0 }; /* - * Global variables that are formatted on FreeBSD based on the kernel file name. - */ -#if !defined(sun) -static char curthread_str[MAXPATHLEN]; -static char intmtx_str[MAXPATHLEN]; -static char threadmtx_str[MAXPATHLEN]; -static char rwlock_str[MAXPATHLEN]; -static char sxlock_str[MAXPATHLEN]; -#endif - -/* * Table of global identifiers. This is used to populate the global identifier * hash when a new dtrace client open occurs. For more info see dt_ident.h. * The global identifiers that represent functions use the dt_idops_func ops @@ -218,11 +194,7 @@ static const dt_ident_t _dtrace_globals[] = { { "curthread", DT_IDENT_SCALAR, 0, DIF_VAR_CURTHREAD, { DTRACE_STABILITY_STABLE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_COMMON }, DT_VERS_1_0, -#if defined(sun) &dt_idops_type, "genunix`kthread_t *" }, -#else - &dt_idops_type, curthread_str }, -#endif { "ddi_pathname", DT_IDENT_FUNC, 0, DIF_SUBR_DDI_PATHNAME, DT_ATTR_EVOLCMN, DT_VERS_1_0, &dt_idops_func, "string(void *, int64_t)" }, @@ -236,8 +208,6 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_type, "uint_t" }, { "errno", DT_IDENT_SCALAR, 0, DIF_VAR_ERRNO, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "int" }, -{ "execargs", DT_IDENT_SCALAR, 0, DIF_VAR_EXECARGS, - DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, { "execname", DT_IDENT_SCALAR, 0, DIF_VAR_EXECNAME, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, { "exit", DT_IDENT_ACTFUNC, 0, DT_ACT_EXIT, DT_ATTR_STABCMN, DT_VERS_1_0, @@ -267,25 +237,15 @@ static const dt_ident_t _dtrace_globals[] = { { "index", DT_IDENT_FUNC, 0, DIF_SUBR_INDEX, DT_ATTR_STABCMN, DT_VERS_1_1, &dt_idops_func, "int(const char *, const char *, [int])" }, { "inet_ntoa", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA, DT_ATTR_STABCMN, -#if defined(sun) DT_VERS_1_5, &dt_idops_func, "string(ipaddr_t *)" }, -#else - DT_VERS_1_5, &dt_idops_func, "string(in_addr_t *)" }, -#endif { "inet_ntoa6", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOA6, DT_ATTR_STABCMN, -#if defined(sun) DT_VERS_1_5, &dt_idops_func, "string(in6_addr_t *)" }, -#else - DT_VERS_1_5, &dt_idops_func, "string(struct in6_addr *)" }, -#endif { "inet_ntop", DT_IDENT_FUNC, 0, DIF_SUBR_INET_NTOP, DT_ATTR_STABCMN, DT_VERS_1_5, &dt_idops_func, "string(int, void *)" }, { "ipl", DT_IDENT_SCALAR, 0, DIF_VAR_IPL, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "uint_t" }, -#if defined(sun) { "jstack", DT_IDENT_ACTFUNC, 0, DT_ACT_JSTACK, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "stack(...)" }, -#endif { "lltostr", DT_IDENT_FUNC, 0, DIF_SUBR_LLTOSTR, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "string(int64_t)" }, { "lquantize", DT_IDENT_AGGFUNC, 0, DTRACEAGG_LQUANTIZE, @@ -293,8 +253,6 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_func, "void(@, int32_t, int32_t, ...)" }, { "max", DT_IDENT_AGGFUNC, 0, DTRACEAGG_MAX, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@)" }, -{ "memref", DT_IDENT_FUNC, 0, DIF_SUBR_MEMREF, DT_ATTR_STABCMN, DT_VERS_1_1, - &dt_idops_func, "uintptr_t *(void *, size_t)" }, { "min", DT_IDENT_AGGFUNC, 0, DTRACEAGG_MIN, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@)" }, { "mod", DT_IDENT_ACTFUNC, 0, DT_ACT_MOD, DT_ATTR_STABCMN, @@ -305,7 +263,6 @@ static const dt_ident_t _dtrace_globals[] = { { "msgsize", DT_IDENT_FUNC, 0, DIF_SUBR_MSGSIZE, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "size_t(mblk_t *)" }, -#if defined(sun) { "mutex_owned", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNED, DT_ATTR_EVOLCMN, DT_VERS_1_0, &dt_idops_func, "int(genunix`kmutex_t *)" }, @@ -318,20 +275,6 @@ static const dt_ident_t _dtrace_globals[] = { { "mutex_type_spin", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_SPIN, DT_ATTR_EVOLCMN, DT_VERS_1_0, &dt_idops_func, "int(genunix`kmutex_t *)" }, -#else -{ "mutex_owned", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNED, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, intmtx_str }, -{ "mutex_owner", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_OWNER, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, threadmtx_str }, -{ "mutex_type_adaptive", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_ADAPTIVE, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, intmtx_str }, -{ "mutex_type_spin", DT_IDENT_FUNC, 0, DIF_SUBR_MUTEX_TYPE_SPIN, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, intmtx_str }, -#endif { "ntohl", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHL, DT_ATTR_EVOLCMN, DT_VERS_1_3, &dt_idops_func, "uint32_t(uint32_t)" }, { "ntohll", DT_IDENT_FUNC, 0, DIF_SUBR_NTOHLL, DT_ATTR_EVOLCMN, DT_VERS_1_3, @@ -350,10 +293,6 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_func, "void(@, ...)" }, { "printf", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTF, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@, ...)" }, -{ "printm", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTM, DT_ATTR_STABCMN, DT_VERS_1_0, - &dt_idops_func, "void(size_t, uintptr_t *)" }, -{ "printt", DT_IDENT_ACTFUNC, 0, DT_ACT_PRINTT, DT_ATTR_STABCMN, DT_VERS_1_0, - &dt_idops_func, "void(size_t, uintptr_t *)" }, { "probefunc", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEFUNC, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, { "probemod", DT_IDENT_SCALAR, 0, DIF_VAR_PROBEMOD, @@ -374,7 +313,6 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_func, "int()" }, { "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1, &dt_idops_func, "int(const char *, const char *, [int])" }, -#if defined(sun) { "rw_iswriter", DT_IDENT_FUNC, 0, DIF_SUBR_RW_ISWRITER, DT_ATTR_EVOLCMN, DT_VERS_1_0, &dt_idops_func, "int(genunix`krwlock_t *)" }, @@ -384,17 +322,6 @@ static const dt_ident_t _dtrace_globals[] = { { "rw_write_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_WRITE_HELD, DT_ATTR_EVOLCMN, DT_VERS_1_0, &dt_idops_func, "int(genunix`krwlock_t *)" }, -#else -{ "rw_iswriter", DT_IDENT_FUNC, 0, DIF_SUBR_RW_ISWRITER, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, rwlock_str }, -{ "rw_read_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_READ_HELD, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, rwlock_str }, -{ "rw_write_held", DT_IDENT_FUNC, 0, DIF_SUBR_RW_WRITE_HELD, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, rwlock_str }, -#endif { "self", DT_IDENT_PTR, 0, 0, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "void" }, { "setopt", DT_IDENT_ACTFUNC, 0, DT_ACT_SETOPT, DT_ATTR_STABCMN, @@ -430,17 +357,6 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_func, "string(const char *, int, [int])" }, { "sum", DT_IDENT_AGGFUNC, 0, DTRACEAGG_SUM, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(@)" }, -#if !defined(sun) -{ "sx_isexclusive", DT_IDENT_FUNC, 0, DIF_SUBR_SX_ISEXCLUSIVE, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, sxlock_str }, -{ "sx_shared_held", DT_IDENT_FUNC, 0, DIF_SUBR_SX_SHARED_HELD, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, sxlock_str }, -{ "sx_exclusive_held", DT_IDENT_FUNC, 0, DIF_SUBR_SX_EXCLUSIVE_HELD, - DT_ATTR_EVOLCMN, DT_VERS_1_0, - &dt_idops_func, sxlock_str }, -#endif { "sym", DT_IDENT_ACTFUNC, 0, DT_ACT_SYM, DT_ATTR_STABCMN, DT_VERS_1_2, &dt_idops_func, "_symaddr(uintptr_t)" }, { "system", DT_IDENT_ACTFUNC, 0, DT_ACT_SYSTEM, DT_ATTR_STABCMN, DT_VERS_1_0, @@ -459,19 +375,14 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_func, "void(@, size_t)" }, { "trunc", DT_IDENT_ACTFUNC, 0, DT_ACT_TRUNC, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_func, "void(...)" }, -{ "typeref", DT_IDENT_FUNC, 0, DIF_SUBR_TYPEREF, DT_ATTR_STABCMN, DT_VERS_1_1, - &dt_idops_func, "uintptr_t *(void *, size_t, string, size_t)" }, -#if defined(sun) { "uaddr", DT_IDENT_ACTFUNC, 0, DT_ACT_UADDR, DT_ATTR_STABCMN, DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, { "ucaller", DT_IDENT_SCALAR, 0, DIF_VAR_UCALLER, DT_ATTR_STABCMN, DT_VERS_1_2, &dt_idops_type, "uint64_t" }, { "ufunc", DT_IDENT_ACTFUNC, 0, DT_ACT_USYM, DT_ATTR_STABCMN, DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, -#endif { "uid", DT_IDENT_SCALAR, 0, DIF_VAR_UID, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "uid_t" }, -#if defined(sun) { "umod", DT_IDENT_ACTFUNC, 0, DT_ACT_UMOD, DT_ATTR_STABCMN, DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, { "uregs", DT_IDENT_ARRAY, 0, DIF_VAR_UREGS, DT_ATTR_STABCMN, DT_VERS_1_0, @@ -483,17 +394,14 @@ static const dt_ident_t _dtrace_globals[] = { &dt_idops_type, "uint32_t" }, { "usym", DT_IDENT_ACTFUNC, 0, DT_ACT_USYM, DT_ATTR_STABCMN, DT_VERS_1_2, &dt_idops_func, "_usymaddr(uintptr_t)" }, -#endif { "vtimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_VTIMESTAMP, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "uint64_t" }, { "walltimestamp", DT_IDENT_SCALAR, 0, DIF_VAR_WALLTIMESTAMP, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "int64_t" }, -#if defined(sun) { "zonename", DT_IDENT_SCALAR, 0, DIF_VAR_ZONENAME, DT_ATTR_STABCMN, DT_VERS_1_0, &dt_idops_type, "string" }, -#endif { NULL, 0, 0, 0, { 0, 0, 0 }, 0, NULL, NULL } }; @@ -733,20 +641,11 @@ const dtrace_pattr_t _dtrace_prvdesc = { { DTRACE_STABILITY_UNSTABLE, DTRACE_STABILITY_UNSTABLE, DTRACE_CLASS_COMMON }, }; -#if defined(sun) const char *_dtrace_defcpp = "/usr/ccs/lib/cpp"; /* default cpp(1) to invoke */ const char *_dtrace_defld = "/usr/ccs/bin/ld"; /* default ld(1) to invoke */ -#else -const char *_dtrace_defcpp = "cpp"; /* default cpp(1) to invoke */ -const char *_dtrace_defld = "ld"; /* default ld(1) to invoke */ -#endif const char *_dtrace_libdir = "/usr/lib/dtrace"; /* default library directory */ -#if defined(sun) const char *_dtrace_provdir = "/dev/dtrace/provider"; /* provider directory */ -#else -const char *_dtrace_provdir = "/dev/dtrace"; /* provider directory */ -#endif int _dtrace_strbuckets = 211; /* default number of hash buckets (prime) */ int _dtrace_intbuckets = 256; /* default number of integer buckets (Pof2) */ @@ -759,9 +658,7 @@ int _dtrace_argmax = 32; /* default maximum number of probe arguments */ int _dtrace_debug = 0; /* debug messages enabled (off) */ const char *const _dtrace_version = DT_VERS_STRING; /* API version string */ -#if defined(sun) int _dtrace_rdvers = RD_VERSION; /* rtld_db feature version */ -#endif typedef struct dt_fdlist { int *df_fds; /* array of provider driver file descriptors */ @@ -769,26 +666,16 @@ typedef struct dt_fdlist { uint_t df_size; /* size of df_fds[] */ } dt_fdlist_t; -#if defined(sun) #pragma init(_dtrace_init) -#else -void _dtrace_init(void) __attribute__ ((constructor)); -#endif void _dtrace_init(void) { _dtrace_debug = getenv("DTRACE_DEBUG") != NULL; -#if defined(sun) for (; _dtrace_rdvers > 0; _dtrace_rdvers--) { if (rd_init(_dtrace_rdvers) == RD_OK) break; } -#endif -#if defined(__i386__) - /* make long doubles 64 bits -sson */ - (void) fpsetprec(FP_PE); -#endif } static dtrace_hdl_t * @@ -806,10 +693,9 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp) { dt_provmod_t *prov; char path[PATH_MAX]; - int fd; -#if defined(sun) struct dirent *dp, *ep; DIR *dirp; + int fd; if ((dirp = opendir(_dtrace_provdir)) == NULL) return; /* failed to open directory; just skip it */ @@ -854,92 +740,6 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *dfp) } (void) closedir(dirp); -#else - char *p; - char *p1; - char *p_providers = NULL; - int error; - size_t len = 0; - - /* - * Loop to allocate/reallocate memory for the string of provider - * names and retry: - */ - while(1) { - /* - * The first time around, get the string length. The next time, - * hopefully we've allocated enough memory. - */ - error = sysctlbyname("debug.dtrace.providers",p_providers,&len,NULL,0); - if (len == 0) - /* No providers? That's strange. Where's dtrace? */ - break; - else if (error == 0 && p_providers == NULL) { - /* - * Allocate the initial memory which should be enough - * unless another provider loads before we have - * time to go back and get the string. - */ - if ((p_providers = malloc(len)) == NULL) - /* How do we report errors here? */ - return; - } else if (error == -1 && errno == ENOMEM) { - /* - * The current buffer isn't large enough, so - * reallocate it. We normally won't need to do this - * because providers aren't being loaded all the time. - */ - if ((p = realloc(p_providers,len)) == NULL) - /* How do we report errors here? */ - return; - p_providers = p; - } else - break; - } - - /* Check if we got a string of provider names: */ - if (error == 0 && len > 0 && p_providers != NULL) { - p = p_providers; - - /* - * Parse the string containing the space separated - * provider names. - */ - while ((p1 = strsep(&p," ")) != NULL) { - if (dfp->df_ents == dfp->df_size) { - uint_t size = dfp->df_size ? dfp->df_size * 2 : 16; - int *fds = realloc(dfp->df_fds, size * sizeof (int)); - - if (fds == NULL) - break; - - dfp->df_fds = fds; - dfp->df_size = size; - } - - (void) snprintf(path, sizeof (path), "/dev/dtrace/%s", p1); - - if ((fd = open(path, O_RDONLY)) == -1) - continue; /* failed to open driver; just skip it */ - - if (((prov = malloc(sizeof (dt_provmod_t))) == NULL) || - (prov->dp_name = malloc(strlen(p1) + 1)) == NULL) { - free(prov); - (void) close(fd); - break; - } - - (void) strcpy(prov->dp_name, p1); - prov->dp_next = *provmod; - *provmod = prov; - - dt_dprintf("opened provider %s\n", p1); - dfp->df_fds[dfp->df_ents++] = fd; - } - } - if (p_providers != NULL) - free(p_providers); -#endif } static void @@ -956,7 +756,6 @@ dt_provmod_destroy(dt_provmod_t **provmod) *provmod = NULL; } -#if defined(sun) static const char * dt_get_sysinfo(int cmd, char *buf, size_t len) { @@ -971,7 +770,6 @@ dt_get_sysinfo(int cmd, char *buf, size_t len) return (buf); } -#endif static dtrace_hdl_t * dt_vopen(int version, int flags, int *errp, @@ -1059,11 +857,7 @@ dt_vopen(int version, int flags, int *errp, dtfd = open("/dev/dtrace/dtrace", O_RDWR); err = errno; /* save errno from opening dtfd */ -#if defined(sun) ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR); -#else - ftfd = open("/dev/dtrace/fasttrap", O_RDWR); -#endif fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */ while (df.df_ents-- != 0) @@ -1112,11 +906,7 @@ alloc: dtp->dt_fterr = fterr; dtp->dt_cdefs_fd = -1; dtp->dt_ddefs_fd = -1; -#if defined(sun) dtp->dt_stdout_fd = -1; -#else - dtp->dt_freopen_fp = NULL; -#endif dtp->dt_modbuckets = _dtrace_strbuckets; dtp->dt_mods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *)); dtp->dt_provbuckets = _dtrace_strbuckets; @@ -1144,7 +934,6 @@ alloc: dtp->dt_cpp_argv[0] = (char *)strbasename(dtp->dt_cpp_path); -#if defined(sun) (void) snprintf(isadef, sizeof (isadef), "-D__SUNW_D_%u", (uint_t)(sizeof (void *) * NBBY)); @@ -1159,7 +948,6 @@ alloc: dt_cpp_add_arg(dtp, isadef) == NULL || dt_cpp_add_arg(dtp, utsdef) == NULL) return (set_open_errno(dtp, errp, EDT_NOMEM)); -#endif if (flags & DTRACE_O_NODEV) bcopy(&_dtrace_conf, &dtp->dt_conf, sizeof (_dtrace_conf)); @@ -1184,7 +972,6 @@ alloc: return (set_open_errno(dtp, errp, EDT_NOMEM)); #endif -#if defined(sun) #ifdef __x86 /* * On x86 systems, __i386 is defined for <sys/isa_defs.h> for 32-bit @@ -1199,17 +986,6 @@ alloc: return (set_open_errno(dtp, errp, EDT_NOMEM)); } #endif -#else -#if defined(__amd64__) || defined(__i386__) - if (dtp->dt_conf.dtc_ctfmodel == CTF_MODEL_LP64) { - if (dt_cpp_add_arg(dtp, "-m64") == NULL) - return (set_open_errno(dtp, errp, EDT_NOMEM)); - } else { - if (dt_cpp_add_arg(dtp, "-m32") == NULL) - return (set_open_errno(dtp, errp, EDT_NOMEM)); - } -#endif -#endif if (dtp->dt_conf.dtc_difversion < DIF_VERSION) return (set_open_errno(dtp, errp, EDT_DIFVERS)); @@ -1219,38 +995,6 @@ alloc: else bcopy(_dtrace_ints_64, dtp->dt_ints, sizeof (_dtrace_ints_64)); - /* - * 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. - */ -#if !defined(sun) - { - char bootfile[MAXPATHLEN]; - char *p; - int i; - size_t len = sizeof(bootfile); - - /* This call shouldn't fail, but use a default just in case. */ - if (sysctlbyname("kern.bootfile", bootfile, &len, NULL, 0) != 0) - strlcpy(bootfile, "kernel", sizeof(bootfile)); - - if ((p = strrchr(bootfile, '/')) != NULL) - p++; - else - p = bootfile; - - /* - * Format the global variables based on the kernel module name. - */ - snprintf(curthread_str, sizeof(curthread_str), "%s`struct thread *",p); - snprintf(intmtx_str, sizeof(intmtx_str), "int(%s`struct mtx *)",p); - snprintf(threadmtx_str, sizeof(threadmtx_str), "struct thread *(%s`struct mtx *)",p); - snprintf(rwlock_str, sizeof(rwlock_str), "int(%s`struct rwlock *)",p); - snprintf(sxlock_str, sizeof(sxlock_str), "int(%s`struct sxlock *)",p); - } -#endif - dtp->dt_macros = dt_idhash_create("macro", NULL, 0, UINT_MAX); dtp->dt_aggs = dt_idhash_create("aggregation", NULL, DTRACE_AGGVARIDNONE + 1, UINT_MAX); @@ -1547,9 +1291,6 @@ dtrace_close(dtrace_hdl_t *dtp) dt_dirpath_t *dirp; int i; - if (dtp->dt_procs != NULL) - dt_proc_hash_destroy(dtp); - while ((pgp = dt_list_next(&dtp->dt_programs)) != NULL) dt_program_destroy(dtp, pgp); @@ -1578,6 +1319,9 @@ dtrace_close(dtrace_hdl_t *dtp) while ((pvp = dt_list_next(&dtp->dt_provlist)) != NULL) dt_provider_destroy(dtp, pvp); + if (dtp->dt_procs != NULL) + dt_proc_hash_destroy(dtp); + if (dtp->dt_fd != -1) (void) close(dtp->dt_fd); if (dtp->dt_ftfd != -1) @@ -1586,13 +1330,8 @@ dtrace_close(dtrace_hdl_t *dtp) (void) close(dtp->dt_cdefs_fd); if (dtp->dt_ddefs_fd != -1) (void) close(dtp->dt_ddefs_fd); -#if defined(sun) if (dtp->dt_stdout_fd != -1) (void) close(dtp->dt_stdout_fd); -#else - if (dtp->dt_freopen_fp != NULL) - (void) fclose(dtp->dt_freopen_fp); -#endif dt_epid_destroy(dtp); dt_aggid_destroy(dtp); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c index fa1407f83c12..5353bfae528d 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_options.c @@ -35,9 +35,7 @@ #include <stdlib.h> #include <unistd.h> #include <limits.h> -#if defined(sun) #include <alloca.h> -#endif #include <errno.h> #include <fcntl.h> @@ -797,12 +795,7 @@ dt_options_load(dtrace_hdl_t *dtp) bzero(&hdr, sizeof (dof_hdr_t)); hdr.dofh_loadsz = sizeof (dof_hdr_t); -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &hdr) == -1) -#else - dof = &hdr; - if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &dof) == -1) -#endif return (dt_set_errno(dtp, errno)); if (hdr.dofh_loadsz < sizeof (dof_hdr_t)) @@ -815,11 +808,7 @@ dt_options_load(dtrace_hdl_t *dtp) for (i = 0; i < DTRACEOPT_MAX; i++) dtp->dt_options[i] = DTRACEOPT_UNSET; -#if defined(sun) if (dt_ioctl(dtp, DTRACEIOC_DOFGET, dof) == -1) -#else - if (dt_ioctl(dtp, DTRACEIOC_DOFGET, &dof) == -1) -#endif return (dt_set_errno(dtp, errno)); for (i = 0; i < dof->dofh_secnum; i++) { @@ -923,7 +912,7 @@ static const dt_option_t _dtrace_ctoptions[] = { { "verbose", dt_opt_cflags, DTRACE_C_DIFV }, { "version", dt_opt_version }, { "zdefs", dt_opt_cflags, DTRACE_C_ZDEFS }, - { NULL, NULL, 0 } + { NULL } }; /* @@ -947,7 +936,7 @@ static const dt_option_t _dtrace_rtoptions[] = { { "statusrate", dt_opt_rate, DTRACEOPT_STATUSRATE }, { "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE }, { "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES }, - { NULL, NULL, 0 } + { NULL } }; /* @@ -964,7 +953,7 @@ static const dt_option_t _dtrace_drtoptions[] = { { "rawbytes", dt_opt_runtime, DTRACEOPT_RAWBYTES }, { "stackindent", dt_opt_runtime, DTRACEOPT_STACKINDENT }, { "switchrate", dt_opt_rate, DTRACEOPT_SWITCHRATE }, - { NULL, NULL, 0 } + { NULL } }; int diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c index b1932866a8c4..9aabc18565db 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c @@ -100,9 +100,7 @@ #include <setjmp.h> #include <strings.h> #include <assert.h> -#if defined(sun) #include <alloca.h> -#endif #include <stdlib.h> #include <stdarg.h> #include <stdio.h> diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c index 5640b4af053d..63463293391c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c @@ -32,9 +32,7 @@ #include <stdio.h> #include <errno.h> #include <ctype.h> -#if defined(sun) #include <alloca.h> -#endif #include <libgen.h> #include <stddef.h> @@ -68,14 +66,10 @@ typedef struct dt_pid_probe { static void dt_pid_objname(char *buf, size_t len, Lmid_t lmid, const char *obj) { -#if defined(sun) if (lmid == LM_ID_BASE) (void) strncpy(buf, obj, len); else (void) snprintf(buf, len, "LM%lx`%s", lmid, obj); -#else - (void) strncpy(buf, obj, len); -#endif } static int @@ -120,11 +114,7 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) int isdash = strcmp("-", func) == 0; pid_t pid; -#if defined(sun) pid = Pstatus(pp->dpp_pr)->pr_pid; -#else - pid = proc_getpid(pp->dpp_pr); -#endif dt_dprintf("creating probe pid%d:%s:%s:%s\n", (int)pid, pp->dpp_obj, func, pp->dpp_name); @@ -144,7 +134,6 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) pp->dpp_obj); if (!isdash && gmatch("return", pp->dpp_name)) { -#ifdef DOODAD if (dt_pid_create_return_probe(pp->dpp_pr, dtp, ftp, symp, pp->dpp_stret) < 0) { return (dt_pid_error(dtp, pcb, dpr, ftp, @@ -152,20 +141,17 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) "for '%s': %s", func, dtrace_errmsg(dtp, dtrace_errno(dtp)))); } -#endif nmatches++; } if (!isdash && gmatch("entry", pp->dpp_name)) { -#ifdef DOODAD if (dt_pid_create_entry_probe(pp->dpp_pr, dtp, ftp, symp) < 0) { return (dt_pid_error(dtp, pcb, dpr, ftp, D_PROC_CREATEFAIL, "failed to create entry probe " "for '%s': %s", func, dtrace_errmsg(dtp, dtrace_errno(dtp)))); } -#endif nmatches++; } @@ -184,10 +170,8 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) (u_longlong_t)off, func)); } -#ifdef DOODAD err = dt_pid_create_offset_probe(pp->dpp_pr, pp->dpp_dtp, ftp, symp, off); -#endif if (err == DT_PROC_ERR) { return (dt_pid_error(dtp, pcb, dpr, ftp, @@ -205,7 +189,6 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) nmatches++; } else if (glob && !isdash) { -#ifdef DOODAD if (dt_pid_create_glob_offset_probes(pp->dpp_pr, pp->dpp_dtp, ftp, symp, pp->dpp_name) < 0) { return (dt_pid_error(dtp, pcb, dpr, ftp, @@ -213,7 +196,6 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) "failed to create offset probes in '%s': %s", func, dtrace_errmsg(dtp, dtrace_errno(dtp)))); } -#endif nmatches++; } @@ -272,17 +254,13 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) if (obj == NULL) return (0); -#if defined(sun) (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid); -#endif - if ((pp->dpp_obj = strrchr(obj, '/')) == NULL) pp->dpp_obj = obj; else pp->dpp_obj++; -#if defined(sun) if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, ".stret1", &sym, NULL) == 0) pp->dpp_stret[0] = sym.st_value; @@ -306,27 +284,6 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) pp->dpp_stret[3] = sym.st_value; else pp->dpp_stret[3] = 0; -#else - if (proc_name2sym(pp->dpp_pr, obj, ".stret1", &sym) == 0) - pp->dpp_stret[0] = sym.st_value; - else - pp->dpp_stret[0] = 0; - - if (proc_name2sym(pp->dpp_pr, obj, ".stret2", &sym) == 0) - pp->dpp_stret[1] = sym.st_value; - else - pp->dpp_stret[1] = 0; - - if (proc_name2sym(pp->dpp_pr, obj, ".stret4", &sym) == 0) - pp->dpp_stret[2] = sym.st_value; - else - pp->dpp_stret[2] = 0; - - if (proc_name2sym(pp->dpp_pr, obj, ".stret8", &sym) == 0) - pp->dpp_stret[3] = sym.st_value; - else - pp->dpp_stret[3] = 0; -#endif dt_dprintf("%s stret %llx %llx %llx %llx\n", obj, (u_longlong_t)pp->dpp_stret[0], (u_longlong_t)pp->dpp_stret[1], @@ -347,24 +304,16 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) * just fail silently in the hopes that some other object will * contain the desired symbol. */ -#if defined(sun) if (Pxlookup_by_name(pp->dpp_pr, pp->dpp_lmid, obj, pp->dpp_func, &sym, NULL) != 0) { -#else - if (proc_name2sym(pp->dpp_pr, obj, pp->dpp_func, &sym) != 0) { -#endif if (strcmp("-", pp->dpp_func) == 0) { sym.st_name = 0; sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_FUNC); sym.st_other = 0; sym.st_value = 0; -#if defined(sun) sym.st_size = Pstatus(pp->dpp_pr)->pr_dmodel == PR_MODEL_ILP32 ? -1U : -1ULL; -#else - sym.st_size = ~((Elf64_Xword) 0); -#endif } else if (!strisglob(pp->dpp_mod)) { return (dt_pid_error(dtp, pcb, dpr, NULL, @@ -387,21 +336,14 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) * We don't instrument PLTs -- they're dynamically rewritten, * and, so, inherently dicey to instrument. */ -#ifdef DOODAD if (Ppltdest(pp->dpp_pr, sym.st_value) != NULL) return (0); -#endif -#if defined(sun) (void) Plookup_by_addr(pp->dpp_pr, sym.st_value, pp->dpp_func, -#else - (void) proc_addr2sym(pp->dpp_pr, sym.st_value, pp->dpp_func, -#endif DTRACE_FUNCNAMELEN, &sym); return (dt_pid_per_sym(pp, &sym, pp->dpp_func)); } else { -#ifdef DOODAD uint_t nmatches = pp->dpp_nmatches; if (Psymbol_iter_by_addr(pp->dpp_pr, obj, PR_SYMTAB, @@ -417,7 +359,6 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) BIND_ANY | TYPE_FUNC, dt_pid_sym_filt, pp) == 1) return (1); } -#endif } return (0); @@ -432,11 +373,7 @@ dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj) if (gmatch(obj, pp->dpp_mod)) return (dt_pid_per_mod(pp, pmp, obj)); -#if defined(sun) (void) Plmid(pp->dpp_pr, pmp->pr_vaddr, &pp->dpp_lmid); -#else - pp->dpp_lmid = 0; -#endif if ((pp->dpp_obj = strrchr(obj, '/')) == NULL) pp->dpp_obj = obj; @@ -454,14 +391,11 @@ dt_pid_mod_filt(void *arg, const prmap_t *pmp, const char *obj) static const prmap_t * dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P) { -#ifdef DOODAD char m[MAXPATHLEN]; Lmid_t lmid = PR_LMID_EVERY; const char *obj; -#endif const prmap_t *pmp; -#ifdef DOODAD /* * Pick apart the link map from the library name. */ @@ -493,11 +427,7 @@ dt_pid_fix_mod(dtrace_probedesc_t *pdp, struct ps_prochandle *P) obj++; (void) Plmid(P, pmp->pr_vaddr, &lmid); - dt_pid_objname(pdp->dtpd_mod, sizeof (pdp->dtpd_mod), lmid, obj); -#else -pmp = NULL; -#endif return (pmp); } @@ -515,7 +445,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, pp.dpp_pr = dpr->dpr_proc; pp.dpp_pcb = pcb; -#ifdef DOODAD /* * We can only trace dynamically-linked executables (since we've * hidden some magic in ld.so.1 as well as libc.so.1). @@ -525,7 +454,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, "process %s is not a dynamically-linked executable", &pdp->dtpd_provider[3])); } -#endif pp.dpp_mod = pdp->dtpd_mod[0] != '\0' ? pdp->dtpd_mod : "*"; pp.dpp_func = pdp->dtpd_func[0] != '\0' ? pdp->dtpd_func : "*"; @@ -539,13 +467,8 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, pp.dpp_mod = pdp->dtpd_mod; (void) strcpy(pdp->dtpd_mod, "a.out"); } else if (strisglob(pp.dpp_mod) || -#if defined(sun) (aout = Pname_to_map(pp.dpp_pr, "a.out")) == NULL || (pmp = Pname_to_map(pp.dpp_pr, pp.dpp_mod)) == NULL || -#else - (aout = proc_name2map(pp.dpp_pr, "a.out")) == NULL || - (pmp = proc_name2map(pp.dpp_pr, pp.dpp_mod)) == NULL || -#endif aout->pr_vaddr != pmp->pr_vaddr) { return (dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_LIB, "only the a.out module is valid with the " @@ -564,7 +487,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, * to iterate over each module and compare its name against the * pattern. An empty module name is treated as '*'. */ -#ifdef DOODAD if (strisglob(pp.dpp_mod)) { ret = Pobject_iter(pp.dpp_pr, dt_pid_mod_filt, &pp); } else { @@ -585,7 +507,6 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, ret = dt_pid_per_mod(&pp, pmp, obj); } } -#endif return (ret); } @@ -595,9 +516,7 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) { struct ps_prochandle *P = data; GElf_Sym sym; -#if defined(sun) prsyminfo_t sip; -#endif dof_helper_t dh; GElf_Half e_type; const char *mname; @@ -611,12 +530,8 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) * run the code to instantiate these providers. */ for (i = 0; i < 2; i++) { -#if defined(sun) if (Pxlookup_by_name(P, PR_LMID_EVERY, oname, syms[i], &sym, &sip) != 0) { -#else - if (proc_name2sym(P, oname, syms[i], &sym) != 0) { -#endif continue; } @@ -627,25 +542,18 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) dt_dprintf("lookup of %s succeeded for %s\n", syms[i], mname); -#ifdef DOODAD if (Pread(P, &e_type, sizeof (e_type), pmp->pr_vaddr + offsetof(Elf64_Ehdr, e_type)) != sizeof (e_type)) { dt_dprintf("read of ELF header failed"); continue; } -#endif dh.dofhp_dof = sym.st_value; dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr; dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod), -#if defined(sun) sip.prs_lmid, mname); -#else - 0, mname); -#endif -#ifdef DOODAD if (fd == -1 && (fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) { dt_dprintf("pr_open of helper device failed: %s\n", @@ -655,13 +563,10 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) if (pr_ioctl(P, fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0) dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod); -#endif } -#ifdef DOODAD if (fd != -1) (void) pr_close(P, fd); -#endif return (0); } @@ -675,19 +580,13 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, assert(DT_MUTEX_HELD(&dpr->dpr_lock)); -#ifdef DOODAD (void) Pupdate_maps(P); if (Pobject_iter(P, dt_pid_usdt_mapping, P) != 0) { ret = -1; (void) dt_pid_error(dtp, pcb, dpr, NULL, D_PROC_USDT, "failed to instantiate probes for pid %d: %s", -#if defined(sun) (int)Pstatus(P)->pr_pid, strerror(errno)); -#else - (int)proc_getpid(P), strerror(errno)); -#endif } -#endif /* * Put the module name in its canonical form. @@ -768,13 +667,7 @@ dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb) assert(dpr != NULL); (void) pthread_mutex_lock(&dpr->dpr_lock); - if ((err = dt_pid_create_pid_probes(pdp, dtp, pcb, dpr)) == 0) { - /* - * Alert other retained enablings which may match - * against the newly created probes. - */ - (void) dt_ioctl(dtp, DTRACEIOC_ENABLE, NULL); - } + err = dt_pid_create_pid_probes(pdp, dtp, pcb, dpr); (void) pthread_mutex_unlock(&dpr->dpr_lock); dt_proc_release(dtp, P); @@ -809,7 +702,6 @@ dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb) int dt_pid_create_probes_module(dtrace_hdl_t *dtp, dt_proc_t *dpr) { - dtrace_enable_io_t args; dtrace_prog_t *pgp; dt_stmt_t *stp; dtrace_probedesc_t *pdp, pd; @@ -854,9 +746,7 @@ dt_pid_create_probes_module(dtrace_hdl_t *dtp, dt_proc_t *dpr) * Give DTrace a shot to the ribs to get it to check * out the newly created probes. */ - args.dof = NULL; - args.n_matched = 0; - (void) dt_ioctl(dtp, DTRACEIOC_ENABLE, &args); + (void) dt_ioctl(dtp, DTRACEIOC_ENABLE, NULL); } return (ret); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c index a9328ab067b9..00b826978f37 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pragma.c @@ -18,9 +18,8 @@ * * CDDL HEADER END */ - /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -28,9 +27,7 @@ #include <assert.h> #include <strings.h> -#if defined(sun) #include <alloca.h> -#endif #include <stdlib.h> #include <stdio.h> @@ -213,7 +210,6 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp) dt_node_t *nnp = cnp ? cnp->dn_list : NULL; int found; dt_lib_depend_t *dld; - char lib[MAXPATHLEN]; if (cnp == NULL || nnp == NULL || cnp->dn_kind != DT_NODE_IDENT || nnp->dn_kind != DT_NODE_IDENT) { @@ -227,53 +223,29 @@ dt_pragma_depends(const char *prname, dt_node_t *cnp) dt_module_t *mp = dt_module_lookup_by_name(dtp, nnp->dn_string); found = mp != NULL && dt_module_getctf(dtp, mp) != NULL; } else if (strcmp(cnp->dn_string, "library") == 0) { + + /* + * We have the file we are working on in dtp->dt_filetag + * so find that node and add the dependency in. + */ if (yypcb->pcb_cflags & DTRACE_C_CTL) { - assert(dtp->dt_filetag != NULL); + char lib[MAXPATHLEN]; - /* - * We have the file we are working on in dtp->dt_filetag - * so find that node and add the dependency in. - */ dld = dt_lib_depend_lookup(&dtp->dt_lib_dep, dtp->dt_filetag); assert(dld != NULL); - (void) snprintf(lib, sizeof (lib), "%s%s", + (void) snprintf(lib, MAXPATHLEN, "%s%s", dld->dtld_libpath, nnp->dn_string); if ((dt_lib_depend_add(dtp, &dld->dtld_dependencies, lib)) != 0) { xyerror(D_PRAGMA_DEPEND, - "failed to add dependency %s:%s\n", lib, + "failed to add dependency %s:%s\n", + lib, dtrace_errmsg(dtp, dtrace_errno(dtp))); } - } else { - /* - * By this point we have already performed a topological - * sort of the dependencies; we process this directive - * as satisfied as long as the dependency was properly - * loaded. - */ - if (dtp->dt_filetag == NULL) - xyerror(D_PRAGMA_DEPEND, "main program may " - "not explicitly depend on a library"); - - dld = dt_lib_depend_lookup(&dtp->dt_lib_dep, - dtp->dt_filetag); - assert(dld != NULL); - - (void) snprintf(lib, sizeof (lib), "%s%s", - dld->dtld_libpath, nnp->dn_string); - dld = dt_lib_depend_lookup(&dtp->dt_lib_dep_sorted, - lib); - assert(dld != NULL); - - if (!dld->dtld_loaded) - xyerror(D_PRAGMA_DEPEND, "program requires " - "library \"%s\" which failed to load", - lib); } - - found = B_TRUE; + found = 1; } else { xyerror(D_PRAGMA_INVAL, "invalid class %s " "specified by #pragma %s\n", cnp->dn_string, prname); diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c index 209b10a13ba8..953511b1d029 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c @@ -26,17 +26,10 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#if defined(sun) #include <sys/sysmacros.h> -#else -#define ABS(a) ((a) < 0 ? -(a) : (a)) -#endif -#include <string.h> #include <strings.h> #include <stdlib.h> -#if defined(sun) #include <alloca.h> -#endif #include <assert.h> #include <ctype.h> #include <errno.h> @@ -306,11 +299,9 @@ pfprint_fp(dtrace_hdl_t *dtp, FILE *fp, const char *format, case sizeof (double): return (dt_printf(dtp, fp, format, *((double *)addr) / n)); -#if !defined(__arm__) && !defined(__powerpc__) case sizeof (long double): return (dt_printf(dtp, fp, format, *((long double *)addr) / ldn)); -#endif default: return (dt_set_errno(dtp, EDT_DMISMATCH)); } @@ -463,11 +454,7 @@ pfprint_time(dtrace_hdl_t *dtp, FILE *fp, const char *format, * Below, we turn this into the canonical adb/mdb /[yY] format, * "1973 Dec 3 17:20:00". */ -#if defined(sun) (void) ctime_r(&sec, src, sizeof (src)); -#else - (void) ctime_r(&sec, src); -#endif /* * Place the 4-digit year at the head of the string... @@ -1566,7 +1553,6 @@ dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata, if (rval == -1 || fp == NULL) return (rval); -#if defined(sun) if (pfd->pfd_preflen != 0 && strcmp(pfd->pfd_prefix, DT_FREOPEN_RESTORE) == 0) { /* @@ -1611,8 +1597,7 @@ dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata, * fails, we can fail the operation without destroying stdout. */ if ((nfp = fopen(filename, "aF")) == NULL) { - char *msg = strerror(errno); - char *faultstr; + char *msg = strerror(errno), *faultstr; int len = 80; len += strlen(msg) + strlen(filename); @@ -1648,82 +1633,6 @@ dtrace_freopen(dtrace_hdl_t *dtp, FILE *fp, void *fmtdata, } (void) fclose(nfp); -#else - /* - * The 'standard output' (which is not necessarily stdout) - * treatment on FreeBSD is implemented differently than on - * Solaris because FreeBSD's freopen() will attempt to re-use - * the current file descriptor, causing the previous file to - * be closed and thereby preventing it from be re-activated - * later. - * - * For FreeBSD we use the concept of setting an output file - * pointer in the DTrace handle if a dtrace_freopen() has - * enabled another output file and we leave the caller's - * file pointer untouched. If it was actually stdout, then - * stdout remains open. If it was another file, then that - * file remains open. While a dtrace_freopen() has activated - * another file, we keep a pointer to that which we use in - * the output functions by preference and only use the caller's - * file pointer if no dtrace_freopen() call has been made. - * - * The check to see if we're re-activating the caller's - * output file is much the same as on Solaris. - */ - if (pfd->pfd_preflen != 0 && - strcmp(pfd->pfd_prefix, DT_FREOPEN_RESTORE) == 0) { - /* - * The only way to have the format string set to the value - * DT_FREOPEN_RESTORE is via the empty freopen() string -- - * denoting that we should restore the old stdout. - */ - assert(strcmp(dtp->dt_sprintf_buf, DT_FREOPEN_RESTORE) == 0); - - if (dtp->dt_freopen_fp == NULL) { - /* - * We could complain here by generating an error, - * but it seems like overkill: it seems that calling - * freopen() to restore stdout when freopen() has - * never before been called should just be a no-op, - * so we just return in this case. - */ - return (rval); - } - - /* - * At this point, to re-active the original output file, - * on FreeBSD we only code the current file that this - * function opened previously. - */ - (void) fclose(dtp->dt_freopen_fp); - dtp->dt_freopen_fp = NULL; - - return (rval); - } - - if ((nfp = fopen(dtp->dt_sprintf_buf, "a")) == NULL) { - char *msg = strerror(errno); - char *faultstr; - int len = 80; - - len += strlen(msg) + strlen(dtp->dt_sprintf_buf); - faultstr = alloca(len); - - (void) snprintf(faultstr, len, "couldn't freopen() \"%s\": %s", - dtp->dt_sprintf_buf, strerror(errno)); - - if ((errval = dt_handle_liberr(dtp, data, faultstr)) == 0) - return (rval); - - return (errval); - } - - if (dtp->dt_freopen_fp != NULL) - (void) fclose(dtp->dt_freopen_fp); - - /* Remember that the output has been redirected to the new file. */ - dtp->dt_freopen_fp = nfp; -#endif return (rval); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c index b8662bf67f34..419f13b8474c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c @@ -79,9 +79,7 @@ */ #include <sys/wait.h> -#if defined(sun) #include <sys/lwp.h> -#endif #include <strings.h> #include <signal.h> #include <assert.h> @@ -95,7 +93,6 @@ #define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork1 || \ w == SYS_forkall || w == SYS_forksys) -#ifdef DOODAD static dt_bkpt_t * dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) { @@ -117,36 +114,27 @@ dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data) return (dbp); } -#endif static void dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts) { -#if defined(sun) int state = Pstate(dpr->dpr_proc); -#else - int state = proc_state(dpr->dpr_proc); -#endif dt_bkpt_t *dbp, *nbp; assert(DT_MUTEX_HELD(&dpr->dpr_lock)); for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = nbp) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD if (delbkpts && dbp->dbp_active && state != PS_LOST && state != PS_UNDEAD) { (void) Pdelbkpt(dpr->dpr_proc, dbp->dbp_addr, dbp->dbp_instr); } -#endif nbp = dt_list_next(dbp); dt_list_delete(&dpr->dpr_bps, dbp); dt_free(dpr->dpr_hdl, dbp); } } -#ifdef DOODAD static void dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr) { @@ -173,7 +161,6 @@ dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr) dbp->dbp_func(dtp, dpr, dbp->dbp_data); (void) Pxecbkpt(dpr->dpr_proc, dbp->dbp_instr); } -#endif static void dt_proc_bpenable(dt_proc_t *dpr) @@ -184,12 +171,9 @@ dt_proc_bpenable(dt_proc_t *dpr) for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD if (!dbp->dbp_active && Psetbkpt(dpr->dpr_proc, dbp->dbp_addr, &dbp->dbp_instr) == 0) dbp->dbp_active = B_TRUE; -#endif } dt_dprintf("breakpoints enabled\n"); @@ -204,12 +188,9 @@ dt_proc_bpdisable(dt_proc_t *dpr) for (dbp = dt_list_next(&dpr->dpr_bps); dbp != NULL; dbp = dt_list_next(dbp)) { -printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); -#ifdef DOODAD if (dbp->dbp_active && Pdelbkpt(dpr->dpr_proc, dbp->dbp_addr, dbp->dbp_instr) == 0) dbp->dbp_active = B_FALSE; -#endif } dt_dprintf("breakpoints disabled\n"); @@ -282,7 +263,6 @@ dt_proc_bpmain(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *fname) dt_proc_stop(dpr, DT_PROC_STOP_MAIN); } -#if defined(sun) static void dt_proc_rdevent(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *evname) { @@ -459,7 +439,6 @@ dt_proc_waitrun(dt_proc_t *dpr) (void) pthread_mutex_lock(&dpr->dpr_lock); } -#endif typedef struct dt_proc_control_data { dtrace_hdl_t *dpcd_hdl; /* DTrace handle */ @@ -486,13 +465,11 @@ dt_proc_control(void *arg) dt_proc_t *dpr = datap->dpcd_proc; dt_proc_hash_t *dph = dpr->dpr_hdl->dt_procs; struct ps_prochandle *P = dpr->dpr_proc; - int pid = dpr->dpr_pid; -#if defined(sun) int pfd = Pctlfd(P); + int pid = dpr->dpr_pid; const long wstop = PCWSTOP; -#endif int notify = B_FALSE; /* @@ -510,7 +487,6 @@ dt_proc_control(void *arg) */ (void) pthread_mutex_lock(&dpr->dpr_lock); -#if defined(sun) (void) Punsetflags(P, PR_ASYNC); /* require synchronous mode */ (void) Psetflags(P, PR_BPTADJ); /* always adjust eip on x86 */ (void) Punsetflags(P, PR_FORK); /* do not inherit on fork */ @@ -556,20 +532,6 @@ dt_proc_control(void *arg) dt_dprintf("pid %d: failed to set running: %s\n", (int)dpr->dpr_pid, strerror(errno)); } -#else - /* - * If PR_KLC is set, we created the process; otherwise we grabbed it. - * Check for an appropriate stop request and wait for dt_proc_continue. - */ - if (proc_getflags(P) & PR_KLC) - dt_proc_stop(dpr, DT_PROC_STOP_CREATE); - else - dt_proc_stop(dpr, DT_PROC_STOP_GRAB); - - if (proc_continue(P) != 0) - dt_dprintf("pid %d: failed to set running: %s\n", - (int)dpr->dpr_pid, strerror(errno)); -#endif (void) pthread_mutex_unlock(&dpr->dpr_lock); @@ -583,33 +545,20 @@ dt_proc_control(void *arg) * Pwait() (which will return immediately) and do our processing. */ while (!dpr->dpr_quit) { -#if defined(sun) const lwpstatus_t *psp; if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR) continue; /* check dpr_quit and continue waiting */ -#else - /* Wait for the process to report status. */ - proc_wait(P); -#endif (void) pthread_mutex_lock(&dpr->dpr_lock); - -#if defined(sun) pwait_locked: if (Pstopstatus(P, PCNULL, 0) == -1 && errno == EINTR) { (void) pthread_mutex_unlock(&dpr->dpr_lock); continue; /* check dpr_quit and continue waiting */ } -#endif -#if defined(sun) switch (Pstate(P)) { -#else - switch (proc_state(P)) { -#endif case PS_STOP: -#ifdef DOODAD psp = &Pstatus(P)->pr_lwp; dt_dprintf("pid %d: proc stopped showing %d/%d\n", @@ -652,14 +601,11 @@ pwait_locked: else if (psp->pr_why == PR_SYSEXIT && IS_SYS_EXEC(psp->pr_what)) dt_proc_attach(dpr, B_TRUE); -#endif break; case PS_LOST: -#if defined(sun) if (Preopen(P) == 0) goto pwait_locked; -#endif dt_dprintf("pid %d: proc lost: %s\n", pid, strerror(errno)); @@ -675,12 +621,10 @@ pwait_locked: break; } -#if defined(sun) if (Pstate(P) != PS_UNDEAD && Psetrun(P, 0, 0) == -1) { dt_dprintf("pid %d: failed to set running: %s\n", (int)dpr->dpr_pid, strerror(errno)); } -#endif (void) pthread_mutex_unlock(&dpr->dpr_lock); } @@ -720,11 +664,7 @@ dt_proc_error(dtrace_hdl_t *dtp, dt_proc_t *dpr, const char *format, ...) va_end(ap); if (dpr->dpr_proc != NULL) -#if defined(sun) Prelease(dpr->dpr_proc, 0); -#else - proc_detach(dpr->dpr_proc); -#endif dt_free(dtp, dpr); (void) dt_set_errno(dtp, EDT_COMPILER); @@ -735,11 +675,7 @@ dt_proc_t * dt_proc_lookup(dtrace_hdl_t *dtp, struct ps_prochandle *P, int remove) { dt_proc_hash_t *dph = dtp->dt_procs; -#if defined(sun) pid_t pid = Pstatus(P)->pr_pid; -#else - pid_t pid = proc_getpid(P); -#endif dt_proc_t *dpr, **dpp = &dph->dph_hash[pid & (dph->dph_hashlen - 1)]; for (dpr = *dpp; dpr != NULL; dpr = dpr->dpr_hash) { @@ -773,17 +709,9 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) * an external debugger and we were waiting in dt_proc_waitrun(). * Leave the process in this condition using PRELEASE_HANG. */ -#if defined(sun) if (!(Pstatus(dpr->dpr_proc)->pr_flags & (PR_KLC | PR_RLC))) { -#else - if (!(proc_getflags(dpr->dpr_proc) & (PR_KLC | PR_RLC))) { -#endif dt_dprintf("abandoning pid %d\n", (int)dpr->dpr_pid); -#if defined(sun) rflag = PRELEASE_HANG; -#else - rflag = 0 /* XXX */; -#endif } else { dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid); rflag = 0; /* apply kill or run-on-last-close */ @@ -806,11 +734,7 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) */ (void) pthread_mutex_lock(&dpr->dpr_lock); dpr->dpr_quit = B_TRUE; -#if defined(sun) (void) _lwp_kill(dpr->dpr_tid, SIGCANCEL); -#else - (void) pthread_kill(dpr->dpr_tid, SIGUSR1); -#endif /* * If the process is currently idling in dt_proc_stop(), re- @@ -858,11 +782,7 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P) } dt_list_delete(&dph->dph_lrulist, dpr); -#if defined(sun) Prelease(dpr->dpr_proc, rflag); -#else - proc_detach(dpr->dpr_proc); -#endif dt_free(dtp, dpr); } @@ -882,11 +802,7 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop) (void) sigfillset(&nset); (void) sigdelset(&nset, SIGABRT); /* unblocked for assert() */ -#if defined(sun) (void) sigdelset(&nset, SIGCANCEL); /* see dt_proc_destroy() */ -#else - (void) sigdelset(&nset, SIGUSR1); /* see dt_proc_destroy() */ -#endif data.dpcd_hdl = dtp; data.dpcd_proc = dpr; @@ -914,21 +830,14 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop) * small amount of useful information to help figure it out. */ if (dpr->dpr_done) { -#if defined(sun) const psinfo_t *prp = Ppsinfo(dpr->dpr_proc); int stat = prp ? prp->pr_wstat : 0; -#endif int pid = dpr->dpr_pid; -#if defined(sun) if (Pstate(dpr->dpr_proc) == PS_LOST) { -#else - if (proc_state(dpr->dpr_proc) == PS_LOST) { -#endif (void) dt_proc_error(dpr->dpr_hdl, dpr, "failed to control pid %d: process exec'd " "set-id or unobservable program\n", pid); -#if defined(sun) } else if (WIFSIGNALED(stat)) { (void) dt_proc_error(dpr->dpr_hdl, dpr, "failed to control pid %d: process died " @@ -937,7 +846,6 @@ dt_proc_create_thread(dtrace_hdl_t *dtp, dt_proc_t *dpr, uint_t stop) (void) dt_proc_error(dpr->dpr_hdl, dpr, "failed to control pid %d: process exited " "with status %d\n", pid, WEXITSTATUS(stat)); -#endif } err = ESRCH; /* cause grab() or create() to fail */ @@ -967,7 +875,6 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv) (void) pthread_mutex_init(&dpr->dpr_lock, NULL); (void) pthread_cond_init(&dpr->dpr_cv, NULL); -#if defined(sun) if ((dpr->dpr_proc = Pcreate(file, argv, &err, NULL, 0)) == NULL) { return (dt_proc_error(dtp, dpr, "failed to execute %s: %s\n", file, Pcreate_error(err))); @@ -978,21 +885,8 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv) (void) Punsetflags(dpr->dpr_proc, PR_RLC); (void) Psetflags(dpr->dpr_proc, PR_KLC); -#else - (void) proc_clearflags(dpr->dpr_proc, PR_RLC); - (void) proc_setflags(dpr->dpr_proc, PR_KLC); - if ((err = proc_create(file, argv, &dpr->dpr_proc)) != 0) - return (dt_proc_error(dtp, dpr, - "failed to execute %s: %s\n", file, strerror(err))); - dpr->dpr_hdl = dtp; - dpr->dpr_pid = proc_getpid(dpr->dpr_proc); -#endif -#if defined(sun) if (dt_proc_create_thread(dtp, dpr, dtp->dt_prcmode) != 0) -#else - if (dt_proc_create_thread(dtp, dpr, DT_PROC_STOP_IDLE) != 0) -#endif return (NULL); /* dt_proc_error() has been called for us */ dpr->dpr_hash = dph->dph_hash[dpr->dpr_pid & (dph->dph_hashlen - 1)]; @@ -1048,27 +942,16 @@ dt_proc_grab(dtrace_hdl_t *dtp, pid_t pid, int flags, int nomonitor) (void) pthread_mutex_init(&dpr->dpr_lock, NULL); (void) pthread_cond_init(&dpr->dpr_cv, NULL); -#if defined(sun) if ((dpr->dpr_proc = Pgrab(pid, flags, &err)) == NULL) { return (dt_proc_error(dtp, dpr, "failed to grab pid %d: %s\n", (int)pid, Pgrab_error(err))); } -#else - if ((err = proc_attach(pid, flags, &dpr->dpr_proc)) != 0) - return (dt_proc_error(dtp, dpr, - "failed to grab pid %d: %s\n", (int) pid, strerror(err))); -#endif dpr->dpr_hdl = dtp; dpr->dpr_pid = pid; -#if defined(sun) (void) Punsetflags(dpr->dpr_proc, PR_KLC); (void) Psetflags(dpr->dpr_proc, PR_RLC); -#else - (void) proc_clearflags(dpr->dpr_proc, PR_KLC); - (void) proc_setflags(dpr->dpr_proc, PR_RLC); -#endif /* * If we are attempting to grab the process without a monitor @@ -1189,11 +1072,7 @@ dtrace_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv) struct ps_prochandle *P = dt_proc_create(dtp, file, argv); if (P != NULL && idp != NULL && idp->di_id == 0) -#if defined(sun) idp->di_id = Pstatus(P)->pr_pid; /* $target = created pid */ -#else - idp->di_id = proc_getpid(P); /* $target = created pid */ -#endif return (P); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h index a6c43826ac7c..a3236694b2b7 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h @@ -44,9 +44,7 @@ typedef struct dt_proc { dtrace_hdl_t *dpr_hdl; /* back pointer to libdtrace handle */ struct ps_prochandle *dpr_proc; /* proc handle for libproc calls */ char dpr_errmsg[BUFSIZ]; /* error message */ -#if defined(sun) rd_agent_t *dpr_rtld; /* rtld handle for librtld_db calls */ -#endif pthread_mutex_t dpr_lock; /* lock for manipulating dpr_hdl */ pthread_cond_t dpr_cv; /* cond for dpr_stop/quit/done */ pid_t dpr_pid; /* pid of process */ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c index 17856686bd3a..8497dab01e05 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_program.c @@ -32,9 +32,7 @@ #include <errno.h> #include <assert.h> #include <ctype.h> -#if defined(sun) #include <alloca.h> -#endif #include <dt_impl.h> #include <dt_program.h> @@ -153,7 +151,6 @@ int dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, dtrace_proginfo_t *pip) { - dtrace_enable_io_t args; void *dof; int n, err; @@ -162,9 +159,7 @@ dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, if ((dof = dtrace_dof_create(dtp, pgp, DTRACE_D_STRIP)) == NULL) return (-1); - args.dof = dof; - args.n_matched = 0; - n = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args); + n = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof); dtrace_dof_destroy(dtp, dof); if (n == -1) { @@ -186,7 +181,7 @@ dtrace_program_exec(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, } if (pip != NULL) - pip->dpi_matches += args.n_matched; + pip->dpi_matches += n; return (0); } diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c index 188ce0e05796..86e1204e630c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c @@ -27,17 +27,13 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include <sys/types.h> -#if defined(sun) #include <sys/sysmacros.h> -#endif #include <assert.h> #include <limits.h> #include <strings.h> #include <stdlib.h> -#if defined(sun) #include <alloca.h> -#endif #include <unistd.h> #include <errno.h> diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c index 12f186ae51fd..b2163e69e9a6 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_subr.c @@ -26,9 +26,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#if defined(sun) #include <sys/sysmacros.h> -#endif #include <strings.h> #include <unistd.h> @@ -38,11 +36,7 @@ #include <stdio.h> #include <errno.h> #include <ctype.h> -#if defined(sun) #include <alloca.h> -#else -#include <sys/sysctl.h> -#endif #include <assert.h> #include <libgen.h> #include <limits.h> @@ -473,19 +467,10 @@ dt_dprintf(const char *format, ...) } int -#if defined(sun) dt_ioctl(dtrace_hdl_t *dtp, int val, void *arg) -#else -dt_ioctl(dtrace_hdl_t *dtp, u_long val, void *arg) -#endif { const dtrace_vector_t *v = dtp->dt_vector; -#if !defined(sun) - /* Avoid sign extension. */ - val &= 0xffffffff; -#endif - if (v != NULL) return (v->dtv_ioctl(dtp->dt_varg, val, arg)); @@ -501,18 +486,8 @@ dt_status(dtrace_hdl_t *dtp, processorid_t cpu) { const dtrace_vector_t *v = dtp->dt_vector; - if (v == NULL) { -#if defined(sun) + if (v == NULL) return (p_online(cpu, P_STATUS)); -#else - int maxid = 0; - size_t len = sizeof(maxid); - if (sysctlbyname("kern.smp.maxid", &maxid, &len, NULL, 0) != 0) - return (cpu == 0 ? 1 : -1); - else - return (cpu <= maxid ? 1 : -1); -#endif - } return (v->dtv_status(dtp->dt_varg, cpu)); } @@ -579,16 +554,6 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...) va_list ap; int n; -#if !defined(sun) - /* - * On FreeBSD, check if output is currently being re-directed - * to another file. If so, output to that file instead of the - * one the caller has specified. - */ - if (dtp->dt_freopen_fp != NULL) - fp = dtp->dt_freopen_fp; -#endif - va_start(ap, format); if (dtp->dt_sprintf_buflen != 0) { @@ -679,7 +644,6 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...) } n = vfprintf(fp, format, ap); - fflush(fp); va_end(ap); if (n < 0) { @@ -729,11 +693,6 @@ dt_zalloc(dtrace_hdl_t *dtp, size_t size) { void *data; - if (size > 16 * 1024 * 1024) { - (void) dt_set_errno(dtp, EDT_NOMEM); - return (NULL); - } - if ((data = malloc(size)) == NULL) (void) dt_set_errno(dtp, EDT_NOMEM); else @@ -747,11 +706,6 @@ dt_alloc(dtrace_hdl_t *dtp, size_t size) { void *data; - if (size > 16 * 1024 * 1024) { - (void) dt_set_errno(dtp, EDT_NOMEM); - return (NULL); - } - if ((data = malloc(size)) == NULL) (void) dt_set_errno(dtp, EDT_NOMEM); @@ -849,7 +803,6 @@ dt_popcb(const ulong_t *bp, ulong_t n) return (popc + dt_popc(bp[maxw] & ((1UL << maxb) - 1))); } -#if defined(sun) struct _rwlock; struct _lwp_mutex; @@ -866,17 +819,12 @@ dt_rw_write_held(pthread_rwlock_t *lock) extern int _rw_write_held(struct _rwlock *); return (_rw_write_held((struct _rwlock *)lock)); } -#endif int dt_mutex_held(pthread_mutex_t *lock) { -#if defined(sun) extern int _mutex_held(struct _lwp_mutex *); return (_mutex_held((struct _lwp_mutex *)lock)); -#else - return (1); -#endif } static int @@ -963,13 +911,8 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, dt_proc_lock(dtp, P); -#if defined(sun) if (Plookup_by_addr(P, addr, name, sizeof (name), &sym) == 0) { (void) Pobjname(P, addr, objname, sizeof (objname)); -#else - if (proc_addr2sym(P, addr, name, sizeof (name), &sym) == 0) { - (void) proc_objname(P, addr, objname, sizeof (objname)); -#endif obj = dt_basename(objname); @@ -979,11 +922,7 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, } else { (void) snprintf(c, sizeof (c), "%s`%s", obj, name); } -#if defined(sun) - } else if (Pobjname(P, addr, objname, sizeof (objname)) != 0) { -#else - } else if (proc_objname(P, addr, objname, sizeof (objname)) != 0) { -#endif + } else if (Pobjname(P, addr, objname, sizeof (objname)) != NULL) { (void) snprintf(c, sizeof (c), "%s`0x%llx", dt_basename(objname), addr); } else { diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c index 68e64bb1970c..97a7f62d697c 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_work.c @@ -82,7 +82,6 @@ dtrace_sleep(dtrace_hdl_t *dtp) return; /* sleep duration has already past */ } -#if defined(sun) tv.tv_sec = (earliest - now) / NANOSEC; tv.tv_nsec = (earliest - now) % NANOSEC; @@ -92,23 +91,6 @@ dtrace_sleep(dtrace_hdl_t *dtp) * awaken, iterate over any pending notifications and process them. */ (void) pthread_cond_reltimedwait_np(&dph->dph_cv, &dph->dph_lock, &tv); -#else - earliest -= now; - clock_gettime(CLOCK_REALTIME,&tv); - tv.tv_sec += earliest / NANOSEC; - tv.tv_nsec += earliest % NANOSEC; - while (tv.tv_nsec > NANOSEC) { - tv.tv_sec += 1; - tv.tv_nsec -= NANOSEC; - } - - /* - * Wait for either 'tv' nanoseconds to pass or to receive notification - * that a process is in an interesting state. Regardless of why we - * awaken, iterate over any pending notifications and process them. - */ - (void) pthread_cond_timedwait(&dph->dph_cv, &dph->dph_lock, &tv); -#endif while ((dprn = dph->dph_notify) != NULL) { if (dtp->dt_prochdlr != NULL) { @@ -182,7 +164,6 @@ dtrace_status(dtrace_hdl_t *dtp) int dtrace_go(dtrace_hdl_t *dtp) { - dtrace_enable_io_t args; void *dof; int err; @@ -204,9 +185,7 @@ dtrace_go(dtrace_hdl_t *dtp) if ((dof = dtrace_getopt_dof(dtp)) == NULL) return (-1); /* dt_errno has been set for us */ - args.dof = dof; - args.n_matched = 0; - err = dt_ioctl(dtp, DTRACEIOC_ENABLE, &args); + err = dt_ioctl(dtp, DTRACEIOC_ENABLE, dof); dtrace_dof_destroy(dtp, dof); if (err == -1 && (errno != ENOTTY || dtp->dt_vector == NULL)) diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h index 895f776f7deb..1c041207c0ae 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h @@ -148,7 +148,7 @@ typedef struct dtrace_stmtdesc { dtrace_actdesc_t *dtsd_action_last; /* last action in action list */ void *dtsd_aggdata; /* aggregation data */ void *dtsd_fmtdata; /* type-specific output data */ - void (*dtsd_callback)(void); /* callback function for EPID */ + void (*dtsd_callback)(); /* callback function for EPID */ void *dtsd_data; /* callback data pointer */ dtrace_attribute_t dtsd_descattr; /* probedesc attributes */ dtrace_attribute_t dtsd_stmtattr; /* statement attributes */ @@ -521,11 +521,7 @@ extern int dtrace_probe_info(dtrace_hdl_t *, * entry point to obtain a library handle. */ struct dtrace_vector { -#if defined(sun) int (*dtv_ioctl)(void *, int, void *); -#else - int (*dtv_ioctl)(void *, u_long, void *); -#endif int (*dtv_lookup_by_addr)(void *, GElf_Addr, GElf_Sym *, dtrace_syminfo_t *); int (*dtv_status)(void *, processorid_t); @@ -572,9 +568,4 @@ extern int _dtrace_debug; } #endif -#if !defined(sun) -#define _SC_CPUID_MAX _SC_NPROCESSORS_CONF -#define _SC_NPROCESSORS_MAX _SC_NPROCESSORS_CONF -#endif - #endif /* _DTRACE_H */ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/mkerrtags.sh b/cddl/contrib/opensolaris/lib/libdtrace/common/mkerrtags.sh index d5651ff727fc..67a696fed5d2 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/mkerrtags.sh +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/mkerrtags.sh @@ -26,9 +26,7 @@ # #ident "%Z%%M% %I% %E% SMI" -BSDECHO=-e - -echo ${BSDECHO} "\ +echo "\ /*\n\ * Copyright 2003 Sun Microsystems, Inc. All rights reserved.\n\ * Use is subject to license terms.\n\ @@ -45,7 +43,7 @@ replace=' "\1",' sed -n "s/$pattern/$replace/p" || exit 1 -echo ${BSDECHO} "\ +echo "\ };\n\ \n\ static const int _dt_ntag = sizeof (_dt_errtags) / sizeof (_dt_errtags[0]);\n\ diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh b/cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh index 2fdc2fa636d5..7f90b7dd3705 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/mknames.sh @@ -26,9 +26,7 @@ # #ident "%Z%%M% %I% %E% SMI" -BSDECHO=-e - -echo ${BSDECHO} "\ +echo "\ /*\n\ * Copyright 2005 Sun Microsystems, Inc. All rights reserved.\n\ * Use is subject to license terms.\n\ @@ -49,7 +47,7 @@ nawk ' printf("\tcase %s: return (\"%s\");\n", $2, tolower(substr($2, 10))); }' -echo ${BSDECHO} "\ +echo "\ default: return (\"unknown\");\n\ }\n\ }" diff --git a/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c b/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c index cfd66e862657..dc47f7ec3f01 100644 --- a/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c +++ b/cddl/contrib/opensolaris/lib/libgen/common/gmatch.c @@ -32,28 +32,15 @@ /*LINTLIBRARY*/ -#if defined(sun) #pragma weak gmatch = _gmatch -#endif -#if defined(sun) #include "gen_synonyms.h" -#endif #include <sys/types.h> #include <libgen.h> #include <stdlib.h> #include <limits.h> -#if defined(sun) #include <widec.h> #include "_range.h" -#else -/* DOODAD */ static int multibyte = 0; -#define WCHAR_CSMASK 0x30000000 -#define valid_range(c1, c2) \ - (((c1) & WCHAR_CSMASK) == ((c2) & WCHAR_CSMASK) && \ - ((c1) > 0xff || !iscntrl((int)c1)) && ((c2) > 0xff || \ - !iscntrl((int)c2))) -#endif #define Popwchar(p, c) \ n = mbtowc(&cl, p, MB_LEN_MAX); \ |