]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/symtab.h
gdb-2.5.2
[thirdparty/binutils-gdb.git] / gdb / symtab.h
1 /* Symbol table definitions for GDB.
2 Copyright (C) 1986 Free Software Foundation, Inc.
3
4 GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5 WARRANTY. No author or distributor accepts responsibility to anyone
6 for the consequences of using it or for whether it serves any
7 particular purpose or works at all, unless he says so in writing.
8 Refer to the GDB General Public License for full details.
9
10 Everyone is granted permission to copy, modify and redistribute GDB,
11 but only under the conditions described in the GDB General Public
12 License. A copy of this license is supposed to have been given to you
13 along with GDB so you can know your rights and responsibilities. It
14 should be in a file named COPYING. Among other things, the copyright
15 notice and this notice must be preserved on all copies.
16
17 In other words, go ahead and share GDB, but don't try to stop
18 anyone else from sharing it farther. Help stamp out software hoarding!
19 */
20
21 /* An obstack to hold objects that should be freed
22 when we load a new symbol table.
23 This includes the symbols made by dbxread
24 and the types that are not permanent. */
25
26 extern struct obstack *symbol_obstack;
27
28 /* Some definitions and declarations to go with use of obstacks. */
29 #define obstack_chunk_alloc xmalloc
30 #define obstack_chunk_free free
31 extern char *xmalloc ();
32 extern void free ();
33
34 /* gdb can know one or several symbol tables at the same time;
35 the ultimate intent is to have one for each separately-compiled module.
36 Each such symbol table is recorded by a struct symtab, and they
37 are all chained together. */
38
39 /* In addition, gdb can record any number of miscellaneous undebuggable
40 functions' addresses. In a system that appends _ to function names,
41 the _'s are removed from the names stored in this table. */
42
43 struct misc_function
44 {
45 char *name;
46 CORE_ADDR address;
47 };
48
49 /* Address and length of the vector recording all misc function names/addresses. */
50
51 struct misc_function *misc_function_vector;
52 int misc_function_count;
53 \f
54 #include "symseg.h"
55
56 /* Each source file is represented by a struct symtab. */
57 /* These objects are chained through the `next' field. */
58
59 struct symtab
60 {
61 /* Chain of all existing symtabs. */
62 struct symtab *next;
63 /* List of all symbol scope blocks for this symtab. */
64 struct blockvector *blockvector;
65 /* Table mapping core addresses to line numbers for this file. */
66 struct linetable *linetable;
67 /* Vector containing all types defined for this symtab. */
68 struct typevector *typevector;
69 /* Name of this source file. */
70 char *filename;
71 /* This component says how to free the data we point to:
72 free_contents => do a tree walk and free each object.
73 free_nothing => do nothing; some other symtab will free
74 the data this one uses.
75 free_linetable => free just the linetable. */
76 enum free_code {free_nothing, free_contents, free_linetable}
77 free_code;
78 /* Pointer to one block of storage to be freed, if nonzero. */
79 char *free_ptr;
80 /* Total number of lines found in source file. */
81 int nlines;
82 /* Array mapping line number to character position. */
83 int *line_charpos;
84 /* Language of this source file. */
85 enum language language;
86 /* String of version information. May be zero. */
87 char *version;
88 /* String of compilation information. May be zero. */
89 char *compilation;
90 /* Offset within loader symbol table
91 of first local symbol for this file. */
92 int ldsymoff;
93 /* Full name of file as found by searching the source path.
94 0 if not yet known. */
95 char *fullname;
96 };
97
98 /* This is the list of struct symtab's that gdb considers current. */
99
100 struct symtab *symtab_list;
101
102 /* This symtab variable specifies the current file for printing source lines */
103
104 struct symtab *current_source_symtab;
105
106 /* This is the next line to print for listing source lines. */
107
108 int current_source_line;
109
110 #define BLOCKLIST(symtab) (symtab)->blockvector
111 #define BLOCKVECTOR(symtab) (symtab)->blockvector
112
113 #define TYPEVECTOR(symtab) (symtab)->typevector
114
115 #define LINELIST(symtab) (symtab)->linetable
116 #define LINETABLE(symtab) (symtab)->linetable
117 \f
118 /* Macros normally used to access components of symbol table structures. */
119
120 #define BLOCKLIST_NBLOCKS(blocklist) (blocklist)->nblocks
121 #define BLOCKLIST_BLOCK(blocklist,n) (blocklist)->block[n]
122 #define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
123 #define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
124
125 #define TYPEVECTOR_NTYPES(typelist) (typelist)->length
126 #define TYPEVECTOR_TYPE(typelist,n) (typelist)->type[n]
127
128 #define BLOCK_START(bl) (bl)->startaddr
129 #define BLOCK_END(bl) (bl)->endaddr
130 #define BLOCK_NSYMS(bl) (bl)->nsyms
131 #define BLOCK_SYM(bl, n) (bl)->sym[n]
132 #define BLOCK_FUNCTION(bl) (bl)->function
133 #define BLOCK_SUPERBLOCK(bl) (bl)->superblock
134
135 #define SYMBOL_NAME(symbol) (symbol)->name
136 #define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
137 #define SYMBOL_CLASS(symbol) (symbol)->class
138 #define SYMBOL_VALUE(symbol) (symbol)->value.value
139 #define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes
140 #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
141 #define SYMBOL_TYPE(symbol) (symbol)->type
142
143 /* This appears in a type's flags word
144 if it is a (pointer to a|function returning a)* built in scalar type.
145 These types are never freed. */
146 #define TYPE_FLAG_PERM 4
147
148 /* Some macros for bitfields. */
149 #define B_SET(a,x) (a[x>>5] |= (1 << (x&31)))
150 #define B_CLR(a,x) (a[x>>5] &= ~(1 << (x&31)))
151 #define B_TST(a,x) (a[x>>5] & (1 << (x&31)))
152
153 #define TYPE_NAME(thistype) (thistype)->name
154 #define TYPE_TARGET_TYPE(thistype) (thistype)->target_type
155 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
156 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
157 #define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type
158 #define TYPE_MAIN_VARIANT(thistype) (thistype)->main_variant
159 #define TYPE_LENGTH(thistype) (thistype)->length
160 #define TYPE_FLAGS(thistype) (thistype)->flags
161 #define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED)
162 #define TYPE_CODE(thistype) (thistype)->code
163 #define TYPE_NFIELDS(thistype) (thistype)->nfields
164 #define TYPE_FIELDS(thistype) (thistype)->fields
165 /* C++ */
166 #define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype
167 #define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype
168 #define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno
169 #define TYPE_FN_FIELDS(thistype) (thistype)->fn_fields
170 #define TYPE_NFN_FIELDS(thistype) (thistype)->nfn_fields
171 #define TYPE_NFN_FIELDS_TOTAL(thistype) (thistype)->nfn_fields_total
172 #define TYPE_BASECLASS(thistype) (thistype)->baseclass
173 #define TYPE_VIA_PUBLIC(thistype) (thistype)->via_public
174 #define TYPE_VIA_PROTECTED(thistype) (thistype)->via_protected
175 #define TYPE_CHAIN(thistype) (thistype)->baseclass
176
177 #define TYPE_FIELD(thistype, n) (thistype)->fields[n]
178 #define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type
179 #define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name
180 #define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type)
181 #define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos
182 #define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize
183 #define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize
184
185 #define TYPE_FIELD_PRIVATE_BITS(thistype) (thistype)->private_field_bits
186 #define TYPE_FIELD_PROTECTED_BITS(thistype) (thistype)->protected_field_bits
187 #define SET_TYPE_FIELD_PRIVATE(thistype, n) B_SET ((thistype)->private_field_bits, (n))
188 #define SET_TYPE_FIELD_PROTECTED(thistype, n) B_SET ((thistype)->protected_field_bits, (n))
189 #define TYPE_FIELD_PRIVATE(thistype, n) B_TST((thistype)->private_field_bits, (n))
190 #define TYPE_FIELD_PROTECTED(thistype, n) B_TST((thistype)->protected_field_bits, (n))
191
192 #define TYPE_HAS_DESTRUCTOR(thistype) ((thistype)->has_destructor)
193 #define TYPE_HAS_CONSTRUCTOR(thistype) ((thistype)->has_constructor)
194
195 #define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1)
196 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize)
197
198 #define TYPE_FN_FIELDLISTS(thistype) (thistype)->fn_fieldlists
199 #define TYPE_FN_FIELDLIST(thistype, n) (thistype)->fn_fieldlists[n]
200 #define TYPE_FN_FIELDLIST1(thistype, n) (thistype)->fn_fieldlists[n].fn_fields
201 #define TYPE_FN_FIELDLIST_NAME(thistype, n) (thistype)->fn_fieldlists[n].name
202 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) (thistype)->fn_fieldlists[n].length
203
204 #define TYPE_FN_FIELD(thistype) (thistype)[n]
205 #define TYPE_FN_FIELD_NAME(thistype, n) (thistype)[n].name
206 #define TYPE_FN_FIELD_TYPE(thistype, n) (thistype)[n].type
207 #define TYPE_FN_FIELD_ARGS(thistype, n) (thistype)[n].args
208 #define TYPE_FN_FIELD_PHYSNAME(thistype, n) (thistype)[n].physname
209 #define TYPE_FN_FIELD_VIRTUAL_P(thistype, n) (thistype)[n].voffset
210 #define TYPE_FN_FIELD_VOFFSET(thistype, n) ((thistype)[n].voffset-1)
211
212 #define TYPE_FN_PRIVATE_BITS(thistype) (thistype).private_fn_field_bits
213 #define TYPE_FN_PROTECTED_BITS(thistype) (thistype).protected_fn_field_bits
214 #define SET_TYPE_FN_PRIVATE(thistype, n) B_SET ((thistype).private_fn_field_bits, n)
215 #define SET_TYPE_FN_PROTECTED(thistype, n) B_SET ((thistype).protected_fn_field_bits, n)
216 #define TYPE_FN_PRIVATE(thistype, n) B_TST ((thistype).private_fn_field_bits, n)
217 #define TYPE_FN_PROTECTED(thistype, n) B_TST ((thistype).protected_fn_field_bits, n)
218 \f
219 /* Functions that work on the objects described above */
220
221 extern struct symtab *lookup_symtab ();
222 extern struct symbol *lookup_symbol ();
223 extern struct symbol *lookup_symbol_1 (), *lookup_symbol_2 ();
224 extern struct type *lookup_typename ();
225 extern struct type *lookup_unsigned_typename ();
226 extern struct type *lookup_struct ();
227 extern struct type *lookup_union ();
228 extern struct type *lookup_enum ();
229 extern struct type *lookup_pointer_type ();
230 extern struct type *lookup_function_type ();
231 extern struct symbol *block_function ();
232 extern struct symbol *find_pc_function ();
233 extern int find_pc_misc_function ();
234
235 /* C++ stuff. */
236 extern struct type *lookup_reference_type ();
237 extern struct type *lookup_member_type ();
238 extern struct type *lookup_class ();
239 /* end of C++ stuff. */
240
241 extern struct type *builtin_type_void;
242 extern struct type *builtin_type_char;
243 extern struct type *builtin_type_short;
244 extern struct type *builtin_type_int;
245 extern struct type *builtin_type_long;
246 extern struct type *builtin_type_unsigned_char;
247 extern struct type *builtin_type_unsigned_short;
248 extern struct type *builtin_type_unsigned_int;
249 extern struct type *builtin_type_unsigned_long;
250 extern struct type *builtin_type_float;
251 extern struct type *builtin_type_double;
252
253 struct symtab_and_line
254 {
255 struct symtab *symtab;
256 int line;
257 CORE_ADDR pc;
258 CORE_ADDR end;
259 };
260
261 struct symtabs_and_lines
262 {
263 struct symtab_and_line *sals;
264 int nelts;
265 };
266
267 /* Given a pc value, return line number it is in.
268 Second arg nonzero means if pc is on the boundary
269 use the previous statement's line number. */
270
271 struct symtab_and_line find_pc_line ();
272
273 /* Given a string, return the line specified by it.
274 For commands like "list" and "breakpoint". */
275
276 struct symtabs_and_lines decode_line_spec ();
277 struct symtabs_and_lines decode_line_1 ();