db_sym.h revision 1.9 1 /* $NetBSD: db_sym.h,v 1.9 1998/12/04 20:18:05 thorpej Exp $ */
2
3 /*
4 * Mach Operating System
5 * Copyright (c) 1991,1990 Carnegie Mellon University
6 * All Rights Reserved.
7 *
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 *
28 * Author: Alessandro Forin, Carnegie Mellon University
29 * Date: 8/90
30 */
31
32 /*
33 * This module can handle multiple symbol tables
34 */
35 typedef struct {
36 const char *name; /* symtab name */
37 char *start; /* symtab location */
38 char *end;
39 char *private; /* optional machdep pointer */
40 } db_symtab_t;
41
42 extern db_symtab_t *db_last_symtab; /* where last symbol was found */
43
44 /*
45 * Symbol representation is specific to the symtab style:
46 * BSD compilers use dbx' nlist, other compilers might use
47 * a different one
48 */
49 typedef char * db_sym_t; /* opaque handle on symbols */
50 #define DB_SYM_NULL ((db_sym_t)0)
51
52 /*
53 * Non-stripped symbol tables will have duplicates, for instance
54 * the same string could match a parameter name, a local var, a
55 * global var, etc.
56 * We are most concern with the following matches.
57 */
58 typedef int db_strategy_t; /* search strategy */
59
60 #define DB_STGY_ANY 0 /* anything goes */
61 #define DB_STGY_XTRN 1 /* only external symbols */
62 #define DB_STGY_PROC 2 /* only procedures */
63
64 /*
65 * A symbol table may be in one of many formats. All symbol tables
66 * must be of the same format as the master kernel symbol table.
67 */
68 typedef struct {
69 const char *sym_format;
70 boolean_t (*sym_init) __P((int, void *, void *, const char *));
71 db_sym_t (*sym_lookup) __P((db_symtab_t *, char *));
72 db_sym_t (*sym_search) __P((db_symtab_t *, db_addr_t, db_strategy_t,
73 db_expr_t *));
74 void (*sym_value) __P((db_symtab_t *, db_sym_t, char **,
75 db_expr_t *));
76 boolean_t (*sym_line_at_pc) __P((db_symtab_t *, db_sym_t,
77 char **, int *, db_expr_t));
78 boolean_t (*sym_numargs) __P((db_symtab_t *, db_sym_t, int *,
79 char **));
80 } db_symformat_t;
81
82 extern boolean_t db_qualify_ambiguous_names;
83 /* if TRUE, check across symbol tables
84 * for multiple occurrences of a name.
85 * Might slow down quite a bit */
86
87 extern unsigned int db_maxoff; /* like gdb's "max-symbolic-offset" */
88 /*
89 * Functions exported by the symtable module
90 */
91 int db_add_symbol_table __P((char *, char *, const char *, char *));
92 /* extend the list of symbol tables */
93
94 void db_del_symbol_table __P((char *));
95 /* remove a symbol table from list */
96
97 boolean_t db_eqname __P((char *, char *, int));
98 /* strcmp, modulo leading char */
99
100 int db_value_of_name __P((char *, db_expr_t *));
101 /* find symbol value given name */
102
103 db_sym_t db_lookup __P((char *));
104
105 boolean_t db_symbol_is_ambiguous __P((db_sym_t));
106
107 db_sym_t db_search_symbol __P((db_addr_t, db_strategy_t, db_expr_t *));
108 /* find symbol given value */
109
110 void db_symbol_values __P((db_sym_t, char **, db_expr_t *));
111 /* return name and value of symbol */
112
113 #define db_find_sym_and_offset(val,namep,offp) \
114 db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
115 /* find name&value given approx val */
116
117 #define db_find_xtrn_sym_and_offset(val,namep,offp) \
118 db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
119 /* ditto, but no locals */
120
121 void db_printsym __P((db_expr_t, db_strategy_t));
122 /* print closest symbol to a value */
123
124 boolean_t db_line_at_pc __P((db_sym_t, char **, int *, db_expr_t));
125
126 int db_sym_numargs __P((db_sym_t, int *, char **));
127
128 #ifdef DB_AOUT_SYMBOLS
129 extern db_symformat_t db_symformat_aout;
130 #endif
131 #ifdef DB_ELF_SYMBOLS
132 extern db_symformat_t db_symformat_elf;
133 #endif
134