]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - lib/librtld_db/rtld_db.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / lib / librtld_db / rtld_db.h
1 /*
2  * Copyright (c) 2010 The FreeBSD Foundation 
3  * All rights reserved. 
4  * 
5  * This software was developed by Rui Paulo under sponsorship from the
6  * FreeBSD Foundation. 
7  *  
8  * Redistribution and use in source and binary forms, with or without 
9  * modification, are permitted provided that the following conditions 
10  * are met: 
11  * 1. Redistributions of source code must retain the above copyright 
12  *    notice, this list of conditions and the following disclaimer. 
13  * 2. Redistributions in binary form must reproduce the above copyright 
14  *    notice, this list of conditions and the following disclaimer in the 
15  *    documentation and/or other materials provided with the distribution. 
16  * 
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
27  * SUCH DAMAGE. 
28  *
29  * $FreeBSD$
30  */ 
31
32 #ifndef _RTLD_DB_H_
33 #define _RTLD_DB_H_
34
35 #include <sys/param.h>
36 #include <sys/cdefs.h>
37 #include <sys/types.h>
38
39
40 #define RD_VERSION      1
41
42 typedef enum {
43         RD_OK,
44         RD_ERR,
45         RD_DBERR,
46         RD_NOCAPAB,
47         RD_NODYNAM,
48         RD_NOBASE,
49         RD_NOMAPS
50 } rd_err_e;
51
52 typedef struct rd_agent {
53         struct proc_handle *rda_php;
54         uintptr_t rda_addr;             /* address of r_debug_state */
55 } rd_agent_t;
56
57 typedef struct rd_loadobj {
58         uintptr_t       rdl_saddr;              /* start address */
59         uintptr_t       rdl_eaddr;              /* end address */
60         uint32_t        rdl_offset;
61         uint8_t         rdl_prot;
62 #define RD_RDL_R        0x01
63 #define RD_RDL_W        0x02
64 #define RD_RDL_X        0x04
65         enum {
66                 RDL_TYPE_NONE   = 0,
67                 RDL_TYPE_DEF,
68                 RDL_TYPE_VNODE,
69                 RDL_TYPE_SWAP,
70                 RDL_TYPE_DEV,
71                 /* XXX some types missing */
72                 RDL_TYPE_UNKNOWN = 255
73         } rdl_type;
74         unsigned char   rdl_path[PATH_MAX];
75 } rd_loadobj_t;
76
77 typedef enum {
78         RD_NONE = 0,
79         RD_PREINIT,
80         RD_POSTINIT,
81         RD_DLACTIVITY
82 } rd_event_e;
83
84 typedef enum {
85         RD_NOTIFY_BPT,
86         RD_NOTIFY_AUTOBPT,
87         RD_NOTIFY_SYSCALL
88 } rd_notify_e;
89
90 typedef struct rd_notify {
91         rd_notify_e type;
92         union {
93                 uintptr_t bptaddr;
94                 long      syscallno;
95         } u;
96 } rd_notify_t;
97
98 typedef enum {
99         RD_NOSTATE = 0,
100         RD_CONSISTENT,
101         RD_ADD,
102         RD_DELETE
103 } rd_state_e;
104
105 typedef struct rd_event_msg {
106         rd_event_e type;
107         union {
108                 rd_state_e state;
109         } u;
110 } rd_event_msg_t;
111
112 typedef enum {
113         RD_RESOLVE_NONE,
114         RD_RESOLVE_STEP,
115         RD_RESOLVE_TARGET,
116         RD_RESOLVE_TARGET_STEP
117 } rd_skip_e;
118
119 typedef struct rd_plt_info {
120         rd_skip_e pi_skip_method;
121         long      pi_nstep;
122         uintptr_t pi_target;
123         uintptr_t pi_baddr;
124         unsigned int pi_flags;
125 } rd_plt_info_t;
126
127 #define RD_FLG_PI_PLTBOUND      0x0001
128
129 __BEGIN_DECLS
130
131 struct proc_handle;
132 void            rd_delete(rd_agent_t *);
133 const char      *rd_errstr(rd_err_e);
134 rd_err_e        rd_event_addr(rd_agent_t *, rd_event_e, rd_notify_t *);
135 rd_err_e        rd_event_enable(rd_agent_t *, int);
136 rd_err_e        rd_event_getmsg(rd_agent_t *, rd_event_msg_t *);
137 rd_err_e        rd_init(int);
138 typedef int rl_iter_f(const rd_loadobj_t *, void *);
139 rd_err_e        rd_loadobj_iter(rd_agent_t *, rl_iter_f *, void *);
140 void            rd_log(const int);
141 rd_agent_t      *rd_new(struct proc_handle *);
142 rd_err_e        rd_objpad_enable(rd_agent_t *, size_t);
143 struct proc;
144 rd_err_e        rd_plt_resolution(rd_agent_t *, uintptr_t, struct proc *,
145                     uintptr_t, rd_plt_info_t *);
146 rd_err_e        rd_reset(rd_agent_t *);
147
148 __END_DECLS
149
150 #endif /* _RTLD_DB_H_ */