2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 * Mach Operating System
35 * Copyright (c) 1991,1990 Carnegie Mellon University
36 * All Rights Reserved.
38 * Permission to use, copy, modify and distribute this software and its
39 * documentation is hereby granted, provided that both the copyright
40 * notice and this permission notice appear in all copies of the
41 * software, derivative works or modified versions, and any portions
42 * thereof, and that both notices appear in supporting documentation.
44 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
46 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
48 * Carnegie Mellon requests users of this software to return to
50 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
51 * School of Computer Science
52 * Carnegie Mellon University
53 * Pittsburgh PA 15213-3890
55 * any improvements or extensions that they make and grant Carnegie Mellon
56 * the rights to redistribute these changes.
61 * Author: Alessandro Forin, Carnegie Mellon University
65 #ifndef _DDB_DB_SYM_H_
66 #define _DDB_DB_SYM_H_
68 #include <mach/boolean.h>
69 #include <mach/machine/vm_types.h>
70 #include <machine/db_machdep.h>
71 #include <kern/task.h>
74 * This module can handle multiple symbol tables,
75 * of multiple types, at the same time
77 #define SYMTAB_NAME_LEN 32
83 #define SYMTAB_MACHDEP 2
84 char *start
; /* symtab location */
86 char *private; /* optional machdep pointer */
87 char *map_pointer
; /* symbols are for this map only,
89 char name
[SYMTAB_NAME_LEN
];
91 unsigned long minsym
; /* lowest symbol value */
92 unsigned long maxsym
; /* highest symbol value */
93 boolean_t sorted
; /* is this table sorted ? */
96 extern db_symtab_t
*db_last_symtab
; /* where last symbol was found */
99 * Symbol representation is specific to the symtab style:
100 * BSD compilers use dbx' nlist, other compilers might use
103 typedef void * db_sym_t
; /* opaque handle on symbols */
104 #define DB_SYM_NULL ((db_sym_t)0)
107 * Non-stripped symbol tables will have duplicates, for instance
108 * the same string could match a parameter name, a local var, a
110 * We are most concern with the following matches.
112 typedef int db_strategy_t
; /* search strategy */
114 #define DB_STGY_ANY 0 /* anything goes */
115 #define DB_STGY_XTRN 1 /* only external symbols */
116 #define DB_STGY_PROC 2 /* only procedures */
118 extern boolean_t db_qualify_ambiguous_names
;
119 /* if TRUE, check across symbol tables
120 * for multiple occurrences of a name.
121 * Might slow down quite a bit */
123 extern unsigned long db_maxoff
;
125 /* Prototypes for functions exported by this module.
127 extern boolean_t
db_add_symbol_table(
134 unsigned long minsym
,
135 unsigned long maxsym
,
138 extern void db_install_inks(
141 extern boolean_t
db_value_of_name(
145 extern db_sym_t
db_lookup(char *symstr
);
147 extern char * db_get_sym(
150 extern db_sym_t
db_sym_parse_and_lookup(
151 int (*func
)(db_symtab_t
*,
161 extern int db_sym_parse_and_lookup_incomplete(
162 int (*func
)(db_symtab_t
*,
175 extern int db_sym_parse_and_print_completion(
176 int (*func
)(db_symtab_t
*,
181 extern db_sym_t
db_search_task_symbol(
183 db_strategy_t strategy
,
187 extern db_sym_t
db_search_task_symbol_and_line(
189 db_strategy_t strategy
,
196 extern void db_symbol_values(
202 extern void db_task_printsym(
204 db_strategy_t strategy
,
207 extern void db_printsym(
209 db_strategy_t strategy
);
211 extern boolean_t
db_line_at_pc(
217 extern void db_qsort(
221 int (*compfun
)(char *, char *));
223 extern void db_qsort_limit_search(
228 int (*compfun
)(char *, char *));
230 extern void db_sym_print_completion(
237 extern void db_print_completion(
240 extern int db_lookup_incomplete(
244 extern void ddb_init(void);
246 extern void db_machdep_init(void);
248 extern void db_clone_symtabXXX(char *, char *, vm_offset_t
);
250 extern db_symtab_t
*db_symtab_cloneeXXX(char *);
252 extern int db_task_getlinenum( db_expr_t
, task_t
);
254 /* Some convenience macros.
256 #define db_find_sym_and_offset(val,namep,offp) \
257 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
258 /* find name&value given approx val */
260 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
261 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
262 /* ditto, but no locals */
264 #define db_find_task_sym_and_offset(val,namep,offp,task) \
265 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
266 namep, 0) /* find name&value given approx val */
268 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
269 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
270 namep,0) /* ditto, but no locals */
272 #define db_search_symbol(val,strgy,offp) \
273 db_search_task_symbol(val,strgy,offp,0)
274 /* find symbol in current task */
277 * Symbol table switch, defines the interface
278 * to symbol-table specific routines.
281 extern struct db_sym_switch
{
285 boolean_t (*sym_init
)(
296 db_sym_t (*search_symbol
)(
299 db_strategy_t strategy
,
303 boolean_t (*line_at_pc
)(
311 void (*symbol_values
)(
316 db_sym_t (*search_by_addr
)(
326 int (*print_completion
)(
331 int (*lookup_incomplete
)(
341 #define symtab_type(s) SYMTAB_AOUT
344 #define X_db_init() x_db[symtab_type(s)].init()
345 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t)
346 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
347 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
348 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
349 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
350 #define X_db_search_by_addr(s,a,f,c,l,d,r) \
351 x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r)
352 #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p)
353 #define X_db_lookup_incomplete(s,p,n,l,t) \
354 x_db[(s)->type].lookup_incomplete(s,p,n,l,t)
356 #endif /* !_DDB_DB_SYM_H_ */