2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * Mach Operating System
33 * Copyright (c) 1991,1990 Carnegie Mellon University
34 * All Rights Reserved.
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
59 * Author: Alessandro Forin, Carnegie Mellon University
63 #ifndef _DDB_DB_SYM_H_
64 #define _DDB_DB_SYM_H_
66 #include <mach/boolean.h>
67 #include <mach/machine/vm_types.h>
68 #include <machine/db_machdep.h>
69 #include <kern/task.h>
72 * This module can handle multiple symbol tables,
73 * of multiple types, at the same time
75 #define SYMTAB_NAME_LEN 32
81 #define SYMTAB_MACHDEP 2
82 char *start
; /* symtab location */
84 char *private; /* optional machdep pointer */
85 char *map_pointer
; /* symbols are for this map only,
87 char name
[SYMTAB_NAME_LEN
];
89 unsigned long minsym
; /* lowest symbol value */
90 unsigned long maxsym
; /* highest symbol value */
91 boolean_t sorted
; /* is this table sorted ? */
94 extern db_symtab_t
*db_last_symtab
; /* where last symbol was found */
97 * Symbol representation is specific to the symtab style:
98 * BSD compilers use dbx' nlist, other compilers might use
101 typedef void * db_sym_t
; /* opaque handle on symbols */
102 #define DB_SYM_NULL ((db_sym_t)0)
105 * Non-stripped symbol tables will have duplicates, for instance
106 * the same string could match a parameter name, a local var, a
108 * We are most concern with the following matches.
110 typedef int db_strategy_t
; /* search strategy */
112 #define DB_STGY_ANY 0 /* anything goes */
113 #define DB_STGY_XTRN 1 /* only external symbols */
114 #define DB_STGY_PROC 2 /* only procedures */
116 extern boolean_t db_qualify_ambiguous_names
;
117 /* if TRUE, check across symbol tables
118 * for multiple occurrences of a name.
119 * Might slow down quite a bit */
121 extern unsigned long db_maxoff
;
123 /* Prototypes for functions exported by this module.
125 extern boolean_t
db_add_symbol_table(
132 unsigned long minsym
,
133 unsigned long maxsym
,
136 extern void db_install_inks(
139 extern boolean_t
db_value_of_name(
143 extern db_sym_t
db_lookup(const char *symstr
);
145 extern char * db_get_sym(
148 extern db_sym_t
db_sym_parse_and_lookup(
149 int (*func
)(db_symtab_t
*,
159 extern int db_sym_parse_and_lookup_incomplete(
160 int (*func
)(db_symtab_t
*,
173 extern int db_sym_parse_and_print_completion(
174 int (*func
)(db_symtab_t
*,
179 extern db_sym_t
db_search_task_symbol(
181 db_strategy_t strategy
,
185 extern db_sym_t
db_search_task_symbol_and_line(
187 db_strategy_t strategy
,
194 extern void db_symbol_values(
200 extern void db_task_printsym(
202 db_strategy_t strategy
,
205 extern void db_printsym(
207 db_strategy_t strategy
);
209 extern boolean_t
db_line_at_pc(
215 extern void db_qsort(
219 int (*compfun
)(char *, char *));
221 extern void db_qsort_limit_search(
226 int (*compfun
)(char *, char *));
228 extern void db_sym_print_completion(
235 extern void db_print_completion(
238 extern int db_lookup_incomplete(
242 extern void ddb_init(void);
244 extern void db_machdep_init(void);
246 extern void db_clone_symtabXXX(char *, char *, vm_offset_t
);
248 extern db_symtab_t
*db_symtab_cloneeXXX(char *);
250 extern int db_task_getlinenum( db_expr_t
, task_t
);
252 /* Some convenience macros.
254 #define db_find_sym_and_offset(val,namep,offp) \
255 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
256 /* find name&value given approx val */
258 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
259 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
260 /* ditto, but no locals */
262 #define db_find_task_sym_and_offset(val,namep,offp,task) \
263 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
264 namep, 0) /* find name&value given approx val */
266 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
267 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
268 namep,0) /* ditto, but no locals */
270 #define db_search_symbol(val,strgy,offp) \
271 db_search_task_symbol(val,strgy,offp,0)
272 /* find symbol in current task */
275 * Symbol table switch, defines the interface
276 * to symbol-table specific routines.
279 extern struct db_sym_switch
{
283 boolean_t (*sym_init
)(
294 db_sym_t (*search_symbol
)(
297 db_strategy_t strategy
,
301 boolean_t (*line_at_pc
)(
309 void (*symbol_values
)(
314 db_sym_t (*search_by_addr
)(
324 int (*print_completion
)(
329 int (*lookup_incomplete
)(
339 #define symtab_type(s) SYMTAB_AOUT
342 #define X_db_init() x_db[symtab_type(s)].init()
343 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t)
344 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
345 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
346 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
347 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
348 #define X_db_search_by_addr(s,a,f,c,l,d,r) \
349 x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r)
350 #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p)
351 #define X_db_lookup_incomplete(s,p,n,l,t) \
352 x_db[(s)->type].lookup_incomplete(s,p,n,l,t)
354 #endif /* !_DDB_DB_SYM_H_ */