2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
31 * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez
32 * Import of Mac OS X kernel (~semeria)
34 * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez
35 * Import of OSF Mach kernel (~mburg)
37 * Revision 1.2.20.6 1996/01/09 19:16:22 devrcs
38 * Add proto for db_task_getlinenum().
39 * [1995/12/01 21:42:34 jfraser]
41 * Revision 1.2.20.5 1995/02/28 01:58:53 dwm
42 * Merged with changes from 1.2.20.4
43 * [1995/02/28 01:53:54 dwm]
45 * mk6 CR1120 - Merge mk6pro_shared into cnmk_shared
46 * [1995/02/28 01:12:57 dwm]
48 * Revision 1.2.20.4 1995/02/23 21:43:48 alanl
49 * Prepend a "db_" to qsort and qsort_limit_search
50 * (collisions with the real qsort in stdlib.h)
53 * Expanded db_sym_switch structure to make ddb object format dependent;
54 * this allows us to remove all of the aout dependencies.
57 * Revision 1.2.23.4 1994/12/22 20:36:20 bolinger
58 * Fix ri-osc CR881: Fixed glitch in use of symtab cloning hack.
59 * [1994/12/22 20:35:17 bolinger]
61 * Revision 1.2.23.3 1994/11/02 18:36:07 dwm
62 * mk6 CR668 - 1.3b26 merge
63 * 64bit cleanup, prototypes
64 * fix X_db_search_by_addr macro to match prototype
65 * [1994/11/02 18:16:20 dwm]
67 * Revision 1.2.20.4 1995/02/23 21:43:48 alanl
68 * Prepend a "db_" to qsort and qsort_limit_search
69 * (collisions with the real qsort in stdlib.h)
72 * Expanded db_sym_switch structure to make ddb object format dependent;
73 * this allows us to remove all of the aout dependencies.
76 * Revision 1.2.23.4 1994/12/22 20:36:20 bolinger
77 * Fix ri-osc CR881: Fixed glitch in use of symtab cloning hack.
78 * [1994/12/22 20:35:17 bolinger]
80 * Revision 1.2.23.3 1994/11/02 18:36:07 dwm
81 * mk6 CR668 - 1.3b26 merge
82 * 64bit cleanup, prototypes
83 * fix X_db_search_by_addr macro to match prototype
84 * [1994/11/02 18:16:20 dwm]
86 * Revision 1.2.20.2 1994/09/23 01:21:51 ezf
87 * change marker to not FREE
88 * [1994/09/22 21:11:04 ezf]
90 * Revision 1.2.20.1 1994/06/11 21:12:25 bolinger
91 * Merge up to NMK17.2.
92 * [1994/06/11 20:04:14 bolinger]
94 * Revision 1.2.14.1 1994/02/08 10:58:56 bernadat
95 * Added db_sym_print_completion
96 * db_sym_parse_and_lookup_incomplete
97 * db_sym_parse_and_print_completion
99 * db_lookup_incomplete
103 * Changed func type to db_sym_parse_and_lookup prototype
105 * Added definition of db_maxoff.
107 * [94/02/07 bernadat]
109 * Revision 1.2.18.1 1994/06/08 19:11:28 dswartz
111 * [1994/06/08 19:10:27 dswartz]
113 * Revision 1.2.17.2 1994/06/01 21:34:50 klj
114 * Initial preemption code base merge
116 * Revision 1.2.4.3 1993/07/27 18:28:12 elliston
117 * Add ANSI prototypes. CR #9523.
118 * [1993/07/27 18:13:02 elliston]
120 * Revision 1.2.4.2 1993/06/09 02:20:56 gm
121 * Added to OSF/1 R1.3 from NMK15.0.
122 * [1993/06/02 20:57:18 jeffc]
124 * Revision 1.2 1993/04/19 16:03:18 devrcs
125 * Added 3 new fields in db_symtab_t for sorting.
126 * [barbou@gr.osf.org]
127 * [92/12/03 bernadat]
129 * Revision 1.1 1992/09/30 02:24:22 robert
136 * Revision 2.6 91/10/09 16:02:45 af
137 * Revision 2.5.1.1 91/10/05 13:07:39 jeffreyh
138 * Added macro definitions of db_find_task_sym_and_offset(),
139 * db_find_xtrn_task_sym_and_offset(), db_search_symbol().
142 * Revision 2.5.1.1 91/10/05 13:07:39 jeffreyh
143 * Added macro definitions of db_find_task_sym_and_offset(),
144 * db_find_xtrn_task_sym_and_offset(), db_search_symbol().
147 * Revision 2.5 91/07/31 17:31:49 dbg
148 * Add map pointer and storage for name to db_symtab_t.
149 * [91/07/30 16:45:08 dbg]
151 * Revision 2.4 91/05/14 15:36:08 mrt
152 * Correcting copyright
154 * Revision 2.3 91/02/05 17:07:12 mrt
155 * Changed to new Mach copyright
156 * [91/01/31 16:19:27 mrt]
158 * Revision 2.2 90/08/27 21:52:39 dbg
159 * Changed type of db_sym_t to char * - it's a better type for an
169 * Mach Operating System
170 * Copyright (c) 1991,1990 Carnegie Mellon University
171 * All Rights Reserved.
173 * Permission to use, copy, modify and distribute this software and its
174 * documentation is hereby granted, provided that both the copyright
175 * notice and this permission notice appear in all copies of the
176 * software, derivative works or modified versions, and any portions
177 * thereof, and that both notices appear in supporting documentation.
179 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
180 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
181 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
183 * Carnegie Mellon requests users of this software to return to
185 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
186 * School of Computer Science
187 * Carnegie Mellon University
188 * Pittsburgh PA 15213-3890
190 * any improvements or extensions that they make and grant Carnegie Mellon
191 * the rights to redistribute these changes.
196 * Author: Alessandro Forin, Carnegie Mellon University
200 #ifndef _DDB_DB_SYM_H_
201 #define _DDB_DB_SYM_H_
203 #include <mach/boolean.h>
204 #include <mach/machine/vm_types.h>
205 #include <machine/db_machdep.h>
206 #include <kern/task.h>
209 * This module can handle multiple symbol tables,
210 * of multiple types, at the same time
212 #define SYMTAB_NAME_LEN 32
216 #define SYMTAB_AOUT 0
217 #define SYMTAB_COFF 1
218 #define SYMTAB_MACHDEP 2
219 char *start
; /* symtab location */
221 char *private; /* optional machdep pointer */
222 char *map_pointer
; /* symbols are for this map only,
224 char name
[SYMTAB_NAME_LEN
];
226 unsigned long minsym
; /* lowest symbol value */
227 unsigned long maxsym
; /* highest symbol value */
228 boolean_t sorted
; /* is this table sorted ? */
231 extern db_symtab_t
*db_last_symtab
; /* where last symbol was found */
234 * Symbol representation is specific to the symtab style:
235 * BSD compilers use dbx' nlist, other compilers might use
238 typedef void * db_sym_t
; /* opaque handle on symbols */
239 #define DB_SYM_NULL ((db_sym_t)0)
242 * Non-stripped symbol tables will have duplicates, for instance
243 * the same string could match a parameter name, a local var, a
245 * We are most concern with the following matches.
247 typedef int db_strategy_t
; /* search strategy */
249 #define DB_STGY_ANY 0 /* anything goes */
250 #define DB_STGY_XTRN 1 /* only external symbols */
251 #define DB_STGY_PROC 2 /* only procedures */
253 extern boolean_t db_qualify_ambiguous_names
;
254 /* if TRUE, check across symbol tables
255 * for multiple occurrences of a name.
256 * Might slow down quite a bit */
258 extern unsigned long db_maxoff
;
260 /* Prototypes for functions exported by this module.
262 extern boolean_t
db_add_symbol_table(
269 unsigned long minsym
,
270 unsigned long maxsym
,
273 extern void db_install_inks(
276 extern boolean_t
db_value_of_name(
280 extern db_sym_t
db_lookup(char *symstr
);
282 extern char * db_get_sym(
285 extern db_sym_t
db_sym_parse_and_lookup(
286 int (*func
)(db_symtab_t
*,
296 extern int db_sym_parse_and_lookup_incomplete(
297 int (*func
)(db_symtab_t
*,
310 extern int db_sym_parse_and_print_completion(
311 int (*func
)(db_symtab_t
*,
316 extern db_sym_t
db_search_task_symbol(
318 db_strategy_t strategy
,
322 extern db_sym_t
db_search_task_symbol_and_line(
324 db_strategy_t strategy
,
331 extern void db_symbol_values(
337 extern void db_task_printsym(
339 db_strategy_t strategy
,
342 extern void db_printsym(
344 db_strategy_t strategy
);
346 extern boolean_t
db_line_at_pc(
352 extern void db_qsort(
356 int (*compfun
)(char *, char *));
358 extern void db_qsort_limit_search(
363 int (*compfun
)(char *, char *));
365 extern void db_sym_print_completion(
372 extern void db_print_completion(
375 extern int db_lookup_incomplete(
379 extern void ddb_init(void);
381 extern void db_machdep_init(void);
383 extern void db_clone_symtabXXX(char *, char *, vm_offset_t
);
385 extern db_symtab_t
*db_symtab_cloneeXXX(char *);
387 extern db_task_getlinenum( db_expr_t
, task_t
);
389 /* Some convenience macros.
391 #define db_find_sym_and_offset(val,namep,offp) \
392 db_symbol_values(0, db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
393 /* find name&value given approx val */
395 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
396 db_symbol_values(0, db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
397 /* ditto, but no locals */
399 #define db_find_task_sym_and_offset(val,namep,offp,task) \
400 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_ANY,offp,task), \
401 namep, 0) /* find name&value given approx val */
403 #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
404 db_symbol_values(0, db_search_task_symbol(val,DB_STGY_XTRN,offp,task), \
405 namep,0) /* ditto, but no locals */
407 #define db_search_symbol(val,strgy,offp) \
408 db_search_task_symbol(val,strgy,offp,0)
409 /* find symbol in current task */
412 * Symbol table switch, defines the interface
413 * to symbol-table specific routines.
416 extern struct db_sym_switch
{
420 boolean_t (*sym_init
)(
431 db_sym_t (*search_symbol
)(
434 db_strategy_t strategy
,
438 boolean_t (*line_at_pc
)(
446 void (*symbol_values
)(
451 db_sym_t (*search_by_addr
)(
461 int (*print_completion
)(
466 int (*lookup_incomplete
)(
476 #define symtab_type(s) SYMTAB_AOUT
479 #define X_db_init() x_db[symtab_type(s)].init()
480 #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].sym_init(s,e,n,t)
481 #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
482 #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
483 #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
484 #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(p,n,v)
485 #define X_db_search_by_addr(s,a,f,c,l,d,r) \
486 x_db[(s)->type].search_by_addr(s,a,f,c,l,d,r)
487 #define X_db_print_completion(s,p) x_db[(s)->type].print_completion(s,p)
488 #define X_db_lookup_incomplete(s,p,n,l,t) \
489 x_db[(s)->type].lookup_incomplete(s,p,n,l,t)
491 #endif /* !_DDB_DB_SYM_H_ */