FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_sym.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: db_sym.h,v $
29 * Revision 2.7 93/01/14 17:25:50 danner
30 * Handle coexisting symtable types.
31 * 64bit cleanup, prototypes.
32 * [92/11/30 af]
33 *
34 * Revision 2.6 91/10/09 16:02:45 af
35 * Added macro definitions of db_find_task_sym_and_offset(),
36 * db_find_xtrn_task_sym_and_offset(), db_search_symbol().
37 * [91/08/29 tak]
38 *
39 * Revision 2.5 91/07/31 17:31:49 dbg
40 * Add map pointer and storage for name to db_symtab_t.
41 * [91/07/30 16:45:08 dbg]
42 *
43 * Revision 2.4 91/05/14 15:36:08 mrt
44 * Correcting copyright
45 *
46 * Revision 2.3 91/02/05 17:07:12 mrt
47 * Changed to new Mach copyright
48 * [91/01/31 16:19:27 mrt]
49 *
50 * Revision 2.2 90/08/27 21:52:39 dbg
51 * Changed type of db_sym_t to char * - it's a better type for an
52 * opaque pointer.
53 * [90/08/22 dbg]
54 *
55 * Created.
56 * [90/08/19 af]
57 *
58 */
59 /*
60 * Author: Alessandro Forin, Carnegie Mellon University
61 * Date: 8/90
62 */
63
64 #include <mach/boolean.h>
65 #include <mach/machine/vm_types.h>
66 #include <machine/db_machdep.h>
67
68 /*
69 * This module can handle multiple symbol tables,
70 * of multiple types, at the same time
71 */
72 #define SYMTAB_NAME_LEN 32
73
74 typedef struct {
75 int type;
76 #define SYMTAB_AOUT 0
77 #define SYMTAB_COFF 1
78 #define SYMTAB_MACHDEP 2
79 char *start; /* symtab location */
80 char *end;
81 char *private; /* optional machdep pointer */
82 char *map_pointer; /* symbols are for this map only,
83 if not null */
84 char name[SYMTAB_NAME_LEN];
85 /* symtab name */
86 } db_symtab_t;
87
88 extern db_symtab_t *db_last_symtab; /* where last symbol was found */
89
90 /*
91 * Symbol representation is specific to the symtab style:
92 * BSD compilers use dbx' nlist, other compilers might use
93 * a different one
94 */
95 typedef char * db_sym_t; /* opaque handle on symbols */
96 #define DB_SYM_NULL ((db_sym_t)0)
97
98 /*
99 * Non-stripped symbol tables will have duplicates, for instance
100 * the same string could match a parameter name, a local var, a
101 * global var, etc.
102 * We are most concerned with the following matches.
103 */
104 typedef int db_strategy_t; /* search strategy */
105
106 #define DB_STGY_ANY 0 /* anything goes */
107 #define DB_STGY_XTRN 1 /* only external symbols */
108 #define DB_STGY_PROC 2 /* only procedures */
109
110 extern boolean_t db_qualify_ambiguous_names;
111 /* if TRUE, check across symbol tables
112 * for multiple occurrences of a name.
113 * Might slow down quite a bit
114 * ..but the machine has nothing
115 * else to do, now does it ? */
116
117 /*
118 * Functions exported by the symtable module
119 */
120
121 /* extend the list of symbol tables */
122
123 extern boolean_t db_add_symbol_table( int type,
124 char * start,
125 char * end,
126 char *name,
127 char *ref,
128 char *map_pointer );
129
130 /* find symbol value given name */
131
132 extern int db_value_of_name( char* name, db_expr_t* valuep);
133
134 /* find symbol given value */
135
136 extern db_sym_t db_search_task_symbol( db_addr_t val,
137 db_strategy_t strategy,
138 db_addr_t *offp,
139 task_t task );
140
141 /* return name and value of symbol */
142
143 extern void db_symbol_values( db_symtab_t *stab,
144 db_sym_t sym,
145 char** namep,
146 db_expr_t* valuep);
147
148 /* find name&value given approx val */
149
150 #define db_find_sym_and_offset(val,namep,offp) \
151 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
152
153 /* ditto, but no locals */
154 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
155 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
156
157 /* find name&value given approx val */
158
159 #define db_find_task_sym_and_offset(val,namep,offp,task) \
160 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
161 namep, 0)
162
163 /* ditto, but no locals */
164 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
165 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
166 namep,0)
167
168 /* find symbol in current task */
169 #define db_search_symbol(val,strgy,offp) \
170 db_search_task_symbol(val,strgy,offp,0)
171
172 /* strcmp, modulo leading char */
173 extern boolean_t db_eqname( char* src, char* dst, char c );
174
175 /* print closest symbol to a value */
176 extern void db_task_printsym( db_expr_t off,
177 db_strategy_t strategy,
178 task_t task);
179
180 /* print closest symbol to a value */
181 extern void db_printsym( db_expr_t off, db_strategy_t strategy);
182
183 /*
184 * Symbol table switch, defines the interface
185 * to symbol-table specific routines.
186 * [NOTE: incomplete prototypes cuz broken compiler]
187 */
188
189 extern struct db_sym_switch {
190
191 boolean_t (*init)(
192 /* char *start,
193 char *end,
194 char *name,
195 char *task_addr
196 */ );
197
198 db_sym_t (*lookup)(
199 /* db_symtab_t *stab,
200 char *symstr
201 */ );
202 db_sym_t (*search_symbol)(
203 /* db_symtab_t *stab,
204 db_addr_t off,
205 db_strategy_t strategy,
206 db_expr_t *diffp
207 */ );
208
209 boolean_t (*line_at_pc)(
210 /* db_symtab_t *stab,
211 db_sym_t sym,
212 char **file,
213 int *line,
214 db_expr_t pc
215 */ );
216
217 void (*symbol_values)(
218 /* db_sym_t sym,
219 char **namep,
220 db_expr_t *valuep
221 */ );
222
223 } x_db[];
224
225 #ifndef symtab_type
226 #define symtab_type(s) SYMTAB_AOUT
227 #endif
228
229 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].init(s,e,n,t)
230 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
231 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
232 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
233 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
Cache object: f79fe274b9723641d7400165767ad264
|