summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/opensolaris/lib/libdtrace/i386
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/lib/libdtrace/i386
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/lib/libdtrace/i386')
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c b/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
index c1484a4..ad1c032 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/i386/dt_isadep.c
@@ -35,6 +35,12 @@
#include <dis_tables.h>
+#if !defined(sun)
+#define PR_MODEL_ILP32 1
+#define PR_MODEL_LP64 2
+#include <libproc_compat.h>
+#endif
+
#define DT_POPL_EBP 0x5d
#define DT_RET 0xc3
#define DT_RET16 0xc2
@@ -78,8 +84,17 @@ dt_pid_has_jump_table(struct ps_prochandle *P, dtrace_hdl_t *dtp,
{
ulong_t i;
int size;
+#if defined(sun)
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
+#else
+ pid_t pid = proc_getpid(P);
+#if __i386__
+ char dmodel = PR_MODEL_ILP32;
+#elif __amd64__
+ char dmodel = PR_MODEL_LP64;
+#endif
+#endif
/*
* Take a pass through the function looking for a register-dependant
@@ -98,6 +113,7 @@ dt_pid_has_jump_table(struct ps_prochandle *P, dtrace_hdl_t *dtp,
return (1);
}
+#ifdef notyet
/*
* Register-dependant jmp instructions start with a 0xff byte
* and have the modrm.reg field set to 4. They can have an
@@ -110,6 +126,7 @@ dt_pid_has_jump_table(struct ps_prochandle *P, dtrace_hdl_t *dtp,
ftp->ftps_func, i);
return (1);
}
+#endif
}
return (0);
@@ -123,8 +140,17 @@ dt_pid_create_return_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
uint8_t *text;
ulong_t i, end;
int size;
+#if defined(sun)
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
+#else
+ pid_t pid = proc_getpid(P);
+#if __i386__
+ char dmodel = PR_MODEL_ILP32;
+#elif __amd64__
+ char dmodel = PR_MODEL_LP64;
+#endif
+#endif
/*
* We allocate a few extra bytes at the end so we don't have to check
@@ -275,8 +301,17 @@ dt_pid_create_offset_probe(struct ps_prochandle *P, dtrace_hdl_t *dtp,
uint8_t *text;
ulong_t i;
int size;
+#if defined(sun)
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
+#else
+ pid_t pid = proc_getpid(P);
+#if __i386__
+ char dmodel = PR_MODEL_ILP32;
+#elif __amd64__
+ char dmodel = PR_MODEL_LP64;
+#endif
+#endif
if ((text = malloc(symp->st_size)) == NULL) {
dt_dprintf("mr sparkle: malloc() failed\n");
@@ -349,8 +384,17 @@ dt_pid_create_glob_offset_probes(struct ps_prochandle *P, dtrace_hdl_t *dtp,
uint8_t *text;
int size;
ulong_t i, end = symp->st_size;
+#if defined(sun)
pid_t pid = Pstatus(P)->pr_pid;
char dmodel = Pstatus(P)->pr_dmodel;
+#else
+ pid_t pid = proc_getpid(P);
+#if __i386__
+ char dmodel = PR_MODEL_ILP32;
+#elif __amd64__
+ char dmodel = PR_MODEL_LP64;
+#endif
+#endif
ftp->ftps_type = DTFTP_OFFSETS;
ftp->ftps_pc = (uintptr_t)symp->st_value;
OpenPOWER on IntegriCloud