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