aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libdtrace
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2016-12-06 04:28:56 +0000
committerMark Johnston <markj@FreeBSD.org>2016-12-06 04:28:56 +0000
commite0d70fc1dcf9b36f7540f7963fc0d0cb4ae0d80f (patch)
treefdee3c77fe7307e72ffa7f8e45b2f7015bac5cc3 /cddl/contrib/opensolaris/lib/libdtrace
parentfe2521b98063641e23bf08f395bb7f7e09994122 (diff)
downloadsrc-e0d70fc1dcf9b36f7540f7963fc0d0cb4ae0d80f.tar.gz
src-e0d70fc1dcf9b36f7540f7963fc0d0cb4ae0d80f.zip
libdtrace: Don't use a read-only handle for enumerating pid probes.
Enumeration of return probes involves disassembling subroutines in the target process, and ptrace(2) is currently used to read from the target process. libproc could read from the backing file instead to avoid this problem, but in the common case libdtrace will have a writeable handle on the process anyway. In particular, a writeable handle is needed to list USDT probes, and libdtrace will cache such a handle for processes that it controls via dtrace -c and -p.
Notes
Notes: svn path=/head/; revision=309599
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libdtrace')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
index 54444775ab3d..fcbea77f95a2 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_pid.c
@@ -729,8 +729,13 @@ dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb)
(void) snprintf(provname, sizeof (provname), "pid%d", (int)pid);
if (gmatch(provname, pdp->dtpd_provider) != 0) {
+#ifdef __FreeBSD__
+ if ((P = dt_proc_grab(dtp, pid, 0, 1)) == NULL)
+#else
if ((P = dt_proc_grab(dtp, pid, PGRAB_RDONLY | PGRAB_FORCE,
- 0)) == NULL) {
+ 0)) == NULL)
+#endif
+ {
(void) dt_pid_error(dtp, pcb, NULL, NULL, D_PROC_GRAB,
"failed to grab process %d", (int)pid);
return (-1);