summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authormarkj <markj@FreeBSD.org>2015-12-07 21:44:05 +0000
committermarkj <markj@FreeBSD.org>2015-12-07 21:44:05 +0000
commit6744527ba7a66fb8f409c8aea6c9c6ac3b8b84c6 (patch)
tree8f09ddeaee99dc12f093b0d7b20524da12d14535 /cddl
parentf734f97f4eae5074772d9168c3337517648369ad (diff)
downloadFreeBSD-src-6744527ba7a66fb8f409c8aea6c9c6ac3b8b84c6.zip
FreeBSD-src-6744527ba7a66fb8f409c8aea6c9c6ac3b8b84c6.tar.gz
Modify DTRACEHIOC_ADDDOF to copy the DOF section from the target process.
r281257 added support for lazyload mode by allowing dtrace(1) to register a DOF section on behalf of a traced process. This was implemented by having libdtrace copy the DOF section into a heap-allocated buffer and passing its address to the ioctl handler. However, DTrace uses the DOF section address as a lookup key in certain cases, so the ioctl handler should be given the target process' DOF section address instead. This change modifies the ADDDOF handler to copy the DOF section in from the target process, rather than from dtrace(1).
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c50
1 files changed, 4 insertions, 46 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
index c61a710..5444477 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
@@ -571,12 +571,6 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
prsyminfo_t sip;
dof_helper_t dh;
GElf_Half e_type;
-#ifdef __FreeBSD__
- dof_hdr_t hdr;
- size_t sz;
- uint64_t dofmax;
- void *dof;
-#endif
const char *mname;
const char *syms[] = { "___SUNW_dof", "__SUNW_dof" };
int i, fd = -1;
@@ -606,61 +600,25 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname)
continue;
}
-#ifdef __FreeBSD__
+ dh.dofhp_dof = sym.st_value;
dh.dofhp_addr = (e_type == ET_EXEC) ? 0 : pmp->pr_vaddr;
- if (Pread(P, &hdr, sizeof (hdr), sym.st_value) !=
- sizeof (hdr)) {
- dt_dprintf("read of DOF header failed\n");
- continue;
- }
-
- sz = sizeof(dofmax);
- if (sysctlbyname("kern.dtrace.dof_maxsize", &dofmax, &sz,
- NULL, 0) != 0) {
- dt_dprintf("failed to read dof_maxsize: %s\n",
- strerror(errno));
- continue;
- }
- if (dofmax < hdr.dofh_loadsz) {
- dt_dprintf("DOF load size exceeds maximum\n");
- continue;
- }
-
- if ((dof = malloc(hdr.dofh_loadsz)) == NULL)
- return (-1);
-
- if (Pread(P, dof, hdr.dofh_loadsz, sym.st_value) !=
- hdr.dofh_loadsz) {
- free(dof);
- dt_dprintf("read of DOF section failed\n");
- continue;
- }
-
- dh.dofhp_dof = (uintptr_t)dof;
- dh.dofhp_pid = proc_getpid(P);
dt_pid_objname(dh.dofhp_mod, sizeof (dh.dofhp_mod),
sip.prs_lmid, mname);
+#ifdef __FreeBSD__
+ dh.dofhp_pid = proc_getpid(P);
+
if (fd == -1 &&
(fd = open("/dev/dtrace/helper", O_RDWR, 0)) < 0) {
dt_dprintf("open of helper device failed: %s\n",
strerror(errno));
- free(dof);
return (-1); /* errno is set for us */
}
if (ioctl(fd, DTRACEHIOC_ADDDOF, &dh, sizeof (dh)) < 0)
dt_dprintf("DOF was rejected for %s\n", dh.dofhp_mod);
-
- free(dof);
#else
- 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),
- sip.prs_lmid, mname);
-
if (fd == -1 &&
(fd = pr_open(P, "/dev/dtrace/helper", O_RDWR, 0)) < 0) {
dt_dprintf("pr_open of helper device failed: %s\n",
OpenPOWER on IntegriCloud