Initial import, 0.1 + pk 0.2.4-B1
[unix-history] / sys / ddb / db_sym.h
CommitLineData
15637ed4
RG
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/*
27 * HISTORY
28 * $Log: db_sym.h,v $
29 * Revision 1.1 1992/03/25 21:45:29 pace
30 * Initial revision
31 *
32 * Revision 2.3 91/02/05 17:07:12 mrt
33 * Changed to new Mach copyright
34 * [91/01/31 16:19:27 mrt]
35 *
36 * Revision 2.2 90/08/27 21:52:39 dbg
37 * Changed type of db_sym_t to char * - it's a better type for an
38 * opaque pointer.
39 * [90/08/22 dbg]
40 *
41 * Created.
42 * [90/08/19 af]
43 *
44 */
45/*
46 * Author: Alessandro Forin, Carnegie Mellon University
47 * Date: 8/90
48 */
49
50/*
51 * This module can handle multiple symbol tables
52 */
53typedef struct {
54 char *name; /* symtab name */
55 char *start; /* symtab location */
56 char *end;
57 char *private; /* optional machdep pointer */
58} db_symtab_t;
59
60extern db_symtab_t *db_last_symtab; /* where last symbol was found */
61
62/*
63 * Symbol representation is specific to the symtab style:
64 * BSD compilers use dbx' nlist, other compilers might use
65 * a different one
66 */
67typedef char * db_sym_t; /* opaque handle on symbols */
68#define DB_SYM_NULL ((db_sym_t)0)
69
70/*
71 * Non-stripped symbol tables will have duplicates, for instance
72 * the same string could match a parameter name, a local var, a
73 * global var, etc.
74 * We are most concern with the following matches.
75 */
76typedef int db_strategy_t; /* search strategy */
77
78#define DB_STGY_ANY 0 /* anything goes */
79#define DB_STGY_XTRN 1 /* only external symbols */
80#define DB_STGY_PROC 2 /* only procedures */
81
82extern 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/*
88 * Functions exported by the symtable module
89 */
90extern void db_add_symbol_table();
91 /* extend the list of symbol tables */
92
93extern int db_value_of_name(/* char*, db_expr_t* */);
94 /* find symbol value given name */
95
96extern db_sym_t db_search_symbol(/* db_expr_t, db_strategy_t, int* */);
97 /* find symbol given value */
98
99extern void db_symbol_values(/* db_sym_t, char**, db_expr_t* */);
100 /* return name and value of symbol */
101
102#define db_find_sym_and_offset(val,namep,offp) \
103 db_symbol_values(db_search_symbol(val,DB_STGY_ANY,offp),namep,0)
104 /* find name&value given approx val */
105
106#define db_find_xtrn_sym_and_offset(val,namep,offp) \
107 db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
108 /* ditto, but no locals */
109
110extern int db_eqname(/* char*, char*, char */);
111 /* strcmp, modulo leading char */
112
113extern void db_printsym(/* db_expr_t, db_strategy_t */);
114 /* print closest symbol to a value */