summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/cmd/dtrace
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2010-08-21 11:50:53 +0000
committerrpaulo <rpaulo@FreeBSD.org>2010-08-21 11:50:53 +0000
commitb325e69c9282072ea3b203319017abc400db4771 (patch)
treeae5b6066f0143ecb034e8de394e160841cd4f84f /cddl/contrib/opensolaris/cmd/dtrace
parent232561a60dcdeeffd316d29086bb31f2e12d7591 (diff)
downloadFreeBSD-src-b325e69c9282072ea3b203319017abc400db4771.zip
FreeBSD-src-b325e69c9282072ea3b203319017abc400db4771.tar.gz
Add libdtrace support for tracing userland programs.
Summary of changes: * Implement a compatibility shim between Solaris libproc and our libproc and remove several ifdefs because of this. * Port the drti to FreeBSD. * Implement the missing DOODAD sections * Link with libproc and librtld_db * Support for ustack, jstack and uregs (by sson@) * Misc bugfixing When writing the SUWN_dof section, we had to resort to building the ELF file layout by "hand". This is the job of libelf, but our libelf doesn't support this yet. When libelf is fixed, we can remove the code under #ifdef BROKEN_LIBELF. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'cddl/contrib/opensolaris/cmd/dtrace')
-rw-r--r--cddl/contrib/opensolaris/cmd/dtrace/dtrace.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
index 2580e63..63721ab 100644
--- a/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
+++ b/cddl/contrib/opensolaris/cmd/dtrace/dtrace.c
@@ -773,19 +773,27 @@ compile_str(dtrace_cmd_t *dcp)
static void
prochandler(struct ps_prochandle *P, const char *msg, void *arg)
{
-fatal("DOODAD in function %s, file %s, line %d\n",__FUNCTION__,__FILE__,__LINE__);
-#ifdef DOODAD
+#if defined(sun)
const psinfo_t *prp = Ppsinfo(P);
int pid = Pstatus(P)->pr_pid;
char name[SIG2STR_MAX];
+#else
+ int wstatus = proc_getwstat(P);
+ int pid = proc_getpid(P);
+#endif
if (msg != NULL) {
notice("pid %d: %s\n", pid, msg);
return;
}
+#if defined(sun)
switch (Pstate(P)) {
+#else
+ switch (proc_state(P)) {
+#endif
case PS_UNDEAD:
+#if defined(sun)
/*
* Ideally we would like to always report pr_wstat here, but it
* isn't possible given current /proc semantics. If we grabbed
@@ -798,9 +806,20 @@ fatal("DOODAD in function %s, file %s, line %d\n",__FUNCTION__,__FILE__,__LINE__
notice("pid %d terminated by %s\n", pid,
proc_signame(WTERMSIG(prp->pr_wstat),
name, sizeof (name)));
+#else
+ if (WIFSIGNALED(wstatus)) {
+ notice("pid %d terminated by %d\n", pid,
+ WTERMSIG(wstatus));
+#endif
+#if defined(sun)
} else if (prp != NULL && WEXITSTATUS(prp->pr_wstat) != 0) {
notice("pid %d exited with status %d\n",
pid, WEXITSTATUS(prp->pr_wstat));
+#else
+ } else if (WEXITSTATUS(wstatus) != 0) {
+ notice("pid %d exited with status %d\n",
+ pid, WEXITSTATUS(wstatus));
+#endif
} else {
notice("pid %d has exited\n", pid);
}
@@ -812,7 +831,6 @@ fatal("DOODAD in function %s, file %s, line %d\n",__FUNCTION__,__FILE__,__LINE__
g_pslive--;
break;
}
-#endif
}
/*ARGSUSED*/
OpenPOWER on IntegriCloud