diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2010-08-21 11:50:53 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2010-08-21 11:50:53 +0000 |
commit | b325e69c9282072ea3b203319017abc400db4771 (patch) | |
tree | ae5b6066f0143ecb034e8de394e160841cd4f84f /cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c | |
parent | 232561a60dcdeeffd316d29086bb31f2e12d7591 (diff) | |
download | FreeBSD-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/lib/libdtrace/common/dt_consume.c')
-rw-r--r-- | cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c index c8ac6b0..911478e 100644 --- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c +++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_consume.c @@ -34,6 +34,9 @@ #include <alloca.h> #endif #include <dt_impl.h> +#if !defined(sun) +#include <libproc_compat.h> +#endif #define DT_MASK_LO 0x00000000FFFFFFFFULL @@ -952,17 +955,9 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, 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), @@ -973,12 +968,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 @@ -994,11 +985,7 @@ 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) { (void) snprintf(c, sizeof (c), "%s`0x%llx", dt_basename(objname), (u_longlong_t)pc[i]); @@ -1068,11 +1055,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); @@ -1115,11 +1098,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 (void) snprintf(c, sizeof (c), "%s", dt_basename(objname)); } else { (void) snprintf(c, sizeof (c), "0x%llx", (u_longlong_t)pc); |