2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
28 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
29 * Import of Mac OS X kernel (~semeria)
31 * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
32 * Import of OSF Mach kernel (~mburg)
34 * Revision 1.2.20.6 1996/01/09 19:16:22 devrcs
35 * Add proto for db_task_getlinenum().
36 * [1995/12/01 21:42:34 jfraser]
38 * Revision 1.2.20.5 1995/02/28 01:58:53 dwm
39 * Merged with changes from 1.2.20.4
40 * [1995/02/28 01:53:54 dwm]
42 * mk6 CR1120 - Merge mk6pro_shared into cnmk_shared
43 * [1995/02/28 01:12:57 dwm]
45 * Revision 1.2.20.4 1995/02/23 21:43:48 alanl
46 * Prepend a "db_" to qsort and qsort_limit_search
47 * (collisions with the real qsort in stdlib.h)
50 * Expanded db_sym_switch structure to make ddb object format dependent;
51 * this allows us to remove all of the aout dependencies.
54 * Revision 1.2.23.4 1994/12/22 20:36:20 bolinger
55 * Fix ri-osc CR881: Fixed glitch in use of symtab cloning hack.
56 * [1994/12/22 20:35:17 bolinger]
58 * Revision 1.2.23.3 1994/11/02 18:36:07 dwm
59 * mk6 CR668 - 1.3b26 merge
60 * 64bit cleanup, prototypes
61 * fix X_db_search_by_addr macro to match prototype
62 * [1994/11/02 18:16:20 dwm]
64 * Revision 1.2.20.4 1995/02/23 21:43:48 alanl
65 * Prepend a "db_" to qsort and qsort_limit_search
66 * (collisions with the real qsort in stdlib.h)
69 * Expanded db_sym_switch structure to make ddb object format dependent;
70 * this allows us to remove all of the aout dependencies.
73 * Revision 1.2.23.4 1994/12/22 20:36:20 bolinger
74 * Fix ri-osc CR881: Fixed glitch in use of symtab cloning hack.
75 * [1994/12/22 20:35:17 bolinger]
77 * Revision 1.2.23.3 1994/11/02 18:36:07 dwm
78 * mk6 CR668 - 1.3b26 merge
79 * 64bit cleanup, prototypes
80 * fix X_db_search_by_addr macro to match prototype
81 * [1994/11/02 18:16:20 dwm]
83 * Revision 1.2.20.2 1994/09/23 01:21:51 ezf
84 * change marker to not FREE
85 * [1994/09/22 21:11:04 ezf]
87 * Revision 1.2.20.1 1994/06/11 21:12:25 bolinger
88 * Merge up to NMK17.2.
89 * [1994/06/11 20:04:14 bolinger]
91 * Revision 1.2.14.1 1994/02/08 10:58:56 bernadat
92 * Added db_sym_print_completion
93 * db_sym_parse_and_lookup_incomplete
94 * db_sym_parse_and_print_completion
96 * db_lookup_incomplete
100 * Changed func type to db_sym_parse_and_lookup prototype
102 * Added definition of db_maxoff.
104 * [94/02/07 bernadat]
106 * Revision 1.2.18.1 1994/06/08 19:11:28 dswartz
108 * [1994/06/08 19:10:27 dswartz]
110 * Revision 1.2.17.2 1994/06/01 21:34:50 klj
111 * Initial preemption code base merge
113 * Revision 1.2.4.3 1993/07/27 18:28:12 elliston
114 * Add ANSI prototypes. CR #9523.
115 * [1993/07/27 18:13:02 elliston]
117 * Revision 1.2.4.2 1993/06/09 02:20:56 gm
118 * Added to OSF/1 R1.3 from NMK15.0.
119 * [1993/06/02 20:57:18 jeffc]
121 * Revision 1.2 1993/04/19 16:03:18 devrcs
122 * Added 3 new fields in db_symtab_t for sorting.
123 * [barbou@gr.osf.org]
124 * [92/12/03 bernadat]
126 * Revision 1.1 1992/09/30 02:24:22 robert
133 * Revision 2.6 91/10/09 16:02:45 af
134 * Revision 2.5.1.1 91/10/05 13:07:39 jeffreyh
135 * Added macro definitions of db_find_task_sym_and_offset(),
136 * db_find_xtrn_task_sym_and_offset(), db_search_symbol().
139 * Revision 2.5.1.1 91/10/05 13:07:39 jeffreyh
140 * Added macro definitions of db_find_task_sym_and_offset(),
141 * db_find_xtrn_task_sym_and_offset(), db_search_symbol().
144 * Revision 2.5 91/07/31 17:31:49 dbg
145 * Add map pointer and storage for name to db_symtab_t.
146 * [91/07/30 16:45:08 dbg]
148 * Revision 2.4 91/05/14 15:36:08 mrt
149 * Correcting copyright
151 * Revision 2.3 91/02/05 17:07:12 mrt
152 * Changed to new Mach copyright
153 * [91/01/31 16:19:27 mrt]
155 * Revision 2.2 90/08/27 21:52:39 dbg
156 * Changed type of db_sym_t to char * - it's a better type for an
166 * Mach Operating System
167 * Copyright (c) 1991,1990 Carnegie Mellon University
168 * All Rights Reserved.
170 * Permission to use, copy, modify and distribute this software and its
171 * documentation is hereby granted, provided that both the copyright
172 * notice and this permission notice appear in all copies of the
173 * software, derivative works or modified versions, and any portions
174 * thereof, and that both notices appear in supporting documentation.
176 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
177 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
178 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
180 * Carnegie Mellon requests users of this software to return to
182 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
183 * School of Computer Science
184 * Carnegie Mellon University
185 * Pittsburgh PA 15213-3890
187 * any improvements or extensions that they make and grant Carnegie Mellon
188 * the rights to redistribute these changes.
193 * Author: Alessandro Forin, Carnegie Mellon University
197 #ifndef _DDB_DB_SYM_H_
198 #define _DDB_DB_SYM_H_
200 #include <mach/boolean.h>
201 #include <mach/machine/vm_types.h>
202 #include <machine/db_machdep.h>
203 #include <kern/task.h>
206 * This module can handle multiple symbol tables,
207 * of multiple types, at the same time
209 #define SYMTAB_NAME_LEN 32
213 #define SYMTAB_AOUT 0
214 #define SYMTAB_COFF 1
215 #define SYMTAB_MACHDEP 2
216 char *start
; /* symtab location */
218 char *private; /* optional machdep pointer */
219 char *map_pointer
; /* symbols are for this map only,
221 char name
[SYMTAB_NAME_LEN
];
223 unsigned long minsym
; /* lowest symbol value */
224 unsigned long maxsym
; /* highest symbol value */
225 boolean_t sorted
; /* is this table sorted ? */
228 extern db_symtab_t
*db_last_symtab
; /* where last symbol was found */
231 * Symbol representation is specific to the symtab style:
232 * BSD compilers use dbx' nlist, other compilers might use
235 typedef void * db_sym_t
; /* opaque handle on symbols */
236 #define DB_SYM_NULL ((db_sym_t)0)
239 * Non-stripped symbol tables will have duplicates, for instance
240 * the same string could match a parameter name, a local var, a
242 * We are most concern with the following matches.
244 typedef int db_strategy_t
; /* search strategy */
246 #define DB_STGY_ANY 0 /* anything goes */
247 #define DB_STGY_XTRN 1 /* only external symbols */
248 #define DB_STGY_PROC 2 /* only procedures */
250 extern boolean_t db_qualify_ambiguous_names
;
251 /* if TRUE, check across symbol tables
252 * for multiple occurrences of a name.
253 * Might slow down quite a bit */
255 extern unsigned long db_maxoff
;
257 /* Prototypes for functions exported by this module.
259 extern boolean_t
db_add_symbol_table(
266 unsigned long minsym
,
267 unsigned long maxsym
,
270 extern void db_install_inks(
273 extern boolean_t
db_value_of_name(
277 extern db_sym_t
db_lookup(char *symstr
);
279 extern char * db_get_sym(
282 extern db_sym_t
db_sym_parse_and_lookup(
283 int (*func
)(db_symtab_t
*,
293 extern int db_sym_parse_and_lookup_incomplete(
294 int (*func
)(db_symtab_t
*,
307 extern int db_sym_parse_and_print_completion(
308 int (*func
)(db_symtab_t
*,
313 extern db_sym_t
db_search_task_symbol(
315 db_strategy_t strategy
,
319 extern db_sym_t
db_search_task_symbol_and_line(
321 db_strategy_t strategy
,
328 extern void db_symbol_values(
334 extern void db_task_printsym(
336 db_strategy_t strategy
,
339 extern void db_printsym(
341 db_strategy_t strategy
);
343 extern boolean_t
db_line_at_pc(
349 extern void db_qsort(
353 int (*compfun
)(char *, char *));
355 extern void db_qsort_limit_search(
360 int (*compfun
)(char *, char *));
362 extern void db_sym_print_completion(
369 extern void db_print_completion(
372 extern int db_lookup_incomplete(
376 extern void ddb_init(void);
378 extern void db_machdep_init(void);
380 extern void db_clone_symtabXXX(char *, char *, vm_offset_t
);
382 extern db_symtab_t
*db_symtab_cloneeXXX(char *);
384 extern db_task_getlinenum( db_expr_t
, task_t
);
386 /* Some convenience macros.
388 #define db_find_sym_and_offset(val,namep,offp) \
389 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
390 /* find name&value given approx val */
392 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
393 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
394 /* ditto, but no locals */
396 #define db_find_task_sym_and_offset(val,namep,offp,task) \
397 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
398 namep, 0) /* find name&value given approx val */
400 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
401 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
402 namep,0) /* ditto, but no locals */
404 #define db_search_symbol(val,strgy,offp) \
405 db_search_task_symbol(val,strgy,offp,0)
406 /* find symbol in current task */
409 * Symbol table switch, defines the interface
410 * to symbol-table specific routines.
413 extern struct db_sym_switch
{
417 boolean_t (*sym_init
)(
428 db_sym_t (*search_symbol
)(
431 db_strategy_t strategy
,
435 boolean_t (*line_at_pc
)(
443 void (*symbol_values
)(
448 db_sym_t (*search_by_addr
)(
458 int (*print_completion
)(
463 int (*lookup_incomplete
)(
473 #define symtab_type(s) SYMTAB_AOUT
476 #define X_db_init() x_db[symtab_type(s)].init()
477 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t)
478 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
479 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
480 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
481 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
482 #define X_db_search_by_addr(s,a,f,c,l,d,r) \
483 x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r)
484 #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p)
485 #define X_db_lookup_incomplete(s,p,n,l,t) \
486 x_db[(s)->type].lookup_incomplete(s,p,n,l,t)
488 #endif /* !_DDB_DB_SYM_H_ */