]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. | |
7 | * | |
8 | * This file contains Original Code and/or Modifications of Original Code | |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
22 | * | |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * HISTORY | |
30 | * | |
31 | * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez | |
32 | * Import of Mac OS X kernel (~semeria) | |
33 | * | |
34 | * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez | |
35 | * Import of OSF Mach kernel (~mburg) | |
36 | * | |
37 | * Revision 1.2.20.6 1996/01/09 19:16:22 devrcs | |
38 | * Add proto for db_task_getlinenum(). | |
39 | * [1995/12/01 21:42:34 jfraser] | |
40 | * | |
41 | * Revision 1.2.20.5 1995/02/28 01:58:53 dwm | |
42 | * Merged with changes from 1.2.20.4 | |
43 | * [1995/02/28 01:53:54 dwm] | |
44 | * | |
45 | * mk6 CR1120 - Merge mk6pro_shared into cnmk_shared | |
46 | * [1995/02/28 01:12:57 dwm] | |
47 | * | |
48 | * Revision 1.2.20.4 1995/02/23 21:43:48 alanl | |
49 | * Prepend a "db_" to qsort and qsort_limit_search | |
50 | * (collisions with the real qsort in stdlib.h) | |
51 | * [95/02/14 travos] | |
52 | * | |
53 | * Expanded db_sym_switch structure to make ddb object format dependent; | |
54 | * this allows us to remove all of the aout dependencies. | |
55 | * [95/01/24 sjs] | |
56 | * | |
57 | * Revision 1.2.23.4 1994/12/22 20:36:20 bolinger | |
58 | * Fix ri-osc CR881: Fixed glitch in use of symtab cloning hack. | |
59 | * [1994/12/22 20:35:17 bolinger] | |
60 | * | |
61 | * Revision 1.2.23.3 1994/11/02 18:36:07 dwm | |
62 | * mk6 CR668 - 1.3b26 merge | |
63 | * 64bit cleanup, prototypes | |
64 | * fix X_db_search_by_addr macro to match prototype | |
65 | * [1994/11/02 18:16:20 dwm] | |
66 | * | |
67 | * Revision 1.2.20.4 1995/02/23 21:43:48 alanl | |
68 | * Prepend a "db_" to qsort and qsort_limit_search | |
69 | * (collisions with the real qsort in stdlib.h) | |
70 | * [95/02/14 travos] | |
71 | * | |
72 | * Expanded db_sym_switch structure to make ddb object format dependent; | |
73 | * this allows us to remove all of the aout dependencies. | |
74 | * [95/01/24 sjs] | |
75 | * | |
76 | * Revision 1.2.23.4 1994/12/22 20:36:20 bolinger | |
77 | * Fix ri-osc CR881: Fixed glitch in use of symtab cloning hack. | |
78 | * [1994/12/22 20:35:17 bolinger] | |
79 | * | |
80 | * Revision 1.2.23.3 1994/11/02 18:36:07 dwm | |
81 | * mk6 CR668 - 1.3b26 merge | |
82 | * 64bit cleanup, prototypes | |
83 | * fix X_db_search_by_addr macro to match prototype | |
84 | * [1994/11/02 18:16:20 dwm] | |
85 | * | |
86 | * Revision 1.2.20.2 1994/09/23 01:21:51 ezf | |
87 | * change marker to not FREE | |
88 | * [1994/09/22 21:11:04 ezf] | |
89 | * | |
90 | * Revision 1.2.20.1 1994/06/11 21:12:25 bolinger | |
91 | * Merge up to NMK17.2. | |
92 | * [1994/06/11 20:04:14 bolinger] | |
93 | * | |
94 | * Revision 1.2.14.1 1994/02/08 10:58:56 bernadat | |
95 | * Added db_sym_print_completion | |
96 | * db_sym_parse_and_lookup_incomplete | |
97 | * db_sym_parse_and_print_completion | |
98 | * db_print_completion | |
99 | * db_lookup_incomplete | |
100 | * ddb_init | |
101 | * prototypes | |
102 | * | |
103 | * Changed func type to db_sym_parse_and_lookup prototype | |
104 | * | |
105 | * Added definition of db_maxoff. | |
106 | * [93/08/12 paire] | |
107 | * [94/02/07 bernadat] | |
108 | * | |
109 | * Revision 1.2.18.1 1994/06/08 19:11:28 dswartz | |
110 | * Preemption merge. | |
111 | * [1994/06/08 19:10:27 dswartz] | |
112 | * | |
113 | * Revision 1.2.17.2 1994/06/01 21:34:50 klj | |
114 | * Initial preemption code base merge | |
115 | * | |
116 | * Revision 1.2.4.3 1993/07/27 18:28:12 elliston | |
117 | * Add ANSI prototypes. CR #9523. | |
118 | * [1993/07/27 18:13:02 elliston] | |
119 | * | |
120 | * Revision 1.2.4.2 1993/06/09 02:20:56 gm | |
121 | * Added to OSF/1 R1.3 from NMK15.0. | |
122 | * [1993/06/02 20:57:18 jeffc] | |
123 | * | |
124 | * Revision 1.2 1993/04/19 16:03:18 devrcs | |
125 | * Added 3 new fields in db_symtab_t for sorting. | |
126 | * [barbou@gr.osf.org] | |
127 | * [92/12/03 bernadat] | |
128 | * | |
129 | * Revision 1.1 1992/09/30 02:24:22 robert | |
130 | * Initial revision | |
131 | * | |
132 | * $EndLog$ | |
133 | */ | |
134 | /* CMU_HIST */ | |
135 | /* | |
136 | * Revision 2.6 91/10/09 16:02:45 af | |
137 | * Revision 2.5.1.1 91/10/05 13:07:39 jeffreyh | |
138 | * Added macro definitions of db_find_task_sym_and_offset(), | |
139 | * db_find_xtrn_task_sym_and_offset(), db_search_symbol(). | |
140 | * [91/08/29 tak] | |
141 | * | |
142 | * Revision 2.5.1.1 91/10/05 13:07:39 jeffreyh | |
143 | * Added macro definitions of db_find_task_sym_and_offset(), | |
144 | * db_find_xtrn_task_sym_and_offset(), db_search_symbol(). | |
145 | * [91/08/29 tak] | |
146 | * | |
147 | * Revision 2.5 91/07/31 17:31:49 dbg | |
148 | * Add map pointer and storage for name to db_symtab_t. | |
149 | * [91/07/30 16:45:08 dbg] | |
150 | * | |
151 | * Revision 2.4 91/05/14 15:36:08 mrt | |
152 | * Correcting copyright | |
153 | * | |
154 | * Revision 2.3 91/02/05 17:07:12 mrt | |
155 | * Changed to new Mach copyright | |
156 | * [91/01/31 16:19:27 mrt] | |
157 | * | |
158 | * Revision 2.2 90/08/27 21:52:39 dbg | |
159 | * Changed type of db_sym_t to char * - it's a better type for an | |
160 | * opaque pointer. | |
161 | * [90/08/22 dbg] | |
162 | * | |
163 | * Created. | |
164 | * [90/08/19 af] | |
165 | * | |
166 | */ | |
167 | /* CMU_ENDHIST */ | |
168 | /* | |
169 | * Mach Operating System | |
170 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
171 | * All Rights Reserved. | |
172 | * | |
173 | * Permission to use, copy, modify and distribute this software and its | |
174 | * documentation is hereby granted, provided that both the copyright | |
175 | * notice and this permission notice appear in all copies of the | |
176 | * software, derivative works or modified versions, and any portions | |
177 | * thereof, and that both notices appear in supporting documentation. | |
178 | * | |
179 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
180 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
181 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
182 | * | |
183 | * Carnegie Mellon requests users of this software to return to | |
184 | * | |
185 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
186 | * School of Computer Science | |
187 | * Carnegie Mellon University | |
188 | * Pittsburgh PA 15213-3890 | |
189 | * | |
190 | * any improvements or extensions that they make and grant Carnegie Mellon | |
191 | * the rights to redistribute these changes. | |
192 | */ | |
193 | /* | |
194 | */ | |
195 | /* | |
196 | * Author: Alessandro Forin, Carnegie Mellon University | |
197 | * Date: 8/90 | |
198 | */ | |
199 | ||
200 | #ifndef _DDB_DB_SYM_H_ | |
201 | #define _DDB_DB_SYM_H_ | |
202 | ||
203 | #include <mach/boolean.h> | |
204 | #include <mach/machine/vm_types.h> | |
205 | #include <machine/db_machdep.h> | |
206 | #include <kern/task.h> | |
207 | ||
208 | /* | |
209 | * This module can handle multiple symbol tables, | |
210 | * of multiple types, at the same time | |
211 | */ | |
212 | #define SYMTAB_NAME_LEN 32 | |
213 | ||
214 | typedef struct { | |
215 | int type; | |
216 | #define SYMTAB_AOUT 0 | |
217 | #define SYMTAB_COFF 1 | |
218 | #define SYMTAB_MACHDEP 2 | |
219 | char *start; /* symtab location */ | |
220 | char *end; | |
221 | char *private; /* optional machdep pointer */ | |
222 | char *map_pointer; /* symbols are for this map only, | |
223 | if not null */ | |
224 | char name[SYMTAB_NAME_LEN]; | |
225 | /* symtab name */ | |
226 | unsigned long minsym; /* lowest symbol value */ | |
227 | unsigned long maxsym; /* highest symbol value */ | |
228 | boolean_t sorted; /* is this table sorted ? */ | |
229 | } db_symtab_t; | |
230 | ||
231 | extern db_symtab_t *db_last_symtab; /* where last symbol was found */ | |
232 | ||
233 | /* | |
234 | * Symbol representation is specific to the symtab style: | |
235 | * BSD compilers use dbx' nlist, other compilers might use | |
236 | * a different one | |
237 | */ | |
238 | typedef void * db_sym_t; /* opaque handle on symbols */ | |
239 | #define DB_SYM_NULL ((db_sym_t)0) | |
240 | ||
241 | /* | |
242 | * Non-stripped symbol tables will have duplicates, for instance | |
243 | * the same string could match a parameter name, a local var, a | |
244 | * global var, etc. | |
245 | * We are most concern with the following matches. | |
246 | */ | |
247 | typedef int db_strategy_t; /* search strategy */ | |
248 | ||
249 | #define DB_STGY_ANY 0 /* anything goes */ | |
250 | #define DB_STGY_XTRN 1 /* only external symbols */ | |
251 | #define DB_STGY_PROC 2 /* only procedures */ | |
252 | ||
253 | extern boolean_t db_qualify_ambiguous_names; | |
254 | /* if TRUE, check across symbol tables | |
255 | * for multiple occurrences of a name. | |
256 | * Might slow down quite a bit */ | |
257 | ||
258 | extern unsigned long db_maxoff; | |
259 | ||
260 | /* Prototypes for functions exported by this module. | |
261 | */ | |
262 | extern boolean_t db_add_symbol_table( | |
263 | int type, | |
264 | char *start, | |
265 | char *end, | |
266 | char *name, | |
267 | char *ref, | |
268 | char *map_pointer, | |
269 | unsigned long minsym, | |
270 | unsigned long maxsym, | |
271 | boolean_t sorted); | |
272 | ||
273 | extern void db_install_inks( | |
274 | vm_offset_t base); | |
275 | ||
276 | extern boolean_t db_value_of_name( | |
277 | char *name, | |
278 | db_expr_t *valuep); | |
279 | ||
280 | extern db_sym_t db_lookup(char *symstr); | |
281 | ||
282 | extern char * db_get_sym( | |
283 | db_expr_t * off); | |
284 | ||
285 | extern db_sym_t db_sym_parse_and_lookup( | |
286 | int (*func)(db_symtab_t *, | |
287 | char *, | |
288 | char *, | |
289 | int, | |
290 | db_sym_t*, | |
291 | char **, | |
292 | int *), | |
293 | db_symtab_t *symtab, | |
294 | char *symstr); | |
295 | ||
296 | extern int db_sym_parse_and_lookup_incomplete( | |
297 | int (*func)(db_symtab_t *, | |
298 | char *, | |
299 | char *, | |
300 | int, | |
301 | db_sym_t*, | |
302 | char **, | |
303 | int *), | |
304 | db_symtab_t *symtab, | |
305 | char *symstr, | |
306 | char **name, | |
307 | int *len, | |
308 | int *toadd); | |
309 | ||
310 | extern int db_sym_parse_and_print_completion( | |
311 | int (*func)(db_symtab_t *, | |
312 | char *), | |
313 | db_symtab_t *symtab, | |
314 | char *symstr); | |
315 | ||
316 | extern db_sym_t db_search_task_symbol( | |
317 | db_addr_t val, | |
318 | db_strategy_t strategy, | |
319 | db_addr_t *offp, | |
320 | task_t task); | |
321 | ||
322 | extern db_sym_t db_search_task_symbol_and_line( | |
323 | db_addr_t val, | |
324 | db_strategy_t strategy, | |
325 | db_expr_t *offp, | |
326 | char **filenamep, | |
327 | int *linenump, | |
328 | task_t task, | |
329 | int *argsp); | |
330 | ||
331 | extern void db_symbol_values( | |
332 | db_symtab_t *stab, | |
333 | db_sym_t sym, | |
334 | char **namep, | |
335 | db_expr_t *valuep); | |
336 | ||
337 | extern void db_task_printsym( | |
338 | db_expr_t off, | |
339 | db_strategy_t strategy, | |
340 | task_t task); | |
341 | ||
342 | extern void db_printsym( | |
343 | db_expr_t off, | |
344 | db_strategy_t strategy); | |
345 | ||
346 | extern boolean_t db_line_at_pc( | |
347 | db_sym_t sym, | |
348 | char **filename, | |
349 | int *linenum, | |
350 | db_expr_t pc); | |
351 | ||
352 | extern void db_qsort( | |
353 | char *table, | |
354 | int nbelts, | |
355 | int eltsize, | |
356 | int (*compfun)(char *, char *)); | |
357 | ||
358 | extern void db_qsort_limit_search( | |
359 | char *target, | |
360 | char **start, | |
361 | char **end, | |
362 | int eltsize, | |
363 | int (*compfun)(char *, char *)); | |
364 | ||
365 | extern void db_sym_print_completion( | |
366 | db_symtab_t *stab, | |
367 | char *name, | |
368 | int function, | |
369 | char *fname, | |
370 | int line); | |
371 | ||
372 | extern void db_print_completion( | |
373 | char *symstr); | |
374 | ||
375 | extern int db_lookup_incomplete( | |
376 | char *symstr, | |
377 | int symlen); | |
378 | ||
379 | extern void ddb_init(void); | |
380 | ||
381 | extern void db_machdep_init(void); | |
382 | ||
383 | extern void db_clone_symtabXXX(char *, char *, vm_offset_t); | |
384 | ||
385 | extern db_symtab_t *db_symtab_cloneeXXX(char *); | |
386 | ||
387 | extern db_task_getlinenum( db_expr_t, task_t); | |
388 | ||
389 | /* Some convenience macros. | |
390 | */ | |
391 | #define db_find_sym_and_offset(val,namep,offp) \ | |
392 | db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0) | |
393 | /* find name&value given approx val */ | |
394 | ||
395 | #define db_find_xtrn_sym_and_offset(val,namep,offp) \ | |
396 | db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0) | |
397 | /* ditto, but no locals */ | |
398 | ||
399 | #define db_find_task_sym_and_offset(val,namep,offp,task) \ | |
400 | db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \ | |
401 | namep, 0) /* find name&value given approx val */ | |
402 | ||
403 | #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \ | |
404 | db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \ | |
405 | namep,0) /* ditto, but no locals */ | |
406 | ||
407 | #define db_search_symbol(val,strgy,offp) \ | |
408 | db_search_task_symbol(val,strgy,offp,0) | |
409 | /* find symbol in current task */ | |
410 | ||
411 | /* | |
412 | * Symbol table switch, defines the interface | |
413 | * to symbol-table specific routines. | |
414 | */ | |
415 | ||
416 | extern struct db_sym_switch { | |
417 | ||
418 | void (*init)(void); | |
419 | ||
420 | boolean_t (*sym_init)( | |
421 | char *start, | |
422 | char *end, | |
423 | char *name, | |
424 | char *task_addr | |
425 | ); | |
426 | ||
427 | db_sym_t (*lookup)( | |
428 | db_symtab_t *stab, | |
429 | char *symstr | |
430 | ); | |
431 | db_sym_t (*search_symbol)( | |
432 | db_symtab_t *stab, | |
433 | db_addr_t off, | |
434 | db_strategy_t strategy, | |
435 | db_expr_t *diffp | |
436 | ); | |
437 | ||
438 | boolean_t (*line_at_pc)( | |
439 | db_symtab_t *stab, | |
440 | db_sym_t sym, | |
441 | char **file, | |
442 | int *line, | |
443 | db_expr_t pc | |
444 | ); | |
445 | ||
446 | void (*symbol_values)( | |
447 | db_sym_t sym, | |
448 | char **namep, | |
449 | db_expr_t *valuep | |
450 | ); | |
451 | db_sym_t (*search_by_addr)( | |
452 | db_symtab_t *stab, | |
453 | db_addr_t off, | |
454 | char **file, | |
455 | char **func, | |
456 | int *line, | |
457 | db_expr_t *diffp, | |
458 | int *args | |
459 | ); | |
460 | ||
461 | int (*print_completion)( | |
462 | db_symtab_t *stab, | |
463 | char *symstr | |
464 | ); | |
465 | ||
466 | int (*lookup_incomplete)( | |
467 | db_symtab_t *stab, | |
468 | char *symstr, | |
469 | char **name, | |
470 | int *len, | |
471 | int *toadd | |
472 | ); | |
473 | } x_db[]; | |
474 | ||
475 | #ifndef symtab_type | |
476 | #define symtab_type(s) SYMTAB_AOUT | |
477 | #endif | |
478 | ||
479 | #define X_db_init() x_db[symtab_type(s)].init() | |
480 | #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t) | |
481 | #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n) | |
482 | #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d) | |
483 | #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a) | |
484 | #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v) | |
485 | #define X_db_search_by_addr(s,a,f,c,l,d,r) \ | |
486 | x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r) | |
487 | #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p) | |
488 | #define X_db_lookup_incomplete(s,p,n,l,t) \ | |
489 | x_db[(s)->type].lookup_incomplete(s,p,n,l,t) | |
490 | ||
491 | #endif /* !_DDB_DB_SYM_H_ */ |