xref: /freebsd/sys/ddb/db_sym.h (revision afe61c15161c324a7af299a9b8457aba5afc92db)
1 /*
2  * Mach Operating System
3  * Copyright (c) 1991,1990 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie the
24  * rights to redistribute these changes.
25  *
26  *	$Id: db_sym.h,v 1.2 1993/10/16 16:47:27 rgrimes Exp $
27  */
28 
29 #ifndef _DDB_DB_SYM_H_
30 #define _DDB_DB_SYM_H_ 1
31 
32 /*
33  * 	Author: Alessandro Forin, Carnegie Mellon University
34  *	Date:	8/90
35  */
36 
37 /*
38  * This module can handle multiple symbol tables
39  */
40 typedef struct {
41 	char		*name;		/* symtab name */
42 	char		*start;		/* symtab location */
43 	char		*end;
44 	char		*private;	/* optional machdep pointer */
45 } db_symtab_t;
46 
47 extern db_symtab_t	*db_last_symtab; /* where last symbol was found */
48 
49 /*
50  * Symbol representation is specific to the symtab style:
51  * BSD compilers use dbx' nlist, other compilers might use
52  * a different one
53  */
54 typedef	char *		db_sym_t;	/* opaque handle on symbols */
55 #define	DB_SYM_NULL	((db_sym_t)0)
56 
57 /*
58  * Non-stripped symbol tables will have duplicates, for instance
59  * the same string could match a parameter name, a local var, a
60  * global var, etc.
61  * We are most concern with the following matches.
62  */
63 typedef int		db_strategy_t;	/* search strategy */
64 
65 #define	DB_STGY_ANY	0			/* anything goes */
66 #define DB_STGY_XTRN	1			/* only external symbols */
67 #define DB_STGY_PROC	2			/* only procedures */
68 
69 extern boolean_t	db_qualify_ambiguous_names;
70 					/* if TRUE, check across symbol tables
71 					 * for multiple occurrences of a name.
72 					 * Might slow down quite a bit */
73 
74 /*
75  * Functions exported by the symtable module
76  */
77 extern void	db_add_symbol_table();
78 					/* extend the list of symbol tables */
79 
80 extern int	db_value_of_name(/* char*, db_expr_t* */);
81 					/* find symbol value given name */
82 
83 extern db_sym_t	db_search_symbol(/* db_expr_t, db_strategy_t, int* */);
84 					/* find symbol given value */
85 
86 extern void	db_symbol_values(/* db_sym_t, char**, db_expr_t* */);
87 					/* return name and value of symbol */
88 
89 #define db_find_sym_and_offset(val,namep,offp)	\
90 	db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
91 					/* find name&value given approx val */
92 
93 #define db_find_xtrn_sym_and_offset(val,namep,offp)	\
94 	db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
95 					/* ditto, but no locals */
96 
97 extern int	db_eqname(/* char*, char*, char */);
98 					/* strcmp, modulo leading char */
99 
100 extern void	db_printsym(/* db_expr_t, db_strategy_t */);
101 					/* print closest symbol to a value */
102 #endif /* _DDB_DB_SYM_H_ */
103