|
|
1.1 root 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 "AS IS"
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 [email protected]
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 Mellon
24: * the rights to redistribute these changes.
25: */
26: /*
27: * Author: Alessandro Forin, Carnegie Mellon University
28: * Date: 8/90
29: */
30:
1.1.1.2 root 31: #ifndef _DDB_DB_SYM_H_
32: #define _DDB_DB_SYM_H_
33:
1.1 root 34: #include <mach/boolean.h>
35: #include <mach/machine/vm_types.h>
36: #include <machine/db_machdep.h>
37:
38: /*
39: * This module can handle multiple symbol tables,
40: * of multiple types, at the same time
41: */
42: #define SYMTAB_NAME_LEN 32
43:
44: typedef struct {
45: int type;
46: #define SYMTAB_AOUT 0
47: #define SYMTAB_COFF 1
48: #define SYMTAB_MACHDEP 2
1.1.1.3 ! root 49: #define SYMTAB_ELF 3
1.1 root 50: char *start; /* symtab location */
51: char *end;
52: char *private; /* optional machdep pointer */
53: char *map_pointer; /* symbols are for this map only,
54: if not null */
55: char name[SYMTAB_NAME_LEN];
56: /* symtab name */
57: } db_symtab_t;
58:
59: extern db_symtab_t *db_last_symtab; /* where last symbol was found */
60:
61: /*
62: * Symbol representation is specific to the symtab style:
63: * BSD compilers use dbx' nlist, other compilers might use
64: * a different one
65: */
66: typedef char * db_sym_t; /* opaque handle on symbols */
67: #define DB_SYM_NULL ((db_sym_t)0)
68:
69: /*
70: * Non-stripped symbol tables will have duplicates, for instance
71: * the same string could match a parameter name, a local var, a
72: * global var, etc.
73: * We are most concerned with the following matches.
74: */
75: typedef int db_strategy_t; /* search strategy */
76:
77: #define DB_STGY_ANY 0 /* anything goes */
78: #define DB_STGY_XTRN 1 /* only external symbols */
79: #define DB_STGY_PROC 2 /* only procedures */
80:
81: extern boolean_t db_qualify_ambiguous_names;
82: /* if TRUE, check across symbol tables
83: * for multiple occurrences of a name.
84: * Might slow down quite a bit
85: * ..but the machine has nothing
86: * else to do, now does it ? */
87:
88: /*
89: * Functions exported by the symtable module
90: */
91:
92: /* extend the list of symbol tables */
93:
94: extern boolean_t db_add_symbol_table( int type,
95: char * start,
96: char * end,
97: char *name,
98: char *ref,
99: char *map_pointer );
100:
101: /* find symbol value given name */
102:
103: extern int db_value_of_name( char* name, db_expr_t* valuep);
104:
105: /* find symbol given value */
106:
107: extern db_sym_t db_search_task_symbol( db_addr_t val,
108: db_strategy_t strategy,
109: db_addr_t *offp,
110: task_t task );
111:
112: /* return name and value of symbol */
113:
114: extern void db_symbol_values( db_symtab_t *stab,
115: db_sym_t sym,
116: char** namep,
117: db_expr_t* valuep);
118:
119: /* find name&value given approx val */
120:
121: #define db_find_sym_and_offset(val,namep,offp) \
1.1.1.2 root 122: do { \
123: db_sym_t s; \
124: db_symbol_values(0, s = db_search_symbol(val,DB_STGY_ANY,offp) \
125: ,namep,0); \
126: db_free_symbol(s); \
127: } while(0);
128:
1.1 root 129:
130: /* ditto, but no locals */
131: #define db_find_xtrn_sym_and_offset(val,namep,offp) \
1.1.1.2 root 132: do { \
133: db_sym_t s; \
134: db_symbol_values(0, s = db_search_symbol(val,DB_STGY_XTRN,offp) \
135: ,namep,0); \
136: db_free_symbol(s); \
137: } while(0);
1.1 root 138:
139: /* find name&value given approx val */
140:
141: #define db_find_task_sym_and_offset(val,namep,offp,task) \
1.1.1.2 root 142: do { \
143: db_sym_t s; \
144: db_symbol_values(0, s = db_search_task_symbol(val,DB_STGY_ANY \
145: ,offp,task), \
146: namep, 0); \
147: db_free_symbol(s); \
148: } while(0);
1.1 root 149:
150: /* ditto, but no locals */
151: #define db_find_xtrn_task_sym_and_offset(val,namep,offp,task) \
1.1.1.2 root 152: do { \
153: db_sym_t s; \
154: db_symbol_values(0, s = db_search_task_symbol(val,DB_STGY_XTRN \
155: ,offp,task), \
156: namep,0); \
157: db_free_symbol(s); \
158: } while(0);
1.1 root 159:
160: /* find symbol in current task */
161: #define db_search_symbol(val,strgy,offp) \
162: db_search_task_symbol(val,strgy,offp,0)
163:
164: /* strcmp, modulo leading char */
1.1.1.3 ! root 165: extern boolean_t db_eqname( const char* src, const char* dst, char c );
1.1 root 166:
167: /* print closest symbol to a value */
1.1.1.3 ! root 168: extern void db_task_printsym( db_addr_t off,
1.1 root 169: db_strategy_t strategy,
170: task_t task);
171:
172: /* print closest symbol to a value */
173: extern void db_printsym( db_expr_t off, db_strategy_t strategy);
174:
1.1.1.2 root 175: /* free a symbol */
176: extern void db_free_symbol(db_sym_t s);
177:
178:
1.1 root 179: /*
180: * Symbol table switch, defines the interface
181: * to symbol-table specific routines.
182: */
183:
184: extern struct db_sym_switch {
185:
186: boolean_t (*init)(
1.1.1.2 root 187: char *start,
1.1 root 188: char *end,
189: char *name,
190: char *task_addr
1.1.1.2 root 191: );
1.1 root 192:
193: db_sym_t (*lookup)(
1.1.1.2 root 194: db_symtab_t *stab,
1.1 root 195: char *symstr
1.1.1.2 root 196: );
1.1 root 197: db_sym_t (*search_symbol)(
1.1.1.2 root 198: db_symtab_t *stab,
1.1 root 199: db_addr_t off,
200: db_strategy_t strategy,
201: db_expr_t *diffp
1.1.1.2 root 202: );
1.1 root 203:
204: boolean_t (*line_at_pc)(
1.1.1.2 root 205: db_symtab_t *stab,
1.1 root 206: db_sym_t sym,
207: char **file,
208: int *line,
1.1.1.3 ! root 209: db_addr_t pc
1.1.1.2 root 210: );
1.1 root 211:
212: void (*symbol_values)(
1.1.1.2 root 213: db_symtab_t *stab,
214: db_sym_t sym,
1.1 root 215: char **namep,
216: db_expr_t *valuep
1.1.1.2 root 217: );
1.1 root 218:
1.1.1.2 root 219: void (*free_symbol)(
220: db_sym_t sym
221: );
1.1 root 222: } x_db[];
223:
224: #ifndef symtab_type
225: #define symtab_type(s) SYMTAB_AOUT
226: #endif
227:
228: #define X_db_sym_init(s,e,n,t) x_db[symtab_type(s)].init(s,e,n,t)
229: #define X_db_lookup(s,n) x_db[(s)->type].lookup(s,n)
230: #define X_db_search_symbol(s,o,t,d) x_db[(s)->type].search_symbol(s,o,t,d)
231: #define X_db_line_at_pc(s,p,f,l,a) x_db[(s)->type].line_at_pc(s,p,f,l,a)
1.1.1.2 root 232: #define X_db_symbol_values(s,p,n,v) x_db[(s)->type].symbol_values(s,p,n,v)
233: #define X_db_free_symbol(s,m) x_db[(s)->type].free_symbol(m)
234:
235: extern boolean_t db_line_at_pc(
236: db_sym_t sym,
237: char **filename,
238: int *linenum,
1.1.1.3 ! root 239: db_addr_t pc);
1.1.1.2 root 240:
1.1.1.3 ! root 241: extern boolean_t aout_db_sym_init(
! 242: char *symtab,
! 243: char *esymtab,
! 244: char *name,
! 245: char *task_addr);
! 246:
! 247: extern boolean_t elf_db_sym_init (
! 248: unsigned shdr_num,
! 249: vm_size_t shdr_size,
! 250: vm_offset_t shdr_addr,
! 251: unsigned shdr_shndx,
! 252: char *name,
! 253: char *task_addr);
! 254:
! 255: db_sym_t db_lookup(char *);
! 256:
! 257: db_sym_t
! 258: db_search_in_task_symbol(
! 259: db_addr_t val,
! 260: db_strategy_t strategy,
! 261: db_addr_t *offp,
! 262: task_t task);
! 263:
! 264: extern db_sym_t
! 265: db_sym_parse_and_lookup(
! 266: db_sym_t (*func)(),
! 267: db_symtab_t *symtab,
! 268: char *symstr);
! 269:
! 270: #endif /* _DDB_DB_SYM_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.