1139747Simp/*-
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 *
2650477Speter * $FreeBSD$
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
474Srgrimes/*
484Srgrimes * Symbol representation is specific to the symtab style:
494Srgrimes * BSD compilers use dbx' nlist, other compilers might use
504Srgrimes * a different one
514Srgrimes */
524Srgrimestypedef	char *		db_sym_t;	/* opaque handle on symbols */
53101878Sjmalletttypedef	const char *	c_db_sym_t;	/* const opaque handle on symbols */
544Srgrimes#define	DB_SYM_NULL	((db_sym_t)0)
5543309Sdillon#define	C_DB_SYM_NULL	((c_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
694Srgrimes/*
704Srgrimes * Functions exported by the symtable module
714Srgrimes */
7292756Salfredvoid		db_add_symbol_table(char *, char *, char *, char *);
734Srgrimes					/* extend the list of symbol tables */
744Srgrimes
7592756Salfredc_db_sym_t	db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *);
764Srgrimes					/* find symbol given value */
774Srgrimes
7892756Salfredvoid		db_symbol_values(c_db_sym_t, const char **, db_expr_t *);
794Srgrimes					/* return name and value of symbol */
804Srgrimes
814Srgrimes#define db_find_sym_and_offset(val,namep,offp)	\
824Srgrimes	db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
834Srgrimes					/* find name&value given approx val */
844Srgrimes
854Srgrimes#define db_find_xtrn_sym_and_offset(val,namep,offp)	\
864Srgrimes	db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
874Srgrimes					/* ditto, but no locals */
884Srgrimes
8992756Salfredint		db_eqname(const char *, const char *, int);
904Srgrimes					/* strcmp, modulo leading char */
914Srgrimes
9292756Salfredvoid		db_printsym(db_expr_t, db_strategy_t);
934Srgrimes					/* print closest symbol to a value */
942112Swollman
9592756Salfredint		db_sym_numargs(c_db_sym_t, int *, char **);
9612472Sbde
9792756Salfredboolean_t	X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym,
9893009Sbde		    char **filename, int *linenum, db_expr_t off);
9992756Salfredc_db_sym_t	X_db_lookup(db_symtab_t *stab, const char *symstr);
10092756Salfredc_db_sym_t	X_db_search_symbol(db_symtab_t *symtab, db_addr_t off,
10193009Sbde		    db_strategy_t strategy, db_expr_t *diffp);
10293009Sbdeint		X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);
10393009Sbdevoid		X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym,
10493009Sbde		    const char **namep, db_expr_t *valuep);
10512472Sbde
10612472Sbde#endif /* !_DDB_DB_SYM_H_ */
107