summaryrefslogtreecommitdiffstats
path: root/lib/librtld_db/rtld_db.h
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2010-07-31 14:26:10 +0000
committerrpaulo <rpaulo@FreeBSD.org>2010-07-31 14:26:10 +0000
commit27277244cd333006d5d010f8047d83a3a8a402c1 (patch)
treeef3df8ba55e73337ce46c4ed406e22517fdf8b3c /lib/librtld_db/rtld_db.h
parent0ccd4521f0bf896c3176bea8d48fb1f02d4c45de (diff)
downloadFreeBSD-src-27277244cd333006d5d010f8047d83a3a8a402c1.zip
FreeBSD-src-27277244cd333006d5d010f8047d83a3a8a402c1.tar.gz
Import the librtld_db library. This is needed by userland DTrace.
This is not yet enabled in the build because I also need to import a new version of libproc. Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/librtld_db/rtld_db.h')
-rw-r--r--lib/librtld_db/rtld_db.h150
1 files changed, 150 insertions, 0 deletions
diff --git a/lib/librtld_db/rtld_db.h b/lib/librtld_db/rtld_db.h
new file mode 100644
index 0000000..33da4d3
--- /dev/null
+++ b/lib/librtld_db/rtld_db.h
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2010 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Rui Paulo under sponsorship from the
+ * FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _RTLD_DB_H_
+#define _RTLD_DB_H_
+
+#include <sys/param.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+
+#define RD_VERSION 1
+
+typedef enum {
+ RD_OK,
+ RD_ERR,
+ RD_DBERR,
+ RD_NOCAPAB,
+ RD_NODYNAM,
+ RD_NOBASE,
+ RD_NOMAPS
+} rd_err_e;
+
+typedef struct rd_agent {
+ struct proc_handle *rda_php;
+ uintptr_t rda_addr; /* address of r_debug_state */
+} rd_agent_t;
+
+typedef struct rd_loadobj {
+ uintptr_t rdl_saddr; /* start address */
+ uintptr_t rdl_eaddr; /* end address */
+ uint32_t rdl_offset;
+ uint8_t rdl_prot;
+#define RD_RDL_R 0x01
+#define RD_RDL_W 0x02
+#define RD_RDL_X 0x04
+ enum {
+ RDL_TYPE_NONE = 0,
+ RDL_TYPE_DEF,
+ RDL_TYPE_VNODE,
+ RDL_TYPE_SWAP,
+ RDL_TYPE_DEV,
+ /* XXX some types missing */
+ RDL_TYPE_UNKNOWN = 255
+ } rdl_type;
+ unsigned char rdl_path[PATH_MAX];
+} rd_loadobj_t;
+
+typedef enum {
+ RD_NONE = 0,
+ RD_PREINIT,
+ RD_POSTINIT,
+ RD_DLACTIVITY
+} rd_event_e;
+
+typedef enum {
+ RD_NOTIFY_BPT,
+ RD_NOTIFY_AUTOBPT,
+ RD_NOTIFY_SYSCALL
+} rd_notify_e;
+
+typedef struct rd_notify {
+ rd_notify_e type;
+ union {
+ uintptr_t bptaddr;
+ long syscallno;
+ } u;
+} rd_notify_t;
+
+typedef enum {
+ RD_NOSTATE = 0,
+ RD_CONSISTENT,
+ RD_ADD,
+ RD_DELETE
+} rd_state_e;
+
+typedef struct rd_event_msg {
+ rd_event_e type;
+ union {
+ rd_state_e state;
+ } u;
+} rd_event_msg_t;
+
+typedef enum {
+ RD_RESOLVE_NONE,
+ RD_RESOLVE_STEP,
+ RD_RESOLVE_TARGET,
+ RD_RESOLVE_TARGET_STEP
+} rd_skip_e;
+
+typedef struct rd_plt_info {
+ rd_skip_e pi_skip_method;
+ long pi_nstep;
+ uintptr_t pi_target;
+ uintptr_t pi_baddr;
+ unsigned int pi_flags;
+} rd_plt_info_t;
+
+#define RD_FLG_PI_PLTBOUND 0x0001
+
+__BEGIN_DECLS
+
+struct proc_handle;
+void rd_delete(rd_agent_t *);
+const char *rd_errstr(rd_err_e);
+rd_err_e rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *);
+rd_err_e rd_event_enable(rd_agent_t *, int);
+rd_err_e rd_event_getmsg(rd_agent_t *, rd_event_msg_t *);
+rd_err_e rd_init(int);
+typedef int rl_iter_f(const rd_loadobj_t *, void *);
+rd_err_e rd_loadobj_iter(rd_agent_t *, rl_iter_f *, void *);
+void rd_log(const int);
+rd_agent_t *rd_new(struct proc_handle *);
+rd_err_e rd_objpad_enable(rd_agent_t *, size_t);
+struct proc;
+rd_err_e rd_plt_resolution(rd_agent_t *, uintptr_t, struct proc *,
+ uintptr_t, rd_plt_info_t *);
+rd_err_e rd_reset(rd_agent_t *);
+
+__END_DECLS
+
+#endif /* _RTLD_DB_H_ */
OpenPOWER on IntegriCloud