2 * Copyright (c) 2000-2004 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@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * Author: Alessandro Forin, Carnegie Mellon University
57 #ifndef _DDB_DB_SYM_H_
58 #define _DDB_DB_SYM_H_
60 #include <mach/boolean.h>
61 #include <mach/machine/vm_types.h>
62 #include <machine/db_machdep.h>
63 #include <kern/task.h>
66 * This module can handle multiple symbol tables,
67 * of multiple types, at the same time
69 #define SYMTAB_NAME_LEN 32
75 #define SYMTAB_MACHDEP 2
76 char *start
; /* symtab location */
78 char *private; /* optional machdep pointer */
79 char *map_pointer
; /* symbols are for this map only,
81 char name
[SYMTAB_NAME_LEN
];
83 unsigned long minsym
; /* lowest symbol value */
84 unsigned long maxsym
; /* highest symbol value */
85 boolean_t sorted
; /* is this table sorted ? */
88 extern db_symtab_t
*db_last_symtab
; /* where last symbol was found */
91 * Symbol representation is specific to the symtab style:
92 * BSD compilers use dbx' nlist, other compilers might use
95 typedef void * db_sym_t
; /* opaque handle on symbols */
96 #define DB_SYM_NULL ((db_sym_t)0)
99 * Non-stripped symbol tables will have duplicates, for instance
100 * the same string could match a parameter name, a local var, a
102 * We are most concern with the following matches.
104 typedef int db_strategy_t
; /* search strategy */
106 #define DB_STGY_ANY 0 /* anything goes */
107 #define DB_STGY_XTRN 1 /* only external symbols */
108 #define DB_STGY_PROC 2 /* only procedures */
110 extern boolean_t db_qualify_ambiguous_names
;
111 /* if TRUE, check across symbol tables
112 * for multiple occurrences of a name.
113 * Might slow down quite a bit */
115 extern unsigned long db_maxoff
;
117 /* Prototypes for functions exported by this module.
119 extern boolean_t
db_add_symbol_table(
126 unsigned long minsym
,
127 unsigned long maxsym
,
130 extern void db_install_inks(
133 extern boolean_t
db_value_of_name(
137 extern db_sym_t
db_lookup(char *symstr
);
139 extern char * db_get_sym(
142 extern db_sym_t
db_sym_parse_and_lookup(
143 int (*func
)(db_symtab_t
*,
153 extern int db_sym_parse_and_lookup_incomplete(
154 int (*func
)(db_symtab_t
*,
167 extern int db_sym_parse_and_print_completion(
168 int (*func
)(db_symtab_t
*,
173 extern db_sym_t
db_search_task_symbol(
175 db_strategy_t strategy
,
179 extern db_sym_t
db_search_task_symbol_and_line(
181 db_strategy_t strategy
,
188 extern void db_symbol_values(
194 extern void db_task_printsym(
196 db_strategy_t strategy
,
199 extern void db_printsym(
201 db_strategy_t strategy
);
203 extern boolean_t
db_line_at_pc(
209 extern void db_qsort(
213 int (*compfun
)(char *, char *));
215 extern void db_qsort_limit_search(
220 int (*compfun
)(char *, char *));
222 extern void db_sym_print_completion(
229 extern void db_print_completion(
232 extern int db_lookup_incomplete(
236 extern void ddb_init(void);
238 extern void db_machdep_init(void);
240 extern void db_clone_symtabXXX(char *, char *, vm_offset_t
);
242 extern db_symtab_t
*db_symtab_cloneeXXX(char *);
244 extern int db_task_getlinenum( db_expr_t
, task_t
);
246 /* Some convenience macros.
248 #define db_find_sym_and_offset(val,namep,offp) \
249 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
250 /* find name&value given approx val */
252 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
253 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
254 /* ditto, but no locals */
256 #define db_find_task_sym_and_offset(val,namep,offp,task) \
257 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
258 namep, 0) /* find name&value given approx val */
260 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
261 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
262 namep,0) /* ditto, but no locals */
264 #define db_search_symbol(val,strgy,offp) \
265 db_search_task_symbol(val,strgy,offp,0)
266 /* find symbol in current task */
269 * Symbol table switch, defines the interface
270 * to symbol-table specific routines.
273 extern struct db_sym_switch
{
277 boolean_t (*sym_init
)(
288 db_sym_t (*search_symbol
)(
291 db_strategy_t strategy
,
295 boolean_t (*line_at_pc
)(
303 void (*symbol_values
)(
308 db_sym_t (*search_by_addr
)(
318 int (*print_completion
)(
323 int (*lookup_incomplete
)(
333 #define symtab_type(s) SYMTAB_AOUT
336 #define X_db_init() x_db[symtab_type(s)].init()
337 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t)
338 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
339 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
340 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
341 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
342 #define X_db_search_by_addr(s,a,f,c,l,d,r) \
343 x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r)
344 #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p)
345 #define X_db_lookup_incomplete(s,p,n,l,t) \
346 x_db[(s)->type].lookup_incomplete(s,p,n,l,t)
348 #endif /* !_DDB_DB_SYM_H_ */