db_sym.h revision 12472
18876Srgrimes/*
24Srgrimes * Mach Operating System
34Srgrimes * Copyright (c) 1991,1990 Carnegie Mellon University
44Srgrimes * All Rights Reserved.
58876Srgrimes *
64Srgrimes * Permission to use, copy, modify and distribute this software and its
74Srgrimes * documentation is hereby granted, provided that both the copyright
84Srgrimes * notice and this permission notice appear in all copies of the
94Srgrimes * software, derivative works or modified versions, and any portions
104Srgrimes * thereof, and that both notices appear in supporting documentation.
118876Srgrimes *
128876Srgrimes * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
134Srgrimes * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
144Srgrimes * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
158876Srgrimes *
164Srgrimes * Carnegie Mellon requests users of this software to return to
178876Srgrimes *
184Srgrimes *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
194Srgrimes *  School of Computer Science
204Srgrimes *  Carnegie Mellon University
214Srgrimes *  Pittsburgh PA 15213-3890
228876Srgrimes *
234Srgrimes * any improvements or extensions that they make and grant Carnegie the
244Srgrimes * rights to redistribute these changes.
254Srgrimes *
2612472Sbde *	$Id: db_sym.h,v 1.8 1995/05/30 07:57:11 rgrimes Exp $
274Srgrimes */
28623Srgrimes
29716Swollman#ifndef _DDB_DB_SYM_H_
3012472Sbde#define	_DDB_DB_SYM_H_
31716Swollman
324Srgrimes/*
334Srgrimes * 	Author: Alessandro Forin, Carnegie Mellon University
344Srgrimes *	Date:	8/90
354Srgrimes */
364Srgrimes
374Srgrimes/*
384Srgrimes * This module can handle multiple symbol tables
394Srgrimes */
404Srgrimestypedef struct {
414Srgrimes	char		*name;		/* symtab name */
424Srgrimes	char		*start;		/* symtab location */
434Srgrimes	char		*end;
444Srgrimes	char		*private;	/* optional machdep pointer */
454Srgrimes} db_symtab_t;
464Srgrimes
474Srgrimesextern db_symtab_t	*db_last_symtab; /* where last symbol was found */
484Srgrimes
494Srgrimes/*
504Srgrimes * Symbol representation is specific to the symtab style:
514Srgrimes * BSD compilers use dbx' nlist, other compilers might use
524Srgrimes * a different one
534Srgrimes */
544Srgrimestypedef	char *		db_sym_t;	/* opaque handle on symbols */
554Srgrimes#define	DB_SYM_NULL	((db_sym_t)0)
564Srgrimes
574Srgrimes/*
584Srgrimes * Non-stripped symbol tables will have duplicates, for instance
594Srgrimes * the same string could match a parameter name, a local var, a
604Srgrimes * global var, etc.
614Srgrimes * We are most concern with the following matches.
624Srgrimes */
634Srgrimestypedef int		db_strategy_t;	/* search strategy */
644Srgrimes
654Srgrimes#define	DB_STGY_ANY	0			/* anything goes */
664Srgrimes#define DB_STGY_XTRN	1			/* only external symbols */
674Srgrimes#define DB_STGY_PROC	2			/* only procedures */
684Srgrimes
694Srgrimesextern boolean_t	db_qualify_ambiguous_names;
704Srgrimes					/* if TRUE, check across symbol tables
714Srgrimes					 * for multiple occurrences of a name.
724Srgrimes					 * Might slow down quite a bit */
734Srgrimes
744Srgrimes/*
754Srgrimes * Functions exported by the symtable module
764Srgrimes */
7712472Sbdevoid		db_add_symbol_table __P((char *, char *, char *, char *));
784Srgrimes					/* extend the list of symbol tables */
794Srgrimes
8012472Sbdedb_sym_t	db_search_symbol __P((db_addr_t, db_strategy_t, db_expr_t *));
814Srgrimes					/* find symbol given value */
824Srgrimes
8312472Sbdevoid		db_symbol_values __P((db_sym_t, char **, db_expr_t *));
844Srgrimes					/* return name and value of symbol */
854Srgrimes
864Srgrimes#define db_find_sym_and_offset(val,namep,offp)	\
874Srgrimes	db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
884Srgrimes					/* find name&value given approx val */
894Srgrimes
904Srgrimes#define db_find_xtrn_sym_and_offset(val,namep,offp)	\
914Srgrimes	db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
924Srgrimes					/* ditto, but no locals */
934Srgrimes
9412472Sbdeint		db_eqname __P((char *, char *, char));
954Srgrimes					/* strcmp, modulo leading char */
964Srgrimes
9712472Sbdevoid		db_printsym __P((db_expr_t, db_strategy_t));
984Srgrimes					/* print closest symbol to a value */
992112Swollman
10012472Sbdeboolean_t	db_line_at_pc __P((db_sym_t, char **, int *, db_expr_t));
10112472Sbdeint		db_sym_numargs __P((db_sym_t, int *, char **));
10212472Sbde
10312472Sbdeboolean_t	X_db_line_at_pc __P((db_symtab_t *symtab, db_sym_t cursym,
10412472Sbde				     char **filename, int *linenum,
10512472Sbde				     db_expr_t off));
10612472Sbdedb_sym_t	X_db_lookup __P((db_symtab_t *stab, char *symstr));
10712472Sbdedb_sym_t	X_db_search_symbol __P((db_symtab_t *symtab, db_addr_t off,
10812472Sbde					db_strategy_t strategy,
10912472Sbde					db_expr_t *diffp));
11012472Sbdevoid		X_db_sym_init __P((int *symtab, char *esymtab, char *name));
11112472Sbdeint		X_db_sym_numargs __P((db_symtab_t *, db_sym_t, int *,
11212472Sbde				      char **));
11312472Sbdevoid		X_db_symbol_values __P((db_sym_t sym, char **namep,
11412472Sbde					db_expr_t *valuep));
11512472Sbde
11612472Sbde#endif /* !_DDB_DB_SYM_H_ */
117