aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/opensolaris/lib')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c16
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h1
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c142
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c30
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c14
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c2
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c3
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c295
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h6
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c29
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h3
11 files changed, 203 insertions, 338 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
index e63771c91e08..f3fda4af834e 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_cc.c
@@ -2478,10 +2478,7 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
"not referenced)\n", yypcb->pcb_sargv[argc - 1], argc - 1);
}
- /*
- * Perform sugar transformations (for "if" / "else") and replace the
- * existing clause chain with the new one.
- */
+ /* Perform sugar transformations. */
if (context == DT_CTX_DPROG) {
dt_node_t *dnp, *next_dnp;
dt_node_t *new_list = NULL;
@@ -2492,8 +2489,17 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
next_dnp = dnp->dn_list;
dnp->dn_list = NULL;
- if (dnp->dn_kind == DT_NODE_CLAUSE)
+ if (dnp->dn_kind == DT_NODE_CLAUSE) {
dnp = dt_compile_sugar(dtp, dnp);
+ if (cflags & DTRACE_C_SUGAR) {
+ dt_node_t *p;
+
+ dt_printd(dnp, stdout, 0);
+ for (p = dnp->dn_list; p != NULL;
+ p = p->dn_list)
+ dt_printd(p, stdout, 0);
+ }
+ }
/* append node to the new list */
new_list = dt_node_link(new_list, dnp);
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
index b3f69bb6329d..1e62bd6b21db 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_impl.h
@@ -323,6 +323,7 @@ struct dtrace_hdl {
#endif
int dt_fd; /* file descriptor for dtrace pseudo-device */
int dt_ftfd; /* file descriptor for fasttrap pseudo-device */
+ int dt_kinstfd; /* file descriptor for kinst 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 */
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
index 0b3dac0224f9..442c6f940733 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -215,10 +215,6 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
dofr[j].dofr_offset;
rel->r_info = ELF32_R_INFO(count + dep->de_global,
R_386_PC32);
-#elif defined(__mips__)
-/* XXX */
- printf("%s:%s(%d): MIPS not implemented\n",
- __FUNCTION__, __FILE__, __LINE__);
#elif defined(__powerpc__)
/*
* Add 4 bytes to hit the low half of this 64-bit
@@ -229,9 +225,9 @@ prepare_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf32_t *dep)
rel->r_info = ELF32_R_INFO(count + dep->de_global,
R_PPC_REL32);
#elif defined(__riscv)
-/* XXX */
- printf("%s:%s(%d): RISC-V not implemented\n",
- __FUNCTION__, __FILE__, __LINE__);
+ rel->r_offset = s->dofs_offset + dofr[j].dofr_offset;
+ rel->r_info = ELF32_R_INFO(count + dep->de_global,
+ R_RISCV_32_PCREL);
#else
#error unknown ISA
#endif
@@ -401,15 +397,15 @@ prepare_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, dof_elf64_t *dep)
R_AARCH64_PREL64);
#elif defined(__arm__)
/* XXX */
-#elif defined(__mips__)
-/* XXX */
#elif defined(__powerpc__)
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
rel->r_info = ELF64_R_INFO(count + dep->de_global,
R_PPC64_REL64);
#elif defined(__riscv)
-/* XXX */
+ rel->r_offset = s->dofs_offset + dofr[j].dofr_offset;
+ rel->r_info = ELF64_R_INFO(count + dep->de_global,
+ R_RISCV_32_PCREL);
#elif defined(__i386) || defined(__amd64)
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset;
@@ -504,14 +500,28 @@ dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
elf_file.ehdr.e_type = ET_REL;
#if defined(__arm__)
elf_file.ehdr.e_machine = EM_ARM;
-#elif defined(__mips__)
- elf_file.ehdr.e_machine = EM_MIPS;
#elif defined(__powerpc__)
elf_file.ehdr.e_machine = EM_PPC;
#elif defined(__i386) || defined(__amd64)
elf_file.ehdr.e_machine = EM_386;
#elif defined(__aarch64__)
elf_file.ehdr.e_machine = EM_AARCH64;
+#elif defined(__riscv)
+ elf_file.ehdr.e_machine = EM_RISCV;
+
+ /* Set the ELF flags according to our current ABI */
+#if defined(__riscv_compressed)
+ elf_file.ehdr.e_flags |= EF_RISCV_RVC;
+#endif
+#if defined(__riscv_float_abi_soft)
+ elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SOFT;
+#endif
+#if defined(__riscv_float_abi_single)
+ elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SINGLE;
+#endif
+#if defined(__riscv_float_abi_double)
+ elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_DOUBLE;
+#endif
#endif
elf_file.ehdr.e_version = EV_CURRENT;
elf_file.ehdr.e_shoff = sizeof (Elf32_Ehdr);
@@ -572,7 +582,7 @@ dump_elf32(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
} else {
shp = &elf_file.shdr[ESHDR_REL];
shp->sh_name = 37; /* DTRACE_SHSTRTAB32[37] = ".rel.SUNW_dof" */
- shp->sh_flags = SHF_ALLOC;
+ shp->sh_flags = 0;
shp->sh_type = SHT_REL;
shp->sh_entsize = sizeof (de.de_rel[0]);
shp->sh_link = ESHDR_SYMTAB;
@@ -644,8 +654,6 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
elf_file.ehdr.e_type = ET_REL;
#if defined(__arm__)
elf_file.ehdr.e_machine = EM_ARM;
-#elif defined(__mips__)
- elf_file.ehdr.e_machine = EM_MIPS;
#elif defined(__powerpc64__)
#if defined(_CALL_ELF) && _CALL_ELF == 2
elf_file.ehdr.e_flags = 2;
@@ -655,6 +663,22 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
elf_file.ehdr.e_machine = EM_AMD64;
#elif defined(__aarch64__)
elf_file.ehdr.e_machine = EM_AARCH64;
+#elif defined(__riscv)
+ elf_file.ehdr.e_machine = EM_RISCV;
+
+ /* Set the ELF flags according to our current ABI */
+#if defined(__riscv_compressed)
+ elf_file.ehdr.e_flags |= EF_RISCV_RVC;
+#endif
+#if defined(__riscv_float_abi_soft)
+ elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SOFT;
+#endif
+#if defined(__riscv_float_abi_single)
+ elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_SINGLE;
+#endif
+#if defined(__riscv_float_abi_double)
+ elf_file.ehdr.e_flags |= EF_RISCV_FLOAT_ABI_DOUBLE;
+#endif
#endif
elf_file.ehdr.e_version = EV_CURRENT;
elf_file.ehdr.e_shoff = sizeof (Elf64_Ehdr);
@@ -715,7 +739,7 @@ dump_elf64(dtrace_hdl_t *dtp, const dof_hdr_t *dof, int fd)
} else {
shp = &elf_file.shdr[ESHDR_REL];
shp->sh_name = 37; /* DTRACE_SHSTRTAB64[37] = ".rel.SUNW_dof" */
- shp->sh_flags = SHF_ALLOC;
+ shp->sh_flags = 0;
shp->sh_type = SHT_RELA;
shp->sh_entsize = sizeof (de.de_rel[0]);
shp->sh_link = ESHDR_SYMTAB;
@@ -843,17 +867,6 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
__LINE__);
return (-1);
}
-#elif defined(__mips__)
-#define DT_REL_NONE R_MIPS_NONE
-
-static int
-dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
- uint32_t *off)
-{
- printf("%s:%s(%d): MIPS not implemented\n", __FUNCTION__, __FILE__,
- __LINE__);
- return (-1);
-}
#elif defined(__powerpc__)
/* The sentinel is 'xor r3,r3,r3'. */
#define DT_OP_XOR_R3 0x7c631a78
@@ -938,14 +951,74 @@ dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
return (0);
}
#elif defined(__riscv)
+#define DT_OP_NOP 0x00000013 /* addi x0, x0, 0 */
+#define DT_OP_RET 0x00008067 /* jalr x0, x1, 0 */
+#define DT_OP_IS_AUIPC(op) (((op) & 0x7f) == 0x17)
+#define DT_OP_IS_JALR(op) (((op) & 0x707f) == 0x67)
+#define DT_OP_JALR_CALL 0x000080e7 /* jalr x1, x1, 0 */
+#define DT_OP_JALR_TAIL 0x00030067 /* jalr x0, x6, 0 */
#define DT_REL_NONE R_RISCV_NONE
+
static int
dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela,
uint32_t *off)
{
- printf("%s:%s(%d): RISC-V implementation required\n", __FUNCTION__,
- __FILE__, __LINE__);
- return (-1);
+ uint32_t *ip;
+
+ /*
+ * XXX: this implementation is untested, but should serve as a decent
+ * starting point.
+ */
+
+ /*
+ * Ensure that the offset is aligned on a compressed-instruction
+ * boundary.
+ */
+ if ((rela->r_offset & (sizeof (uint16_t) - 1)) != 0)
+ return (-1);
+
+ /*
+ * We only know about some specific relocation types.
+ * We also recognize relocation type NONE, since that gets used for
+ * relocations of USDT probes, and we might be re-processing a file.
+ */
+ if (GELF_R_TYPE(rela->r_info) != R_RISCV_CALL &&
+ GELF_R_TYPE(rela->r_info) != R_RISCV_CALL_PLT &&
+ GELF_R_TYPE(rela->r_info) != R_RISCV_NONE)
+ return (-1);
+
+ ip = (uint32_t *)(p + rela->r_offset);
+
+ /*
+ * 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 below.
+ */
+ if (ip[0] == DT_OP_NOP && (ip[1] == DT_OP_NOP || ip[1] == DT_OP_RET))
+ return (0);
+
+ /*
+ * We expect a auipc+jalr pair, either from a call or a tail.
+ * - call: auipc x1 0; jalr x1, x1, 0
+ * - tail: auipc x6 0; jalr x0, x6, 0
+ */
+ if (!DT_OP_IS_AUIPC(ip[0]) || !DT_OP_IS_JALR(ip[1]))
+ return (-1);
+
+ /*
+ * On riscv, we do not have to differentiate between regular probes and
+ * is-enabled probes. Calls are to be converted into a no-op whereas
+ * tail calls should become a return.
+ */
+ if (ip[1] == DT_OP_JALR_CALL) {
+ ip[0] = DT_OP_NOP;
+ ip[1] = DT_OP_NOP;
+ } else {
+ ip[0] = DT_OP_NOP;
+ ip[1] = DT_OP_RET;
+ }
+
+ return (0);
}
#elif defined(__i386) || defined(__amd64)
@@ -1167,9 +1240,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
if (dtp->dt_oflags & DTRACE_O_LP64) {
eclass = ELFCLASS64;
-#if defined(__mips__)
- emachine1 = emachine2 = EM_MIPS;
-#elif defined(__powerpc__)
+#if defined(__powerpc__)
emachine1 = emachine2 = EM_PPC64;
#if !defined(_CALL_ELF) || _CALL_ELF == 1
uses_funcdesc = 1;
@@ -1178,14 +1249,14 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
emachine1 = emachine2 = EM_AMD64;
#elif defined(__aarch64__)
emachine1 = emachine2 = EM_AARCH64;
+#elif defined(__riscv)
+ emachine1 = emachine2 = EM_RISCV;
#endif
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(__i386) || defined(__amd64)
@@ -1612,6 +1683,7 @@ process_obj(dtrace_hdl_t *dtp, const char *obj, int *eprobesp)
* invocation.
*/
if (rsym.st_shndx != SHN_ABS) {
+ rsym.st_info = GELF_ST_INFO(STB_WEAK, STT_FUNC);
rsym.st_shndx = SHN_ABS;
(void) gelf_update_sym(data_sym, ndx, &rsym);
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
index b9408944f8c5..281c787de533 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_module.c
@@ -1129,33 +1129,21 @@ dt_module_getctflib(dtrace_hdl_t *dtp, dt_module_t *dmp, const char *name)
* including the path.
*/
static void
-#ifdef illumos
-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;
int fd, err, bits;
-#ifdef __FreeBSD__
struct module_stat ms;
dt_kmodule_t *dkmp;
uint_t h;
int modid;
-#endif
-
dt_module_t *dmp;
const char *s;
size_t shstrs;
GElf_Shdr sh;
Elf_Data *dp;
Elf_Scn *sp;
-
-#ifdef illumos
- (void) snprintf(fname, sizeof (fname),
- "%s/%s/object", OBJFS_ROOT, name);
-#else
GElf_Ehdr ehdr;
GElf_Phdr ph;
char name[MAXPATHLEN];
@@ -1165,7 +1153,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
(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) {
@@ -1174,6 +1161,9 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
return;
}
+ (void) strlcpy(dmp->dm_file, fname, sizeof(dmp->dm_file));
+ dmp->dm_modid = k_stat->id;
+
/*
* Since the module can unload out from under us (and /system/object
* will return ENOENT), tell libelf to cook the entire file now and
@@ -1206,7 +1196,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
dt_module_destroy(dtp, dmp);
return;
}
-#if defined(__FreeBSD__)
mapbase = (uintptr_t)k_stat->address;
gelf_getehdr(dmp->dm_elf, &ehdr);
is_elf_obj = (ehdr.e_type == ET_REL);
@@ -1219,7 +1208,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
return;
}
}
-#endif
/*
* Iterate over the section headers locating various sections of
* interest and use their attributes to flesh out the dt_module_t.
@@ -1228,7 +1216,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
if (gelf_getshdr(sp, &sh) == NULL || sh.sh_type == SHT_NULL ||
(s = elf_strptr(dmp->dm_elf, shstrs, sh.sh_name)) == NULL)
continue; /* skip any malformed sections */
-#if defined(__FreeBSD__)
if (sh.sh_size == 0)
continue;
if (sh.sh_type == SHT_PROGBITS || sh.sh_type == SHT_NOBITS) {
@@ -1240,7 +1227,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
dmp->dm_sec_offsets[elf_ndxscn(sp)] = sh.sh_addr;
mapbase += sh.sh_size;
}
-#endif
if (strcmp(s, ".text") == 0) {
dmp->dm_text_size = sh.sh_size;
dmp->dm_text_va = sh.sh_addr;
@@ -1254,17 +1240,10 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
(dp = elf_getdata(sp, NULL)) != NULL) {
bcopy(dp->d_buf, &dmp->dm_info,
MIN(sh.sh_size, sizeof (dmp->dm_info)));
- } else if (strcmp(s, ".filename") == 0 &&
- (dp = elf_getdata(sp, NULL)) != NULL) {
- (void) strlcpy(dmp->dm_file,
- dp->d_buf, sizeof (dmp->dm_file));
}
}
dmp->dm_flags |= DT_DM_KERNEL;
-#ifdef illumos
- dmp->dm_modid = (int)OBJFS_MODID(st.st_ino);
-#else
/*
* Include .rodata and special sections into .text.
* This depends on default section layout produced by GNU ld
@@ -1285,12 +1264,10 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
}
}
#endif
-#endif /* illumos */
if (dmp->dm_info.objfs_info_primary)
dmp->dm_flags |= DT_DM_PRIMARY;
-#ifdef __FreeBSD__
ms.version = sizeof(ms);
for (modid = kldfirstmod(k_stat->id); modid > 0;
modid = modnext(modid)) {
@@ -1315,7 +1292,6 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat)
dkmp->dkm_module = dmp;
dtp->dt_kmods[h] = dkmp;
}
-#endif
dt_dprintf("opened %d-bit module %s (%s) [%d]\n",
bits, dmp->dm_name, dmp->dm_file, dmp->dm_modid);
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
index f55d488f4d91..fd770e180b47 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
@@ -416,6 +416,8 @@ static const dt_ident_t _dtrace_globals[] = {
&dt_idops_func, "void(int)" },
{ "rand", DT_IDENT_FUNC, 0, DIF_SUBR_RAND, DT_ATTR_STABCMN, DT_VERS_1_0,
&dt_idops_func, "int()" },
+{ "regs", DT_IDENT_ARRAY, 0, DIF_VAR_REGS, DT_ATTR_STABCMN, DT_VERS_1_13,
+ &dt_idops_regs, NULL },
{ "rindex", DT_IDENT_FUNC, 0, DIF_SUBR_RINDEX, DT_ATTR_STABCMN, DT_VERS_1_1,
&dt_idops_func, "int(const char *, const char *, [int])" },
#ifdef illumos
@@ -1113,6 +1115,15 @@ dt_vopen(int version, int flags, int *errp,
*/
if (err == ENOENT && modfind("dtraceall") < 0) {
kldload("dtraceall"); /* ignore the error */
+#if __SIZEOF_LONG__ == 8
+ if (modfind("linux64elf") >= 0)
+ kldload("systrace_linux");
+ if (modfind("linuxelf") >= 0)
+ kldload("systrace_linux32");
+#else
+ if (modfind("linuxelf") >= 0)
+ kldload("systrace_linux");
+#endif
dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC);
err = errno;
}
@@ -1171,6 +1182,7 @@ alloc:
dtp->dt_version = version;
dtp->dt_fd = dtfd;
dtp->dt_ftfd = ftfd;
+ dtp->dt_kinstfd = -1;
dtp->dt_fterr = fterr;
dtp->dt_cdefs_fd = -1;
dtp->dt_ddefs_fd = -1;
@@ -1679,6 +1691,8 @@ dtrace_close(dtrace_hdl_t *dtp)
(void) close(dtp->dt_fd);
if (dtp->dt_ftfd != -1)
(void) close(dtp->dt_ftfd);
+ if (dtp->dt_kinstfd != -1)
+ (void) close(dtp->dt_kinstfd);
if (dtp->dt_cdefs_fd != -1)
(void) close(dtp->dt_cdefs_fd);
if (dtp->dt_ddefs_fd != -1)
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
index f028f99ccf64..2b85dd2b26b6 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_parser.c
@@ -4767,8 +4767,8 @@ dt_printd(dt_node_t *dnp, FILE *fp, int depth)
dt_printd(dnp->dn_pred, fp, 0);
(void) fprintf(fp, "/\n");
}
- (void) fprintf(fp, "{\n");
+ (void) fprintf(fp, "{\n");
for (arg = dnp->dn_acts; arg != NULL; arg = arg->dn_list)
dt_printd(arg, fp, depth + 1);
(void) fprintf(fp, "}\n");
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
index 57a7db4ad0fd..c33ae955ba61 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
@@ -317,8 +317,7 @@ 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__) && \
- !defined(__mips__) && !defined(__riscv)
+#if !defined(__arm__) && !defined(__powerpc__) && !defined(__riscv)
case sizeof (long double):
return (dt_printf(dtp, fp, format,
*((long double *)addr) / ldn));
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
index 34bcc15b9ac7..b32dcea1f8ba 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.c
@@ -80,10 +80,8 @@
* up using this condition and will then call the client handler as necessary.
*/
+#include <sys/syscall.h>
#include <sys/wait.h>
-#ifdef illumos
-#include <sys/lwp.h>
-#endif
#include <strings.h>
#include <signal.h>
#include <assert.h>
@@ -93,14 +91,10 @@
#include <dt_pid.h>
#include <dt_impl.h>
-#ifndef illumos
-#include <sys/syscall.h>
#include <libproc_compat.h>
-#define SYS_forksys SYS_fork
-#endif
#define IS_SYS_EXEC(w) (w == SYS_execve)
-#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_forksys)
+#define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork)
static dt_bkpt_t *
dt_proc_bpcreate(dt_proc_t *dpr, uintptr_t addr, dt_bkpt_f *func, void *data)
@@ -147,38 +141,23 @@ dt_proc_bpdestroy(dt_proc_t *dpr, int delbkpts)
static void
dt_proc_bpmatch(dtrace_hdl_t *dtp, dt_proc_t *dpr)
{
-#ifdef illumos
- const lwpstatus_t *psp = &Pstatus(dpr->dpr_proc)->pr_lwp;
-#else
unsigned long pc;
-#endif
dt_bkpt_t *dbp;
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
-#ifndef illumos
proc_regget(dpr->dpr_proc, REG_PC, &pc);
proc_bkptregadj(&pc);
-#endif
for (dbp = dt_list_next(&dpr->dpr_bps);
dbp != NULL; dbp = dt_list_next(dbp)) {
-#ifdef illumos
- if (psp->pr_reg[R_PC] == dbp->dbp_addr)
- break;
-#else
if (pc == dbp->dbp_addr)
break;
-#endif
}
if (dbp == NULL) {
dt_dprintf("pid %d: spurious breakpoint wakeup for %lx\n",
-#ifdef illumos
- (int)dpr->dpr_pid, (ulong_t)psp->pr_reg[R_PC]);
-#else
(int)dpr->dpr_pid, pc);
-#endif
return;
}
@@ -346,12 +325,8 @@ dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname)
}
(void) dt_proc_bpcreate(dpr, rdn.u.bptaddr,
-#ifdef illumos
- (dt_bkpt_f *)dt_proc_rdevent, (void *)evname);
-#else
/* XXX ugly */
(dt_bkpt_f *)dt_proc_rdevent, __DECONST(void *, evname));
-#endif
}
/*
@@ -361,34 +336,18 @@ dt_proc_rdwatch(dt_proc_t *dpr, rd_event_e event, const char *evname)
static void
dt_proc_attach(dt_proc_t *dpr, int exec)
{
-#ifdef illumos
- const pstatus_t *psp = Pstatus(dpr->dpr_proc);
-#endif
rd_err_e err;
GElf_Sym sym;
assert(DT_MUTEX_HELD(&dpr->dpr_lock));
if (exec) {
-#ifdef illumos
- if (psp->pr_lwp.pr_errno != 0)
- return; /* exec failed: nothing needs to be done */
-#endif
dt_proc_bpdestroy(dpr, B_FALSE);
-#ifdef illumos
- Preset_maps(dpr->dpr_proc);
-#endif
}
if ((dpr->dpr_rtld = Prd_agent(dpr->dpr_proc)) != NULL &&
(err = rd_event_enable(dpr->dpr_rtld, B_TRUE)) == RD_OK) {
-#ifdef illumos
- dt_proc_rdwatch(dpr, RD_PREINIT, "RD_PREINIT");
-#endif
dt_proc_rdwatch(dpr, RD_POSTINIT, "RD_POSTINIT");
-#ifdef illumos
- dt_proc_rdwatch(dpr, RD_DLACTIVITY, "RD_DLACTIVITY");
-#endif
} else {
dt_dprintf("pid %d: failed to enable rtld events: %s\n",
(int)dpr->dpr_pid, dpr->dpr_rtld ? rd_errstr(err) :
@@ -407,84 +366,6 @@ dt_proc_attach(dt_proc_t *dpr, int exec)
}
}
-/*
- * Wait for a stopped process to be set running again by some other debugger.
- * This is typically not required by /proc-based debuggers, since the usual
- * model is that one debugger controls one victim. But DTrace, as usual, has
- * its own needs: the stop() action assumes that prun(1) or some other tool
- * will be applied to resume the victim process. This could be solved by
- * adding a PCWRUN directive to /proc, but that seems like overkill unless
- * other debuggers end up needing this functionality, so we implement a cheap
- * equivalent to PCWRUN using the set of existing kernel mechanisms.
- *
- * Our intent is really not just to wait for the victim to run, but rather to
- * wait for it to run and then stop again for a reason other than the current
- * PR_REQUESTED stop. Since PCWSTOP/Pstopstatus() can be applied repeatedly
- * to a stopped process and will return the same result without affecting the
- * victim, we can just perform these operations repeatedly until Pstate()
- * changes, the representative LWP ID changes, or the stop timestamp advances.
- * dt_proc_control() will then rediscover the new state and continue as usual.
- * When the process is still stopped in the same exact state, we sleep for a
- * brief interval before waiting again so as not to spin consuming CPU cycles.
- */
-static void
-dt_proc_waitrun(dt_proc_t *dpr)
-{
- printf("%s:%s(%d): not implemented\n", __FUNCTION__, __FILE__,
- __LINE__);
-#ifdef DOODAD
- struct ps_prochandle *P = dpr->dpr_proc;
- const lwpstatus_t *psp = &Pstatus(P)->pr_lwp;
-
- int krflag = psp->pr_flags & (PR_KLC | PR_RLC);
- timestruc_t tstamp = psp->pr_tstamp;
- lwpid_t lwpid = psp->pr_lwpid;
-
- const long wstop = PCWSTOP;
- int pfd = Pctlfd(P);
-
- assert(DT_MUTEX_HELD(&dpr->dpr_lock));
- assert(psp->pr_flags & PR_STOPPED);
- assert(Pstate(P) == PS_STOP);
-
- /*
- * While we are waiting for the victim to run, clear PR_KLC and PR_RLC
- * so that if the libdtrace client is killed, the victim stays stopped.
- * dt_proc_destroy() will also observe this and perform PRELEASE_HANG.
- */
- (void) Punsetflags(P, krflag);
- Psync(P);
-
- (void) pthread_mutex_unlock(&dpr->dpr_lock);
-
- while (!dpr->dpr_quit) {
- if (write(pfd, &wstop, sizeof (wstop)) == -1 && errno == EINTR)
- continue; /* check dpr_quit and continue waiting */
-
- (void) pthread_mutex_lock(&dpr->dpr_lock);
- (void) Pstopstatus(P, PCNULL, 0);
- psp = &Pstatus(P)->pr_lwp;
-
- /*
- * If we've reached a new state, found a new representative, or
- * the stop timestamp has changed, restore PR_KLC/PR_RLC to its
- * original setting and then return with dpr_lock held.
- */
- if (Pstate(P) != PS_STOP || psp->pr_lwpid != lwpid ||
- bcmp(&psp->pr_tstamp, &tstamp, sizeof (tstamp)) != 0) {
- (void) Psetflags(P, krflag);
- Psync(P);
- return;
- }
-
- (void) pthread_mutex_unlock(&dpr->dpr_lock);
- (void) poll(NULL, 0, MILLISEC / 2);
- }
-
- (void) pthread_mutex_lock(&dpr->dpr_lock);
-#endif
-}
-
typedef struct dt_proc_control_data {
dtrace_hdl_t *dpcd_hdl; /* DTrace handle */
dt_proc_t *dpcd_proc; /* proccess to control */
@@ -511,12 +392,6 @@ dt_proc_control(void *arg)
dt_proc_hash_t *dph = dtp->dt_procs;
struct ps_prochandle *P = dpr->dpr_proc;
int pid = dpr->dpr_pid;
-
-#ifdef illumos
- int pfd = Pctlfd(P);
-
- const long wstop = PCWSTOP;
-#endif
int notify = B_FALSE;
/*
@@ -534,44 +409,14 @@ dt_proc_control(void *arg)
*/
(void) pthread_mutex_lock(&dpr->dpr_lock);
-#ifdef illumos
- (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 */
-
- (void) Pfault(P, FLTBPT, B_TRUE); /* always trace breakpoints */
- (void) Pfault(P, FLTTRACE, B_TRUE); /* always trace single-step */
-
- /*
- * We must trace exit from exec() system calls so that if the exec is
- * successful, we can reset our breakpoints and re-initialize libproc.
- */
- (void) Psysexit(P, SYS_execve, B_TRUE);
-
- /*
- * We must trace entry and exit for fork() system calls in order to
- * disable our breakpoints temporarily during the fork. We do not set
- * the PR_FORK flag, so if fork succeeds the child begins executing and
- * does not inherit any other tracing behaviors or a control thread.
- */
- (void) Psysentry(P, SYS_vfork, B_TRUE);
- (void) Psysexit(P, SYS_vfork, B_TRUE);
- (void) Psysentry(P, SYS_forksys, B_TRUE);
- (void) Psysexit(P, SYS_forksys, B_TRUE);
-
- Psync(P); /* enable all /proc changes */
-#endif
dt_proc_attach(dpr, B_FALSE); /* enable rtld breakpoints */
/*
- * 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 DT_CLOSE_KILL is set, we created the process; otherwise we
+ * grabbed it. Check for an appropriate stop request and wait for
+ * dt_proc_continue.
*/
-#ifdef illumos
- if (Pstatus(P)->pr_flags & PR_KLC)
-#else
- if (proc_getflags(P) & PR_KLC)
-#endif
+ if (dpr->dpr_close == DT_CLOSE_KILL)
dt_proc_stop(dpr, DT_PROC_STOP_CREATE);
else
dt_proc_stop(dpr, DT_PROC_STOP_GRAB);
@@ -595,55 +440,21 @@ dt_proc_control(void *arg)
while (!dpr->dpr_quit) {
const lwpstatus_t *psp;
-#ifdef illumos
- 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_wstatus(P);
if (errno == EINTR)
continue; /* check dpr_quit and continue waiting */
-#endif
(void) pthread_mutex_lock(&dpr->dpr_lock);
-#ifdef illumos
-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
-
switch (Pstate(P)) {
case PS_STOP:
-#ifdef illumos
- psp = &Pstatus(P)->pr_lwp;
-#else
psp = proc_getlwpstatus(P);
-#endif
dt_dprintf("pid %d: proc stopped showing %d/%d\n",
pid, psp->pr_why, psp->pr_what);
/*
- * If the process stops showing PR_REQUESTED, then the
- * DTrace stop() action was applied to it or another
- * debugging utility (e.g. pstop(1)) asked it to stop.
- * In either case, the user's intention is for the
- * process to remain stopped until another external
- * mechanism (e.g. prun(1)) is applied. So instead of
- * setting the process running ourself, we wait for
- * someone else to do so. Once that happens, we return
- * to our normal loop waiting for an event of interest.
- */
- if (psp->pr_why == PR_REQUESTED) {
- dt_proc_waitrun(dpr);
- (void) pthread_mutex_unlock(&dpr->dpr_lock);
- continue;
- }
-
- /*
* If the process stops showing one of the events that
* we are tracing, perform the appropriate response.
* Note that we ignore PR_SUSPENDED, PR_CHECKPOINT, and
@@ -666,11 +477,6 @@ pwait_locked:
break;
case PS_LOST:
-#ifdef illumos
- if (Preopen(P) == 0)
- goto pwait_locked;
-#endif
-
dt_dprintf("pid %d: proc lost: %s\n",
pid, strerror(errno));
@@ -685,9 +491,19 @@ pwait_locked:
break;
}
- 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));
+ if (Pstate(P) != PS_UNDEAD) {
+ if (dpr->dpr_quit && dpr->dpr_close == DT_CLOSE_KILL) {
+ /*
+ * We're about to kill the child, so don't
+ * bother resuming it. In some cases, such as
+ * an initialization error, we shouldn't have
+ * started it in the first place, so letting it
+ * run could be harmful.
+ */
+ } else if (Psetrun(P, 0, 0) == -1) {
+ dt_dprintf("pid %d: failed to set running: "
+ "%s\n", (int)dpr->dpr_pid, strerror(errno));
+ }
}
(void) pthread_mutex_unlock(&dpr->dpr_lock);
@@ -739,11 +555,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;
-#ifdef illumos
- 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) {
@@ -772,28 +584,15 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P)
assert(dpr != NULL);
- /*
- * If neither PR_KLC nor PR_RLC is set, then the process is stopped by
- * an external debugger and we were waiting in dt_proc_waitrun().
- * Leave the process in this condition using PRELEASE_HANG.
- */
-#ifdef illumos
- 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);
- rflag = PRELEASE_HANG;
-#ifdef illumos
- } else if (Pstatus(dpr->dpr_proc)->pr_flags & PR_KLC) {
-#else
- } else if (proc_getflags(dpr->dpr_proc) & PR_KLC) {
-#endif
+ switch (dpr->dpr_close) {
+ case DT_CLOSE_KILL:
dt_dprintf("killing pid %d\n", (int)dpr->dpr_pid);
- rflag = PRELEASE_KILL; /* apply kill-on-last-close */
- } else {
+ rflag = PRELEASE_KILL;
+ break;
+ case DT_CLOSE_RUN:
dt_dprintf("releasing pid %d\n", (int)dpr->dpr_pid);
- rflag = 0; /* apply run-on-last-close */
+ rflag = 0;
+ break;
}
if (dpr->dpr_tid) {
@@ -813,11 +612,7 @@ dt_proc_destroy(dtrace_hdl_t *dtp, struct ps_prochandle *P)
*/
(void) pthread_mutex_lock(&dpr->dpr_lock);
dpr->dpr_quit = B_TRUE;
-#ifdef illumos
- (void) _lwp_kill(dpr->dpr_tid, SIGCANCEL);
-#else
pthread_kill(dpr->dpr_tid, SIGTHR);
-#endif
/*
* If the process is currently idling in dt_proc_stop(), re-
@@ -885,11 +680,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() */
-#ifdef illumos
- (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;
@@ -917,14 +708,8 @@ 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) {
-#ifdef illumos
- const psinfo_t *prp = Ppsinfo(dpr->dpr_proc);
- int stat = prp ? prp->pr_wstat : 0;
- int pid = dpr->dpr_pid;
-#else
int stat = proc_getwstat(dpr->dpr_proc);
int pid = proc_getpid(dpr->dpr_proc);
-#endif
if (proc_state(dpr->dpr_proc) == PS_LOST) {
(void) dt_proc_error(dpr->dpr_hdl, dpr,
"failed to control pid %d: process exec'd "
@@ -968,29 +753,15 @@ 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);
-#ifdef illumos
- dpr->dpr_proc = Pxcreate(file, argv, dtp->dt_proc_env, &err, NULL, 0);
- if (dpr->dpr_proc == NULL) {
- return (dt_proc_error(dtp, dpr,
- "failed to execute %s: %s\n", file, Pcreate_error(err)));
- }
-#else
if ((err = proc_create(file, argv, dtp->dt_proc_env, pcf, child_arg,
&dpr->dpr_proc)) != 0) {
return (dt_proc_error(dtp, dpr,
"failed to execute %s: %s\n", file, Pcreate_error(err)));
}
-#endif
dpr->dpr_hdl = dtp;
-#ifdef illumos
- dpr->dpr_pid = Pstatus(dpr->dpr_proc)->pr_pid;
-#else
dpr->dpr_pid = proc_getpid(dpr->dpr_proc);
-#endif
-
- (void) Punsetflags(dpr->dpr_proc, PR_RLC);
- (void) Psetflags(dpr->dpr_proc, PR_KLC);
+ dpr->dpr_close = DT_CLOSE_KILL;
if (dt_proc_create_thread(dtp, dpr, dtp->dt_prcmode) != 0)
return (NULL); /* dt_proc_error() has been called for us */
@@ -1048,20 +819,14 @@ 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);
-#ifdef illumos
- if ((dpr->dpr_proc = Pgrab(pid, flags, &err)) == NULL) {
-#else
if ((err = proc_attach(pid, flags, &dpr->dpr_proc)) != 0) {
-#endif
return (dt_proc_error(dtp, dpr,
"failed to grab pid %d: %s\n", (int)pid, Pgrab_error(err)));
}
dpr->dpr_hdl = dtp;
dpr->dpr_pid = pid;
-
- (void) Punsetflags(dpr->dpr_proc, PR_KLC);
- (void) Psetflags(dpr->dpr_proc, PR_RLC);
+ dpr->dpr_close = DT_CLOSE_RUN;
/*
* If we are attempting to grab the process without a monitor
@@ -1227,11 +992,7 @@ dtrace_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv,
struct ps_prochandle *P = dt_proc_create(dtp, file, argv, pcf, child_arg);
if (P != NULL && idp != NULL && idp->di_id == 0) {
-#ifdef illumos
- 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 beae6f6d5cda..458e9902881f 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_proc.h
@@ -40,6 +40,11 @@
extern "C" {
#endif
+enum dt_close_action {
+ DT_CLOSE_RUN,
+ DT_CLOSE_KILL,
+};
+
typedef struct dt_proc {
dt_list_t dpr_list; /* prev/next pointers for lru chain */
struct dt_proc *dpr_hash; /* next pointer for pid hash chain */
@@ -60,6 +65,7 @@ typedef struct dt_proc {
uint8_t dpr_rdonly; /* proc flag: opened read-only */
pthread_t dpr_tid; /* control thread (or zero if none) */
dt_list_t dpr_bps; /* list of dt_bkpt_t structures */
+ enum dt_close_action dpr_close; /* do this to child when exiting */
} dt_proc_t;
typedef struct dt_proc_notify {
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
index 7cf352d4d505..2391690afc0b 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_provider.c
@@ -48,6 +48,7 @@
#include <dt_list.h>
#include <dt_pid.h>
#include <dtrace.h>
+#include <kinst.h>
static dt_provider_t *
dt_provider_insert(dtrace_hdl_t *dtp, dt_provider_t *pvp, uint_t h)
@@ -699,6 +700,34 @@ dt_probe_info(dtrace_hdl_t *dtp,
prp = idp->di_data;
else if (pdp->dtpd_id != DTRACE_IDNONE)
prp = dt_probe_discover(pvp, pdp);
+
+ if (strcmp(pvp->pv_desc.dtvd_name, "kinst") == 0) {
+ dtrace_kinst_probedesc_t pd;
+
+ if (dtp->dt_kinstfd == -1) {
+ int fd;
+
+ fd = open("/dev/dtrace/kinst", O_WRONLY);
+ if (fd < 0) {
+ (void) dt_set_errno(dtp, errno);
+ return (NULL);
+ }
+ dtp->dt_kinstfd = fd;
+ }
+ memset(&pd, 0, sizeof(pd));
+ strlcpy(pd.kpd_func, pdp->dtpd_func,
+ sizeof (pd.kpd_func));
+
+ if (n_is_glob)
+ pd.kpd_off = -1;
+ else
+ pd.kpd_off = strtol(pdp->dtpd_name, NULL, 10);
+ if (ioctl(dtp->dt_kinstfd, KINSTIOC_MAKEPROBE, &pd) !=
+ 0) {
+ (void) dt_set_errno(dtp, errno);
+ return (NULL);
+ }
+ }
}
/*
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
index f0bc83a7fc7b..af0213695f32 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dtrace.h
@@ -119,10 +119,11 @@ typedef struct dtrace_proginfo {
#define DTRACE_C_PSPEC 0x0080 /* Interpret ambiguous specifiers as probes */
#define DTRACE_C_ETAGS 0x0100 /* Prefix error messages with error tags */
#define DTRACE_C_ARGREF 0x0200 /* Do not require all macro args to be used */
+#define DTRACE_C_SUGAR 0x0400 /* Dump D script post-dt_sugar */
#define DTRACE_C_DEFARG 0x0800 /* Use 0/"" as value for unspecified args */
#define DTRACE_C_NOLIBS 0x1000 /* Do not process D system libraries */
#define DTRACE_C_CTL 0x2000 /* Only process control directives */
-#define DTRACE_C_MASK 0x3bff /* mask of all valid flags to dtrace_*compile */
+#define DTRACE_C_MASK 0x3fff /* mask of all valid flags to dtrace_*compile */
extern dtrace_prog_t *dtrace_program_strcompile(dtrace_hdl_t *,
const char *, dtrace_probespec_t, uint_t, int, char *const []);