xref: /freebsd/sys/ddb/db_sym.h (revision 95ee2897)
1dd3cb568SWarner Losh /*-
2796df753SPedro F. Giffuni  * SPDX-License-Identifier: MIT-CMU
3796df753SPedro F. Giffuni  *
45b81b6b3SRodney W. Grimes  * Mach Operating System
55b81b6b3SRodney W. Grimes  * Copyright (c) 1991,1990 Carnegie Mellon University
65b81b6b3SRodney W. Grimes  * All Rights Reserved.
75b81b6b3SRodney W. Grimes  *
85b81b6b3SRodney W. Grimes  * Permission to use, copy, modify and distribute this software and its
95b81b6b3SRodney W. Grimes  * documentation is hereby granted, provided that both the copyright
105b81b6b3SRodney W. Grimes  * notice and this permission notice appear in all copies of the
115b81b6b3SRodney W. Grimes  * software, derivative works or modified versions, and any portions
125b81b6b3SRodney W. Grimes  * thereof, and that both notices appear in supporting documentation.
135b81b6b3SRodney W. Grimes  *
145b81b6b3SRodney W. Grimes  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
155b81b6b3SRodney W. Grimes  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
165b81b6b3SRodney W. Grimes  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
175b81b6b3SRodney W. Grimes  *
185b81b6b3SRodney W. Grimes  * Carnegie Mellon requests users of this software to return to
195b81b6b3SRodney W. Grimes  *
205b81b6b3SRodney W. Grimes  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
215b81b6b3SRodney W. Grimes  *  School of Computer Science
225b81b6b3SRodney W. Grimes  *  Carnegie Mellon University
235b81b6b3SRodney W. Grimes  *  Pittsburgh PA 15213-3890
245b81b6b3SRodney W. Grimes  *
255b81b6b3SRodney W. Grimes  * any improvements or extensions that they make and grant Carnegie the
265b81b6b3SRodney W. Grimes  * rights to redistribute these changes.
275b81b6b3SRodney W. Grimes  */
280edf66ecSRodney W. Grimes 
296437fb2cSGarrett Wollman #ifndef _DDB_DB_SYM_H_
304753168fSBruce Evans #define	_DDB_DB_SYM_H_
316437fb2cSGarrett Wollman 
325b81b6b3SRodney W. Grimes /*
335b81b6b3SRodney W. Grimes  *	Author: Alessandro Forin, Carnegie Mellon University
345b81b6b3SRodney W. Grimes  *	Date:	8/90
355b81b6b3SRodney W. Grimes  */
365b81b6b3SRodney W. Grimes 
375b81b6b3SRodney W. Grimes /*
385b81b6b3SRodney W. Grimes  * This module can handle multiple symbol tables
395b81b6b3SRodney W. Grimes  */
405b81b6b3SRodney W. Grimes typedef struct {
415b81b6b3SRodney W. Grimes 	char		*name;		/* symtab name */
425b81b6b3SRodney W. Grimes 	char		*start;		/* symtab location */
435b81b6b3SRodney W. Grimes 	char		*end;
445b81b6b3SRodney W. Grimes 	char		*private;	/* optional machdep pointer */
455b81b6b3SRodney W. Grimes } db_symtab_t;
465b81b6b3SRodney W. Grimes 
475b81b6b3SRodney W. Grimes /*
485b81b6b3SRodney W. Grimes  * Symbol representation is specific to the symtab style:
495b81b6b3SRodney W. Grimes  * BSD compilers use dbx' nlist, other compilers might use
505b81b6b3SRodney W. Grimes  * a different one
515b81b6b3SRodney W. Grimes  */
525b81b6b3SRodney W. Grimes typedef	char *		db_sym_t;	/* opaque handle on symbols */
53c96c3805SJuli Mallett typedef	const char *	c_db_sym_t;	/* const opaque handle on symbols */
545b81b6b3SRodney W. Grimes #define	DB_SYM_NULL	((db_sym_t)0)
55fe08c21aSMatthew Dillon #define	C_DB_SYM_NULL	((c_db_sym_t)0)
565b81b6b3SRodney W. Grimes 
575b81b6b3SRodney W. Grimes /*
585b81b6b3SRodney W. Grimes  * Non-stripped symbol tables will have duplicates, for instance
595b81b6b3SRodney W. Grimes  * the same string could match a parameter name, a local var, a
605b81b6b3SRodney W. Grimes  * global var, etc.
615b81b6b3SRodney W. Grimes  * We are most concern with the following matches.
625b81b6b3SRodney W. Grimes  */
635b81b6b3SRodney W. Grimes typedef int		db_strategy_t;	/* search strategy */
645b81b6b3SRodney W. Grimes 
655b81b6b3SRodney W. Grimes #define	DB_STGY_ANY	0			/* anything goes */
665b81b6b3SRodney W. Grimes #define	DB_STGY_XTRN	1			/* only external symbols */
675b81b6b3SRodney W. Grimes #define	DB_STGY_PROC	2			/* only procedures */
685b81b6b3SRodney W. Grimes 
695b81b6b3SRodney W. Grimes /*
705b81b6b3SRodney W. Grimes  * Functions exported by the symtable module
715b81b6b3SRodney W. Grimes  */
7214e10f99SAlfred Perlstein void		db_add_symbol_table(char *, char *, char *, char *);
735b81b6b3SRodney W. Grimes 					/* extend the list of symbol tables */
745b81b6b3SRodney W. Grimes 
7514e10f99SAlfred Perlstein c_db_sym_t	db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *);
765b81b6b3SRodney W. Grimes 					/* find symbol given value */
775b81b6b3SRodney W. Grimes 
7814e10f99SAlfred Perlstein void		db_symbol_values(c_db_sym_t, const char **, db_expr_t *);
795b81b6b3SRodney W. Grimes 					/* return name and value of symbol */
805b81b6b3SRodney W. Grimes 
815b81b6b3SRodney W. Grimes #define	db_find_sym_and_offset(val,namep,offp)	\
825b81b6b3SRodney W. Grimes 	db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
835b81b6b3SRodney W. Grimes 					/* find name&value given approx val */
845b81b6b3SRodney W. Grimes 
855b81b6b3SRodney W. Grimes #define	db_find_xtrn_sym_and_offset(val,namep,offp)	\
865b81b6b3SRodney W. Grimes 	db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
875b81b6b3SRodney W. Grimes 					/* ditto, but no locals */
885b81b6b3SRodney W. Grimes 
89cd508278SPedro F. Giffuni bool		db_eqname(const char *, const char *, int);
905b81b6b3SRodney W. Grimes 					/* strcmp, modulo leading char */
915b81b6b3SRodney W. Grimes 
9214e10f99SAlfred Perlstein void		db_printsym(db_expr_t, db_strategy_t);
935b81b6b3SRodney W. Grimes 					/* print closest symbol to a value */
94f23b4c91SGarrett Wollman 
95cd508278SPedro F. Giffuni bool		db_sym_numargs(c_db_sym_t, int *, char **);
964753168fSBruce Evans 
97cd508278SPedro F. Giffuni bool		X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym,
98763df836SBruce Evans 		    char **filename, int *linenum, db_expr_t off);
9914e10f99SAlfred Perlstein c_db_sym_t	X_db_lookup(db_symtab_t *stab, const char *symstr);
10014e10f99SAlfred Perlstein c_db_sym_t	X_db_search_symbol(db_symtab_t *symtab, db_addr_t off,
101763df836SBruce Evans 		    db_strategy_t strategy, db_expr_t *diffp);
102cd508278SPedro F. Giffuni bool		X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);
103763df836SBruce Evans void		X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym,
104763df836SBruce Evans 		    const char **namep, db_expr_t *valuep);
1054753168fSBruce Evans 
106aba921bdSMitchell Horne void		db_decode_syscall(struct thread *td, u_int number);
107754cb545SMitchell Horne 
1084753168fSBruce Evans #endif /* !_DDB_DB_SYM_H_ */
109