xref: /freebsd/sys/ddb/db_sym.h (revision aba921bd9e1869dae9ae4cc6e0c048f997401034)
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.
270edf66ecSRodney W. Grimes  *
28c3aac50fSPeter Wemm  * $FreeBSD$
295b81b6b3SRodney W. Grimes  */
300edf66ecSRodney W. Grimes 
316437fb2cSGarrett Wollman #ifndef _DDB_DB_SYM_H_
324753168fSBruce Evans #define	_DDB_DB_SYM_H_
336437fb2cSGarrett Wollman 
345b81b6b3SRodney W. Grimes /*
355b81b6b3SRodney W. Grimes  *	Author: Alessandro Forin, Carnegie Mellon University
365b81b6b3SRodney W. Grimes  *	Date:	8/90
375b81b6b3SRodney W. Grimes  */
385b81b6b3SRodney W. Grimes 
395b81b6b3SRodney W. Grimes /*
405b81b6b3SRodney W. Grimes  * This module can handle multiple symbol tables
415b81b6b3SRodney W. Grimes  */
425b81b6b3SRodney W. Grimes typedef struct {
435b81b6b3SRodney W. Grimes 	char		*name;		/* symtab name */
445b81b6b3SRodney W. Grimes 	char		*start;		/* symtab location */
455b81b6b3SRodney W. Grimes 	char		*end;
465b81b6b3SRodney W. Grimes 	char		*private;	/* optional machdep pointer */
475b81b6b3SRodney W. Grimes } db_symtab_t;
485b81b6b3SRodney W. Grimes 
495b81b6b3SRodney W. Grimes /*
505b81b6b3SRodney W. Grimes  * Symbol representation is specific to the symtab style:
515b81b6b3SRodney W. Grimes  * BSD compilers use dbx' nlist, other compilers might use
525b81b6b3SRodney W. Grimes  * a different one
535b81b6b3SRodney W. Grimes  */
545b81b6b3SRodney W. Grimes typedef	char *		db_sym_t;	/* opaque handle on symbols */
55c96c3805SJuli Mallett typedef	const char *	c_db_sym_t;	/* const opaque handle on symbols */
565b81b6b3SRodney W. Grimes #define	DB_SYM_NULL	((db_sym_t)0)
57fe08c21aSMatthew Dillon #define	C_DB_SYM_NULL	((c_db_sym_t)0)
585b81b6b3SRodney W. Grimes 
595b81b6b3SRodney W. Grimes /*
605b81b6b3SRodney W. Grimes  * Non-stripped symbol tables will have duplicates, for instance
615b81b6b3SRodney W. Grimes  * the same string could match a parameter name, a local var, a
625b81b6b3SRodney W. Grimes  * global var, etc.
635b81b6b3SRodney W. Grimes  * We are most concern with the following matches.
645b81b6b3SRodney W. Grimes  */
655b81b6b3SRodney W. Grimes typedef int		db_strategy_t;	/* search strategy */
665b81b6b3SRodney W. Grimes 
675b81b6b3SRodney W. Grimes #define	DB_STGY_ANY	0			/* anything goes */
685b81b6b3SRodney W. Grimes #define	DB_STGY_XTRN	1			/* only external symbols */
695b81b6b3SRodney W. Grimes #define	DB_STGY_PROC	2			/* only procedures */
705b81b6b3SRodney W. Grimes 
715b81b6b3SRodney W. Grimes /*
725b81b6b3SRodney W. Grimes  * Functions exported by the symtable module
735b81b6b3SRodney W. Grimes  */
7414e10f99SAlfred Perlstein void		db_add_symbol_table(char *, char *, char *, char *);
755b81b6b3SRodney W. Grimes 					/* extend the list of symbol tables */
765b81b6b3SRodney W. Grimes 
7714e10f99SAlfred Perlstein c_db_sym_t	db_search_symbol(db_addr_t, db_strategy_t, db_expr_t *);
785b81b6b3SRodney W. Grimes 					/* find symbol given value */
795b81b6b3SRodney W. Grimes 
8014e10f99SAlfred Perlstein void		db_symbol_values(c_db_sym_t, const char **, db_expr_t *);
815b81b6b3SRodney W. Grimes 					/* return name and value of symbol */
825b81b6b3SRodney W. Grimes 
835b81b6b3SRodney W. Grimes #define	db_find_sym_and_offset(val,namep,offp)	\
845b81b6b3SRodney W. Grimes 	db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
855b81b6b3SRodney W. Grimes 					/* find name&value given approx val */
865b81b6b3SRodney W. Grimes 
875b81b6b3SRodney W. Grimes #define	db_find_xtrn_sym_and_offset(val,namep,offp)	\
885b81b6b3SRodney W. Grimes 	db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
895b81b6b3SRodney W. Grimes 					/* ditto, but no locals */
905b81b6b3SRodney W. Grimes 
91cd508278SPedro F. Giffuni bool		db_eqname(const char *, const char *, int);
925b81b6b3SRodney W. Grimes 					/* strcmp, modulo leading char */
935b81b6b3SRodney W. Grimes 
9414e10f99SAlfred Perlstein void		db_printsym(db_expr_t, db_strategy_t);
955b81b6b3SRodney W. Grimes 					/* print closest symbol to a value */
96f23b4c91SGarrett Wollman 
97cd508278SPedro F. Giffuni bool		db_sym_numargs(c_db_sym_t, int *, char **);
984753168fSBruce Evans 
99cd508278SPedro F. Giffuni bool		X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym,
100763df836SBruce Evans 		    char **filename, int *linenum, db_expr_t off);
10114e10f99SAlfred Perlstein c_db_sym_t	X_db_lookup(db_symtab_t *stab, const char *symstr);
10214e10f99SAlfred Perlstein c_db_sym_t	X_db_search_symbol(db_symtab_t *symtab, db_addr_t off,
103763df836SBruce Evans 		    db_strategy_t strategy, db_expr_t *diffp);
104cd508278SPedro F. Giffuni bool		X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);
105763df836SBruce Evans void		X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym,
106763df836SBruce Evans 		    const char **namep, db_expr_t *valuep);
1074753168fSBruce Evans 
108*aba921bdSMitchell Horne void		db_decode_syscall(struct thread *td, u_int number);
109754cb545SMitchell Horne 
1104753168fSBruce Evans #endif /* !_DDB_DB_SYM_H_ */
111