2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 * Mach Operating System
28 * Copyright (c) 1991,1990 Carnegie Mellon University
29 * All Rights Reserved.
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 * Carnegie Mellon requests users of this software to return to
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
54 * Author: Alessandro Forin, Carnegie Mellon University
58 #ifndef _DDB_DB_SYM_H_
59 #define _DDB_DB_SYM_H_
61 #include <mach/boolean.h>
62 #include <mach/machine/vm_types.h>
63 #include <machine/db_machdep.h>
64 #include <kern/task.h>
67 * This module can handle multiple symbol tables,
68 * of multiple types, at the same time
70 #define SYMTAB_NAME_LEN 32
76 #define SYMTAB_MACHDEP 2
77 char *start
; /* symtab location */
79 char *private; /* optional machdep pointer */
80 char *map_pointer
; /* symbols are for this map only,
82 char name
[SYMTAB_NAME_LEN
];
84 unsigned long minsym
; /* lowest symbol value */
85 unsigned long maxsym
; /* highest symbol value */
86 boolean_t sorted
; /* is this table sorted ? */
89 extern db_symtab_t
*db_last_symtab
; /* where last symbol was found */
92 * Symbol representation is specific to the symtab style:
93 * BSD compilers use dbx' nlist, other compilers might use
96 typedef void * db_sym_t
; /* opaque handle on symbols */
97 #define DB_SYM_NULL ((db_sym_t)0)
100 * Non-stripped symbol tables will have duplicates, for instance
101 * the same string could match a parameter name, a local var, a
103 * We are most concern with the following matches.
105 typedef int db_strategy_t
; /* search strategy */
107 #define DB_STGY_ANY 0 /* anything goes */
108 #define DB_STGY_XTRN 1 /* only external symbols */
109 #define DB_STGY_PROC 2 /* only procedures */
111 extern boolean_t db_qualify_ambiguous_names
;
112 /* if TRUE, check across symbol tables
113 * for multiple occurrences of a name.
114 * Might slow down quite a bit */
116 extern unsigned long db_maxoff
;
118 /* Prototypes for functions exported by this module.
120 extern boolean_t
db_add_symbol_table(
127 unsigned long minsym
,
128 unsigned long maxsym
,
131 extern void db_install_inks(
134 extern boolean_t
db_value_of_name(
138 extern db_sym_t
db_lookup(char *symstr
);
140 extern char * db_get_sym(
143 extern db_sym_t
db_sym_parse_and_lookup(
144 int (*func
)(db_symtab_t
*,
154 extern int db_sym_parse_and_lookup_incomplete(
155 int (*func
)(db_symtab_t
*,
168 extern int db_sym_parse_and_print_completion(
169 int (*func
)(db_symtab_t
*,
174 extern db_sym_t
db_search_task_symbol(
176 db_strategy_t strategy
,
180 extern db_sym_t
db_search_task_symbol_and_line(
182 db_strategy_t strategy
,
189 extern void db_symbol_values(
195 extern void db_task_printsym(
197 db_strategy_t strategy
,
200 extern void db_printsym(
202 db_strategy_t strategy
);
204 extern boolean_t
db_line_at_pc(
210 extern void db_qsort(
214 int (*compfun
)(char *, char *));
216 extern void db_qsort_limit_search(
221 int (*compfun
)(char *, char *));
223 extern void db_sym_print_completion(
230 extern void db_print_completion(
233 extern int db_lookup_incomplete(
237 extern void ddb_init(void);
239 extern void db_machdep_init(void);
241 extern void db_clone_symtabXXX(char *, char *, vm_offset_t
);
243 extern db_symtab_t
*db_symtab_cloneeXXX(char *);
245 extern int db_task_getlinenum( db_expr_t
, task_t
);
247 /* Some convenience macros.
249 #define db_find_sym_and_offset(val,namep,offp) \
250 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
251 /* find name&value given approx val */
253 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
254 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
255 /* ditto, but no locals */
257 #define db_find_task_sym_and_offset(val,namep,offp,task) \
258 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
259 namep, 0) /* find name&value given approx val */
261 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
262 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
263 namep,0) /* ditto, but no locals */
265 #define db_search_symbol(val,strgy,offp) \
266 db_search_task_symbol(val,strgy,offp,0)
267 /* find symbol in current task */
270 * Symbol table switch, defines the interface
271 * to symbol-table specific routines.
274 extern struct db_sym_switch
{
278 boolean_t (*sym_init
)(
289 db_sym_t (*search_symbol
)(
292 db_strategy_t strategy
,
296 boolean_t (*line_at_pc
)(
304 void (*symbol_values
)(
309 db_sym_t (*search_by_addr
)(
319 int (*print_completion
)(
324 int (*lookup_incomplete
)(
334 #define symtab_type(s) SYMTAB_AOUT
337 #define X_db_init() x_db[symtab_type(s)].init()
338 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t)
339 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
340 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
341 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
342 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
343 #define X_db_search_by_addr(s,a,f,c,l,d,r) \
344 x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r)
345 #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p)
346 #define X_db_lookup_incomplete(s,p,n,l,t) \
347 x_db[(s)->type].lookup_incomplete(s,p,n,l,t)
349 #endif /* !_DDB_DB_SYM_H_ */