Commit | Line | Data |
---|---|---|
bd5635a1 | 1 | /* Symbol table definitions for GDB. |
4a35d6e9 | 2 | Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc. |
bd5635a1 RP |
3 | |
4 | This file is part of GDB. | |
5 | ||
4a35d6e9 | 6 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 7 | it under the terms of the GNU General Public License as published by |
4a35d6e9 FF |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
bd5635a1 | 10 | |
4a35d6e9 | 11 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
4a35d6e9 FF |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
bd5635a1 RP |
19 | |
20 | #if !defined (SYMTAB_H) | |
21 | #define SYMTAB_H 1 | |
22 | #include <obstack.h> | |
23 | ||
24 | /* An obstack to hold objects that should be freed | |
25 | when we load a new symbol table. | |
26 | This includes the symbols made by dbxread | |
27 | and the types that are not permanent. */ | |
28 | ||
29 | extern struct obstack *symbol_obstack; | |
30 | extern struct obstack *psymbol_obstack; | |
31 | ||
32 | /* Some definitions and declarations to go with use of obstacks. */ | |
33 | #define obstack_chunk_alloc xmalloc | |
34 | #define obstack_chunk_free free | |
35 | #ifdef __STDC__ | |
36 | extern void *xmalloc (); | |
37 | #else | |
38 | extern char *xmalloc (); | |
39 | #endif | |
40 | extern void free (); | |
41 | ||
42 | /* Some macros for char-based bitfields. */ | |
43 | #define B_SET(a,x) (a[x>>3] |= (1 << (x&7))) | |
44 | #define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7))) | |
45 | #define B_TST(a,x) (a[x>>3] & (1 << (x&7))) | |
46 | #define B_TYPE unsigned char | |
47 | #define B_BYTES(x) ( 1 + ((x)>>3) ) | |
48 | #define B_CLRALL(a,x) bzero (a, B_BYTES(x)) | |
49 | ||
50 | /* gdb can know one or several symbol tables at the same time; | |
51 | the ultimate intent is to have one for each separately-compiled module. | |
52 | Each such symbol table is recorded by a struct symtab, and they | |
53 | are all chained together. */ | |
54 | ||
55 | /* In addition, gdb can record any number of miscellaneous undebuggable | |
56 | functions' addresses. In a system that appends _ to function names, | |
57 | the _'s are removed from the names stored in this table. */ | |
58 | ||
59 | /* Actually, the misc function list is used to store *all* of the | |
60 | global symbols (text, data, bss, and abs). It is sometimes used | |
61 | to figure out what symtabs to read in. The "type" field is used | |
4a35d6e9 | 62 | occasionally. Calling it the misc "function" vector is now a misnomer. |
bd5635a1 RP |
63 | |
64 | The misc_info field is available for machine-specific information | |
65 | that can be cached along with a misc function vector entry. The | |
66 | AMD 29000 tdep.c uses it to remember things it has decoded from the | |
67 | instructions in the function header, so it doesn't have to rederive | |
68 | the info constantly (over a serial line). It is initialized to zero | |
69 | and stays that way until target-dependent code sets it. */ | |
70 | ||
71 | enum misc_function_type {mf_unknown = 0, mf_text, mf_data, mf_bss, mf_abs}; | |
72 | ||
73 | struct misc_function | |
74 | { | |
75 | char *name; | |
76 | CORE_ADDR address; | |
77 | char *misc_info; /* Random pointer to misc info. void * but for old C */ | |
78 | enum misc_function_type type; | |
79 | }; | |
80 | ||
81 | /* Address and length of the vector recording all misc function names/addresses. */ | |
82 | ||
83 | struct misc_function *misc_function_vector; | |
84 | int misc_function_count; | |
85 | \f | |
bd5635a1 RP |
86 | /* Different kinds of data types are distinguished by the `code' field. */ |
87 | ||
88 | enum type_code | |
89 | { | |
90 | TYPE_CODE_UNDEF, /* Not used; catches errors */ | |
91 | TYPE_CODE_PTR, /* Pointer type */ | |
92 | TYPE_CODE_ARRAY, /* Array type, lower bound zero */ | |
93 | TYPE_CODE_STRUCT, /* C struct or Pascal record */ | |
94 | TYPE_CODE_UNION, /* C union or Pascal variant part */ | |
95 | TYPE_CODE_ENUM, /* Enumeration type */ | |
96 | TYPE_CODE_FUNC, /* Function type */ | |
97 | TYPE_CODE_INT, /* Integer type */ | |
98 | TYPE_CODE_FLT, /* Floating type */ | |
99 | TYPE_CODE_VOID, /* Void type (values zero length) */ | |
100 | TYPE_CODE_SET, /* Pascal sets */ | |
101 | TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */ | |
102 | TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */ | |
103 | TYPE_CODE_ERROR, /* Unknown type */ | |
104 | ||
105 | /* C++ */ | |
106 | TYPE_CODE_MEMBER, /* Member type */ | |
107 | TYPE_CODE_METHOD, /* Method type */ | |
108 | TYPE_CODE_REF, /* C++ Reference types */ | |
4a35d6e9 FF |
109 | |
110 | /* Modula-2 */ | |
111 | TYPE_CODE_CHAR, /* *real* character type */ | |
112 | TYPE_CODE_BOOL, /* Builtin Modula-2 BOOLEAN */ | |
bd5635a1 RP |
113 | }; |
114 | ||
115 | /* This appears in a type's flags word for an unsigned integer type. */ | |
116 | #define TYPE_FLAG_UNSIGNED 1 | |
117 | /* This appears in a type's flags word | |
118 | if it is a (pointer to a|function returning a)* built in scalar type. | |
119 | These types are never freed. */ | |
120 | #define TYPE_FLAG_PERM 4 | |
121 | /* This appears in a type's flags word if it is a stub type (eg. if | |
122 | someone referenced a type that wasn't definined in a source file | |
123 | via (struct sir_not_appearing_in_this_film *)). */ | |
124 | #define TYPE_FLAG_STUB 8 | |
125 | /* Set when a class has a constructor defined */ | |
126 | #define TYPE_FLAG_HAS_CONSTRUCTOR 256 | |
127 | /* Set when a class has a destructor defined */ | |
128 | #define TYPE_FLAG_HAS_DESTRUCTOR 512 | |
129 | ||
130 | struct type | |
131 | { | |
132 | /* Code for kind of type */ | |
133 | enum type_code code; | |
134 | /* Name of this type, or zero if none. | |
135 | This is used for printing only, except by poorly designed C++ code. | |
136 | Type names specified as input are defined by symbols. */ | |
137 | char *name; | |
138 | /* Length in bytes of storage for a value of this type */ | |
139 | unsigned length; | |
140 | /* For a pointer type, describes the type of object pointed to. | |
141 | For an array type, describes the type of the elements. | |
142 | For a function or method type, describes the type of the value. | |
143 | For a range type, describes the type of the full range. | |
144 | Unused otherwise. */ | |
145 | struct type *target_type; | |
146 | /* Type that is a pointer to this type. | |
147 | Zero if no such pointer-to type is known yet. | |
148 | The debugger may add the address of such a type | |
149 | if it has to construct one later. */ | |
150 | struct type *pointer_type; | |
151 | /* C++: also need a reference type. */ | |
152 | struct type *reference_type; | |
153 | struct type **arg_types; | |
154 | ||
155 | /* Type that is a function returning this type. | |
156 | Zero if no such function type is known here. | |
157 | The debugger may add the address of such a type | |
158 | if it has to construct one later. */ | |
159 | struct type *function_type; | |
160 | ||
161 | /* Handling of pointers to members: | |
162 | TYPE_MAIN_VARIANT is used for pointer and pointer | |
163 | to member types. Normally it the value of the address of its | |
164 | containing type. However, for pointers to members, we must be | |
165 | able to allocate pointer to member types and look them up | |
166 | from some place of reference. | |
167 | NEXT_VARIANT is the next element in the chain. | |
168 | ||
169 | A long time ago (Jul 88; GDB 2.5) Tiemann said that main_variant | |
170 | may no longer be necessary and that he might eliminate it. I don't | |
171 | know whether this is still true (or ever was). */ | |
172 | struct type *main_variant, *next_variant; | |
173 | ||
174 | /* Flags about this type. */ | |
175 | short flags; | |
176 | /* Number of fields described for this type */ | |
177 | short nfields; | |
178 | /* For structure and union types, a description of each field. | |
179 | For set and pascal array types, there is one "field", | |
180 | whose type is the domain type of the set or array. | |
181 | For range types, there are two "fields", | |
182 | the minimum and maximum values (both inclusive). | |
183 | For enum types, each possible value is described by one "field". | |
184 | ||
185 | Using a pointer to a separate array of fields | |
186 | allows all types to have the same size, which is useful | |
187 | because we can allocate the space for a type before | |
188 | we know what to put in it. */ | |
189 | struct field | |
190 | { | |
191 | /* Position of this field, counting in bits from start of | |
192 | containing structure. For a function type, this is the | |
193 | position in the argument list of this argument. | |
194 | For a range bound or enum value, this is the value itself. */ | |
195 | int bitpos; | |
196 | /* Size of this field, in bits, or zero if not packed. | |
197 | For an unpacked field, the field's type's length | |
198 | says how many bytes the field occupies. */ | |
199 | int bitsize; | |
200 | /* In a struct or enum type, type of this field. | |
201 | In a function type, type of this argument. | |
202 | In an array type, the domain-type of the array. */ | |
203 | struct type *type; | |
204 | /* Name of field, value or argument. | |
205 | Zero for range bounds and array domains. */ | |
206 | char *name; | |
207 | } *fields; | |
208 | ||
209 | /* C++ */ | |
210 | B_TYPE *virtual_field_bits; /* if base class is virtual */ | |
211 | B_TYPE *private_field_bits; | |
212 | B_TYPE *protected_field_bits; | |
213 | ||
214 | /* Number of methods described for this type */ | |
215 | short nfn_fields; | |
216 | /* Number of base classes this type derives from. */ | |
217 | short n_baseclasses; | |
218 | ||
219 | /* Number of methods described for this type plus all the | |
220 | methods that it derives from. */ | |
221 | int nfn_fields_total; | |
222 | ||
223 | /* For classes, structures, and unions, a description of each field, | |
224 | which consists of an overloaded name, followed by the types of | |
225 | arguments that the method expects, and then the name after it | |
226 | has been renamed to make it distinct. */ | |
227 | struct fn_fieldlist | |
228 | { | |
229 | /* The overloaded name. */ | |
230 | char *name; | |
231 | /* The number of methods with this name. */ | |
232 | int length; | |
233 | /* The list of methods. */ | |
234 | struct fn_field | |
235 | { | |
236 | #if 0 | |
237 | /* The overloaded name */ | |
238 | char *name; | |
239 | #endif | |
240 | /* The return value of the method */ | |
241 | struct type *type; | |
242 | /* The argument list */ | |
243 | struct type **args; | |
244 | /* The name after it has been processed */ | |
245 | char *physname; | |
246 | ||
247 | /* For virtual functions. */ | |
248 | /* First baseclass that defines this virtual function. */ | |
249 | struct type *fcontext; | |
bcccec8c PB |
250 | unsigned int is_const : 1; |
251 | unsigned int is_volatile : 1; | |
bd5635a1 | 252 | /* Index into that baseclass's virtual function table, |
bcccec8c PB |
253 | minus 2; else if static: VOFFSET_STATIC; else: 0. */ |
254 | unsigned long voffset : 30; | |
255 | # define VOFFSET_STATIC 1 | |
bd5635a1 RP |
256 | } *fn_fields; |
257 | ||
258 | B_TYPE *private_fn_field_bits; | |
259 | B_TYPE *protected_fn_field_bits; | |
260 | ||
261 | } *fn_fieldlists; | |
262 | ||
263 | unsigned char via_protected; | |
264 | unsigned char via_public; | |
265 | ||
266 | /* For types with virtual functions, VPTR_BASETYPE is the base class which | |
267 | defined the virtual function table pointer. VPTR_FIELDNO is | |
268 | the field number of that pointer in the structure. | |
269 | ||
270 | For types that are pointer to member types, VPTR_BASETYPE | |
271 | ifs the type that this pointer is a member of. | |
272 | ||
273 | Unused otherwise. */ | |
274 | struct type *vptr_basetype; | |
275 | ||
276 | int vptr_fieldno; | |
277 | }; | |
278 | \f | |
279 | /* All of the name-scope contours of the program | |
280 | are represented by `struct block' objects. | |
281 | All of these objects are pointed to by the blockvector. | |
282 | ||
283 | Each block represents one name scope. | |
284 | Each lexical context has its own block. | |
285 | ||
286 | The first two blocks in the blockvector are special. | |
287 | The first one contains all the symbols defined in this compilation | |
288 | whose scope is the entire program linked together. | |
289 | The second one contains all the symbols whose scope is the | |
290 | entire compilation excluding other separate compilations. | |
291 | In C, these correspond to global symbols and static symbols. | |
292 | ||
293 | Each block records a range of core addresses for the code that | |
294 | is in the scope of the block. The first two special blocks | |
295 | give, for the range of code, the entire range of code produced | |
296 | by the compilation that the symbol segment belongs to. | |
297 | ||
298 | The blocks appear in the blockvector | |
299 | in order of increasing starting-address, | |
300 | and, within that, in order of decreasing ending-address. | |
301 | ||
302 | This implies that within the body of one function | |
303 | the blocks appear in the order of a depth-first tree walk. */ | |
304 | ||
305 | struct blockvector | |
306 | { | |
307 | /* Number of blocks in the list. */ | |
308 | int nblocks; | |
309 | /* The blocks themselves. */ | |
310 | struct block *block[1]; | |
311 | }; | |
312 | ||
92a29b47 JG |
313 | /* Special block numbers */ |
314 | #define GLOBAL_BLOCK 0 | |
315 | #define STATIC_BLOCK 1 | |
316 | #define FIRST_LOCAL_BLOCK 2 | |
317 | ||
bd5635a1 RP |
318 | struct block |
319 | { | |
320 | /* Addresses in the executable code that are in this block. | |
321 | Note: in an unrelocated symbol segment in a file, | |
322 | these are always zero. They can be filled in from the | |
323 | N_LBRAC and N_RBRAC symbols in the loader symbol table. */ | |
324 | CORE_ADDR startaddr, endaddr; | |
325 | /* The symbol that names this block, | |
326 | if the block is the body of a function; | |
327 | otherwise, zero. | |
328 | Note: In an unrelocated symbol segment in an object file, | |
329 | this field may be zero even when the block has a name. | |
330 | That is because the block is output before the name | |
331 | (since the name resides in a higher block). | |
332 | Since the symbol does point to the block (as its value), | |
333 | it is possible to find the block and set its name properly. */ | |
334 | struct symbol *function; | |
335 | /* The `struct block' for the containing block, or 0 if none. */ | |
336 | /* Note that in an unrelocated symbol segment in an object file | |
337 | this pointer may be zero when the correct value should be | |
338 | the second special block (for symbols whose scope is one compilation). | |
339 | This is because the compiler ouptuts the special blocks at the | |
340 | very end, after the other blocks. */ | |
341 | struct block *superblock; | |
342 | /* A flag indicating whether or not the fucntion corresponding | |
343 | to this block was compiled with gcc or not. If there is no | |
344 | function corresponding to this block, this meaning of this flag | |
345 | is undefined. (In practice it will be 1 if the block was created | |
346 | while processing a file compiled with gcc and 0 when not). */ | |
347 | unsigned char gcc_compile_flag; | |
348 | /* Number of local symbols. */ | |
349 | int nsyms; | |
350 | /* The symbols. */ | |
351 | struct symbol *sym[1]; | |
352 | }; | |
353 | \f | |
354 | /* Represent one symbol name; a variable, constant, function or typedef. */ | |
355 | ||
356 | /* Different name spaces for symbols. Looking up a symbol specifies | |
357 | a namespace and ignores symbol definitions in other name spaces. | |
358 | ||
359 | VAR_NAMESPACE is the usual namespace. | |
360 | In C, this contains variables, function names, typedef names | |
361 | and enum type values. | |
362 | ||
363 | STRUCT_NAMESPACE is used in C to hold struct, union and enum type names. | |
364 | Thus, if `struct foo' is used in a C program, | |
365 | it produces a symbol named `foo' in the STRUCT_NAMESPACE. | |
366 | ||
367 | LABEL_NAMESPACE may be used for names of labels (for gotos); | |
368 | currently it is not used and labels are not recorded at all. */ | |
369 | ||
370 | /* For a non-global symbol allocated statically, | |
371 | the correct core address cannot be determined by the compiler. | |
372 | The compiler puts an index number into the symbol's value field. | |
373 | This index number can be matched with the "desc" field of | |
374 | an entry in the loader symbol table. */ | |
375 | ||
376 | enum namespace | |
377 | { | |
378 | UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE, | |
379 | }; | |
380 | ||
381 | /* An address-class says where to find the value of a symbol. */ | |
382 | ||
383 | enum address_class | |
384 | { | |
385 | LOC_UNDEF, /* Not used; catches errors */ | |
386 | LOC_CONST, /* Value is constant int SYMBOL_VALUE, host byteorder */ | |
387 | LOC_STATIC, /* Value is at fixed address SYMBOL_VALUE_ADDRESS */ | |
388 | LOC_REGISTER, /* Value is in register */ | |
389 | LOC_ARG, /* Value is at spec'd offset in arglist */ | |
390 | LOC_REF_ARG, /* Value address is at spec'd offset in arglist. */ | |
391 | LOC_REGPARM, /* Value is at spec'd offset in register window */ | |
392 | LOC_LOCAL, /* Value is at spec'd offset in stack frame */ | |
393 | LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE | |
394 | Symbols in the namespace STRUCT_NAMESPACE | |
395 | all have this class. */ | |
396 | LOC_LABEL, /* Value is address SYMBOL_VALUE_ADDRESS in the code */ | |
397 | LOC_BLOCK, /* Value is address SYMBOL_VALUE_BLOCK of a | |
398 | `struct block'. Function names have this class. */ | |
bd5635a1 RP |
399 | LOC_CONST_BYTES, /* Value is a constant byte-sequence pointed to by |
400 | SYMBOL_VALUE_ADDRESS, in target byte order. */ | |
401 | LOC_LOCAL_ARG, /* Value is arg at spec'd offset in stack frame. | |
402 | Differs from LOC_LOCAL in that symbol is an | |
403 | argument; differs from LOC_ARG in that we find it | |
404 | in the frame (FRAME_LOCALS_ADDRESS), not in the | |
405 | arglist (FRAME_ARGS_ADDRESS). Added for i960, | |
406 | which passes args in regs then copies to frame. */ | |
407 | }; | |
408 | ||
409 | struct symbol | |
410 | { | |
411 | /* Symbol name */ | |
412 | char *name; | |
413 | /* Name space code. */ | |
414 | enum namespace namespace; | |
415 | /* Address class */ | |
416 | enum address_class class; | |
417 | /* Data type of value */ | |
418 | struct type *type; | |
419 | ||
420 | /* Line number of definition. */ | |
421 | unsigned short line; | |
422 | ||
423 | /* constant value, or address if static, or register number, | |
424 | or offset in arguments, or offset in stack frame. All of | |
425 | these are in host byte order (though what they point to might | |
426 | be in target byte order, e.g. LOC_CONST_BYTES). */ | |
427 | union | |
428 | { | |
429 | long value; /* for LOC_CONST, LOC_REGISTER, LOC_ARG, | |
430 | LOC_REF_ARG, LOC_REGPARM, LOC_LOCAL */ | |
431 | struct block *block; /* for LOC_BLOCK */ | |
432 | char *bytes; /* for LOC_CONST_BYTES */ | |
4a35d6e9 | 433 | CORE_ADDR address; /* for LOC_STATIC, LOC_LABEL */ |
bd5635a1 RP |
434 | struct symbol *chain; /* for opaque typedef struct chain */ |
435 | } | |
436 | value; | |
437 | }; | |
438 | ||
439 | ||
440 | /* A partial_symbol records the name, namespace, and address class of | |
441 | symbols whose types we have not parsed yet. For functions, it also | |
442 | contains their memory address, so we can find them from a PC value. | |
443 | Each partial_symbol sits in a partial_symtab, all of which are chained | |
444 | on the partial_symtab_list and which points to the corresponding | |
445 | normal symtab once the partial_symtab has been referenced. */ | |
446 | ||
447 | struct partial_symbol | |
448 | { | |
449 | /* Symbol name */ | |
450 | char *name; | |
451 | /* Name space code. */ | |
452 | enum namespace namespace; | |
453 | /* Address class (for info_symbols) */ | |
454 | enum address_class class; | |
455 | /* Value (only used for static functions currently). Done this | |
456 | way so that we can use the struct symbol macros. | |
457 | Note that the address of a function is SYMBOL_VALUE_ADDRESS (pst) | |
458 | in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st)) | |
459 | in a symbol table. */ | |
460 | union | |
461 | { | |
462 | long value; | |
463 | CORE_ADDR address; | |
464 | } | |
465 | value; | |
466 | }; | |
467 | \f | |
468 | /* Source-file information. | |
469 | This describes the relation between source files and line numbers | |
470 | and addresses in the program text. */ | |
471 | ||
472 | struct sourcevector | |
473 | { | |
474 | int length; /* Number of source files described */ | |
475 | struct source *source[1]; /* Descriptions of the files */ | |
476 | }; | |
477 | ||
478 | /* Each item represents a line-->pc (or the reverse) mapping. This is | |
479 | somewhat more wasteful of space than one might wish, but since only | |
480 | the files which are actually debugged are read in to core, we don't | |
481 | waste much space. | |
482 | ||
483 | Each item used to be an int; either minus a line number, or a | |
484 | program counter. If it represents a line number, that is the line | |
485 | described by the next program counter value. If it is positive, it | |
486 | is the program counter at which the code for the next line starts. */ | |
487 | ||
488 | struct linetable_entry | |
489 | { | |
490 | int line; | |
491 | CORE_ADDR pc; | |
492 | }; | |
493 | ||
494 | struct linetable | |
495 | { | |
496 | int nitems; | |
497 | struct linetable_entry item[1]; | |
498 | }; | |
499 | ||
500 | /* All the information on one source file. */ | |
501 | ||
502 | struct source | |
503 | { | |
504 | char *name; /* Name of file */ | |
505 | struct linetable contents; | |
506 | }; | |
507 | ||
508 | /* Each source file is represented by a struct symtab. | |
509 | These objects are chained through the `next' field. */ | |
510 | ||
511 | struct symtab | |
512 | { | |
513 | /* Chain of all existing symtabs. */ | |
514 | struct symtab *next; | |
515 | /* List of all symbol scope blocks for this symtab. */ | |
516 | struct blockvector *blockvector; | |
4137c5fc JG |
517 | /* Table mapping core addresses to line numbers for this file. |
518 | Can be NULL if none. */ | |
bd5635a1 | 519 | struct linetable *linetable; |
bd5635a1 RP |
520 | /* Name of this source file. */ |
521 | char *filename; | |
522 | /* Directory in which it was compiled, or NULL if we don't know. */ | |
523 | char *dirname; | |
524 | /* This component says how to free the data we point to: | |
525 | free_contents => do a tree walk and free each object. | |
526 | free_nothing => do nothing; some other symtab will free | |
527 | the data this one uses. | |
528 | free_linetable => free just the linetable. */ | |
529 | enum free_code {free_nothing, free_contents, free_linetable} | |
530 | free_code; | |
531 | /* Pointer to one block of storage to be freed, if nonzero. */ | |
532 | /* This is IN ADDITION to the action indicated by free_code. */ | |
533 | char *free_ptr; | |
534 | /* Total number of lines found in source file. */ | |
535 | int nlines; | |
536 | /* Array mapping line number to character position. */ | |
537 | int *line_charpos; | |
538 | /* Language of this source file. */ | |
539 | enum language language; | |
540 | /* String of version information. May be zero. */ | |
541 | char *version; | |
542 | /* Full name of file as found by searching the source path. | |
543 | 0 if not yet known. */ | |
544 | char *fullname; | |
8aa13b87 JK |
545 | |
546 | /* Anything extra for this symtab. This is for target machines | |
547 | with special debugging info of some sort (which cannot just | |
548 | be represented in a normal symtab). */ | |
549 | #if defined (EXTRA_SYMTAB_INFO) | |
550 | EXTRA_SYMTAB_INFO | |
551 | #endif | |
bd5635a1 RP |
552 | }; |
553 | ||
554 | /* Each source file that has not been fully read in is represented by | |
555 | a partial_symtab. This contains the information on where in the | |
556 | executable the debugging symbols for a specific file are, and a | |
557 | list of names of global symbols which are located in this file. | |
558 | They are all chained on partial_symtab_list. | |
559 | ||
560 | Even after the source file has been read into a symtab, the | |
561 | partial_symtab remains around. They are allocated on an obstack, | |
562 | psymbol_obstack. FIXME, this is bad for dynamic linking or VxWorks- | |
563 | style execution of a bunch of .o's. */ | |
564 | struct partial_symtab | |
565 | { | |
566 | /* Chain of all existing partial symtabs. */ | |
567 | struct partial_symtab *next; | |
568 | /* Name of the source file which this partial_symtab defines */ | |
569 | char *filename; | |
570 | ||
571 | /* Name of the symbol file from which symbols should be read. */ | |
572 | char *symfile_name; | |
573 | /* Address relative to which the symbols in this file are. Need to | |
574 | relocate by this amount when reading in symbols from the symbol | |
575 | file. */ | |
576 | CORE_ADDR addr; | |
bd5635a1 RP |
577 | /* Range of text addresses covered by this file; texthigh is the |
578 | beginning of the next section. */ | |
579 | CORE_ADDR textlow, texthigh; | |
580 | /* Array of pointers to all of the partial_symtab's which this one | |
581 | depends on. Since this array can only be set to previous or | |
582 | the current (?) psymtab, this dependency tree is guaranteed not | |
583 | to have any loops. */ | |
584 | struct partial_symtab **dependencies; | |
585 | int number_of_dependencies; | |
586 | /* Global symbol list. This list will be sorted after readin to | |
587 | improve access. Binary search will be the usual method of | |
588 | finding a symbol within it. globals_offset is an integer offset | |
4a35d6e9 | 589 | within global_psymbols[]. */ |
bd5635a1 RP |
590 | int globals_offset, n_global_syms; |
591 | /* Static symbol list. This list will *not* be sorted after readin; | |
592 | to find a symbol in it, exhaustive search must be used. This is | |
593 | reasonable because searches through this list will eventually | |
594 | lead to either the read in of a files symbols for real (assumed | |
595 | to take a *lot* of time; check) or an error (and we don't care | |
4a35d6e9 FF |
596 | how long errors take). This is an offset and size within |
597 | static_psymbols[]. */ | |
bd5635a1 RP |
598 | int statics_offset, n_static_syms; |
599 | /* Pointer to symtab eventually allocated for this source file, 0 if | |
600 | !readin or if we haven't looked for the symtab after it was readin. */ | |
601 | struct symtab *symtab; | |
602 | /* Pointer to function which will read in the symtab corresponding to | |
603 | this psymtab. */ | |
604 | void (*read_symtab) (); | |
4a35d6e9 FF |
605 | /* Information that lets read_symtab() locate the part of the symbol table |
606 | that this psymtab corresponds to. This information is private to the | |
607 | format-dependent symbol reading routines. For further detail examine | |
608 | the various symbol reading modules. Should really be (void *) but is | |
609 | (char *) as with other such gdb variables. (FIXME) */ | |
610 | char *read_symtab_private; | |
bd5635a1 RP |
611 | /* Non-zero if the symtab corresponding to this psymtab has been |
612 | readin */ | |
613 | unsigned char readin; | |
614 | }; | |
615 | ||
616 | /* A fast way to get from a psymtab to its symtab (after the first time). */ | |
617 | #define PSYMTAB_TO_SYMTAB(pst) ((pst)->symtab? \ | |
618 | (pst)->symtab: \ | |
619 | psymtab_to_symtab (pst) ) | |
620 | ||
621 | /* This is the list of struct symtab's that gdb considers current. */ | |
622 | ||
623 | struct symtab *symtab_list; | |
624 | ||
625 | /* This is the list of struct partial_symtab's that gdb may need to access */ | |
626 | ||
627 | struct partial_symtab *partial_symtab_list; | |
628 | ||
629 | /* This symtab variable specifies the current file for printing source lines */ | |
630 | ||
631 | struct symtab *current_source_symtab; | |
632 | ||
633 | /* This is the next line to print for listing source lines. */ | |
634 | ||
635 | int current_source_line; | |
636 | ||
637 | #define BLOCKLIST(symtab) (symtab)->blockvector | |
638 | #define BLOCKVECTOR(symtab) (symtab)->blockvector | |
639 | ||
bd5635a1 RP |
640 | #define LINETABLE(symtab) (symtab)->linetable |
641 | \f | |
642 | /* Macros normally used to access components of symbol table structures. */ | |
643 | ||
644 | #define BLOCKLIST_NBLOCKS(blocklist) (blocklist)->nblocks | |
645 | #define BLOCKLIST_BLOCK(blocklist,n) (blocklist)->block[n] | |
646 | #define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks | |
647 | #define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n] | |
648 | ||
bd5635a1 RP |
649 | #define BLOCK_START(bl) (bl)->startaddr |
650 | #define BLOCK_END(bl) (bl)->endaddr | |
651 | #define BLOCK_NSYMS(bl) (bl)->nsyms | |
652 | #define BLOCK_SYM(bl, n) (bl)->sym[n] | |
653 | #define BLOCK_FUNCTION(bl) (bl)->function | |
654 | #define BLOCK_SUPERBLOCK(bl) (bl)->superblock | |
655 | #define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag | |
656 | ||
657 | /* Nonzero if symbols of block BL should be sorted alphabetically. */ | |
658 | #define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40) | |
659 | ||
660 | #define SYMBOL_NAME(symbol) (symbol)->name | |
661 | #define SYMBOL_NAMESPACE(symbol) (symbol)->namespace | |
662 | #define SYMBOL_CLASS(symbol) (symbol)->class | |
663 | #define SYMBOL_VALUE(symbol) (symbol)->value.value | |
664 | #define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->value.address | |
665 | #define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes | |
666 | #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block | |
667 | #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain | |
668 | #define SYMBOL_TYPE(symbol) (symbol)->type | |
669 | #define SYMBOL_LINE(symbol) (symbol)->line | |
670 | ||
671 | #define TYPE_NAME(thistype) (thistype)->name | |
672 | #define TYPE_TARGET_TYPE(thistype) (thistype)->target_type | |
673 | #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type | |
674 | #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type | |
675 | #define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type | |
676 | #define TYPE_MAIN_VARIANT(thistype) (thistype)->main_variant | |
677 | #define TYPE_NEXT_VARIANT(thistype) (thistype)->next_variant | |
678 | #define TYPE_LENGTH(thistype) (thistype)->length | |
679 | #define TYPE_FLAGS(thistype) (thistype)->flags | |
680 | #define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED) | |
681 | #define TYPE_CODE(thistype) (thistype)->code | |
682 | #define TYPE_NFIELDS(thistype) (thistype)->nfields | |
683 | #define TYPE_FIELDS(thistype) (thistype)->fields | |
684 | /* C++ */ | |
685 | #define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype | |
686 | #define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype | |
687 | #define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno | |
688 | #define TYPE_FN_FIELDS(thistype) (thistype)->fn_fields | |
689 | #define TYPE_NFN_FIELDS(thistype) (thistype)->nfn_fields | |
690 | #define TYPE_NFN_FIELDS_TOTAL(thistype) (thistype)->nfn_fields_total | |
691 | #define TYPE_ARG_TYPES(thistype) (thistype)->arg_types | |
692 | #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type | |
693 | #define TYPE_N_BASECLASSES(thistype) (thistype)->n_baseclasses | |
694 | #define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name | |
695 | #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype)->fields[index].bitpos | |
696 | #define BASETYPE_VIA_PUBLIC(thistype, index) (!TYPE_FIELD_PRIVATE(thistype, index)) | |
697 | #define BASETYPE_VIA_VIRTUAL(thistype, index) B_TST((thistype)->virtual_field_bits, (index)) | |
698 | ||
699 | #define TYPE_FIELD(thistype, n) (thistype)->fields[n] | |
700 | #define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type | |
701 | #define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name | |
702 | #define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type) | |
703 | #define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos | |
704 | #define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize | |
705 | #define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize | |
706 | ||
707 | #define TYPE_FIELD_PRIVATE_BITS(thistype) (thistype)->private_field_bits | |
708 | #define TYPE_FIELD_PROTECTED_BITS(thistype) (thistype)->protected_field_bits | |
709 | #define TYPE_FIELD_VIRTUAL_BITS(thistype) (thistype)->virtual_field_bits | |
710 | #define SET_TYPE_FIELD_PRIVATE(thistype, n) B_SET ((thistype)->private_field_bits, (n)) | |
711 | #define SET_TYPE_FIELD_PROTECTED(thistype, n) B_SET ((thistype)->protected_field_bits, (n)) | |
712 | #define SET_TYPE_FIELD_VIRTUAL(thistype, n) B_SET ((thistype)->virtual_field_bits, (n)) | |
713 | #define TYPE_FIELD_PRIVATE(thistype, n) B_TST((thistype)->private_field_bits, (n)) | |
714 | #define TYPE_FIELD_PROTECTED(thistype, n) B_TST((thistype)->protected_field_bits, (n)) | |
715 | #define TYPE_FIELD_VIRTUAL(thistype, n) B_TST((thistype)->virtual_field_bits, (n)) | |
716 | ||
717 | #define TYPE_HAS_DESTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_DESTRUCTOR) | |
718 | #define TYPE_HAS_CONSTRUCTOR(thistype) ((thistype)->flags & TYPE_FLAG_HAS_CONSTRUCTOR) | |
719 | ||
720 | #define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1) | |
721 | #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize) | |
722 | ||
723 | #define TYPE_FN_FIELDLISTS(thistype) (thistype)->fn_fieldlists | |
724 | #define TYPE_FN_FIELDLIST(thistype, n) (thistype)->fn_fieldlists[n] | |
725 | #define TYPE_FN_FIELDLIST1(thistype, n) (thistype)->fn_fieldlists[n].fn_fields | |
726 | #define TYPE_FN_FIELDLIST_NAME(thistype, n) (thistype)->fn_fieldlists[n].name | |
727 | #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) (thistype)->fn_fieldlists[n].length | |
728 | ||
729 | #define TYPE_FN_FIELD(thistype, n) (thistype)[n] | |
730 | #define TYPE_FN_FIELD_NAME(thistype, n) (thistype)[n].name | |
731 | #define TYPE_FN_FIELD_TYPE(thistype, n) (thistype)[n].type | |
732 | #define TYPE_FN_FIELD_ARGS(thistype, n) TYPE_ARG_TYPES ((thistype)[n].type) | |
733 | #define TYPE_FN_FIELD_PHYSNAME(thistype, n) (thistype)[n].physname | |
bcccec8c | 734 | #define TYPE_FN_FIELD_VIRTUAL_P(thistype, n) ((thistype)[n].voffset > 1) |
bd5635a1 | 735 | #define TYPE_FN_FIELD_STATIC_P(thistype, n) ((thistype)[n].voffset == VOFFSET_STATIC) |
bcccec8c | 736 | #define TYPE_FN_FIELD_VOFFSET(thistype, n) ((thistype)[n].voffset-2) |
bd5635a1 RP |
737 | #define TYPE_FN_FIELD_FCONTEXT(thistype, n) ((thistype)[n].fcontext) |
738 | ||
739 | #define TYPE_FN_PRIVATE_BITS(thistype) (thistype).private_fn_field_bits | |
740 | #define TYPE_FN_PROTECTED_BITS(thistype) (thistype).protected_fn_field_bits | |
741 | #define SET_TYPE_FN_PRIVATE(thistype, n) B_SET ((thistype).private_fn_field_bits, n) | |
742 | #define SET_TYPE_FN_PROTECTED(thistype, n) B_SET ((thistype).protected_fn_field_bits, n) | |
743 | #define TYPE_FN_PRIVATE(thistype, n) B_TST ((thistype).private_fn_field_bits, n) | |
744 | #define TYPE_FN_PROTECTED(thistype, n) B_TST ((thistype).protected_fn_field_bits, n) | |
745 | ||
746 | /* The virtual function table is now an array of structures | |
747 | which have the form { int16 offset, delta; void *pfn; }. | |
aec4cb91 | 748 | |
ea9cdf62 JK |
749 | In normal virtual function tables, OFFSET is unused. |
750 | DELTA is the amount which is added to the apparent object's base | |
751 | address in order to point to the actual object to which the | |
752 | virtual function should be applied. | |
753 | PFN is a pointer to the virtual function. */ | |
bd5635a1 RP |
754 | |
755 | #define VTBL_FNADDR_OFFSET 2 | |
ea9cdf62 JK |
756 | |
757 | /* Macro that yields non-zero value iff NAME is the prefix | |
758 | for C++ operator names. If you leave out the parenthesis | |
759 | here you will lose! | |
760 | ||
761 | Currently 'o' 'p' CPLUS_MARKER is used for both the symbol in the | |
762 | symbol-file and the names in gdb's symbol table. */ | |
763 | #define OPNAME_PREFIX_P(NAME) ((NAME)[0] == 'o' && (NAME)[1] == 'p' \ | |
764 | && (NAME)[2] == CPLUS_MARKER) | |
765 | ||
766 | #define VTBL_PREFIX_P(NAME) ((NAME)[3] == CPLUS_MARKER \ | |
767 | && !strncmp ((NAME), "_vt", 3)) | |
bd5635a1 RP |
768 | \f |
769 | /* Functions that work on the objects described above */ | |
770 | ||
771 | extern struct symtab *lookup_symtab (); | |
772 | extern struct symbol *lookup_symbol (); | |
773 | extern struct symbol *lookup_block_symbol (); | |
774 | extern int lookup_misc_func (); | |
775 | extern void check_stub_type (); | |
776 | extern void check_stub_method (); | |
777 | extern struct type *lookup_primitive_typename (); | |
778 | extern struct type *lookup_typename (); | |
779 | extern struct type *lookup_unsigned_typename (); | |
780 | extern struct type *lookup_struct (); | |
781 | extern struct type *lookup_union (); | |
782 | extern struct type *lookup_enum (); | |
783 | extern struct type *lookup_struct_elt_type (); | |
784 | extern struct type *lookup_pointer_type (); | |
785 | extern struct type *lookup_function_type (); | |
786 | extern struct type *lookup_basetype_type (); | |
787 | extern struct type *create_array_type (); | |
788 | extern struct symbol *block_function (); | |
789 | extern struct symbol *find_pc_function (); | |
790 | extern int find_pc_partial_function (); | |
4a35d6e9 | 791 | extern void clear_pc_function_cache (); |
bd5635a1 RP |
792 | extern struct partial_symtab *lookup_partial_symtab (); |
793 | extern struct partial_symtab *find_pc_psymtab (); | |
794 | extern struct symtab *find_pc_symtab (); | |
795 | extern struct partial_symbol *find_pc_psymbol (); | |
796 | extern int find_pc_misc_function (); | |
797 | extern int find_pc_line_pc_range (); | |
798 | extern char *type_name_no_tag (); | |
799 | extern int contained_in(); | |
800 | ||
801 | /* C++ stuff. */ | |
802 | extern struct type *lookup_reference_type (); | |
803 | extern struct type *lookup_member_type (); | |
ea9cdf62 | 804 | extern struct type *lookup_method_type (); |
bd5635a1 RP |
805 | extern struct type *lookup_class (); |
806 | extern void smash_to_method_type (); | |
e1ce8aa5 JK |
807 | void smash_to_member_type ( |
808 | #ifdef __STDC__ | |
809 | struct type *, struct type *, struct type * | |
810 | #endif | |
811 | ); | |
ea9cdf62 | 812 | extern struct type *allocate_stub_method (); |
bd5635a1 RP |
813 | /* end of C++ stuff. */ |
814 | ||
815 | extern void free_all_symtabs (); | |
816 | extern void free_all_psymtabs (); | |
817 | extern void free_inclink_symtabs (); | |
818 | extern void reread_symbols (); | |
819 | ||
820 | extern struct type *builtin_type_void; | |
821 | extern struct type *builtin_type_char; | |
822 | extern struct type *builtin_type_short; | |
823 | extern struct type *builtin_type_int; | |
824 | extern struct type *builtin_type_long; | |
825 | extern struct type *builtin_type_unsigned_char; | |
826 | extern struct type *builtin_type_unsigned_short; | |
827 | extern struct type *builtin_type_unsigned_int; | |
828 | extern struct type *builtin_type_unsigned_long; | |
829 | extern struct type *builtin_type_float; | |
830 | extern struct type *builtin_type_double; | |
e2aab031 FF |
831 | extern struct type *builtin_type_long_double; |
832 | extern struct type *builtin_type_complex; | |
833 | extern struct type *builtin_type_double_complex; | |
bd5635a1 RP |
834 | /* This type represents a type that was unrecognized in symbol |
835 | read-in. */ | |
836 | extern struct type *builtin_type_error; | |
837 | ||
bd5635a1 RP |
838 | extern struct type *builtin_type_long_long; |
839 | extern struct type *builtin_type_unsigned_long_long; | |
840 | ||
4a35d6e9 FF |
841 | /* Modula-2 types */ |
842 | extern struct type *builtin_type_m2_char; | |
843 | extern struct type *builtin_type_m2_int; | |
844 | extern struct type *builtin_type_m2_card; | |
845 | extern struct type *builtin_type_m2_real; | |
846 | extern struct type *builtin_type_m2_bool; | |
847 | ||
ea9cdf62 JK |
848 | /* LONG_LONG is defined if the host has "long long". */ |
849 | #ifdef LONG_LONG | |
bd5635a1 RP |
850 | #define BUILTIN_TYPE_LONGEST builtin_type_long_long |
851 | #define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long_long | |
852 | /* This should not be a typedef, because "unsigned LONGEST" needs | |
853 | to work. */ | |
854 | #define LONGEST long long | |
855 | ||
856 | #else /* not LONG_LONG. */ | |
857 | ||
858 | #define BUILTIN_TYPE_LONGEST builtin_type_long | |
859 | #define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long | |
860 | #define LONGEST long | |
861 | ||
862 | #endif /* not LONG_LONG. */ | |
863 | ||
864 | struct symtab_and_line | |
865 | { | |
866 | struct symtab *symtab; | |
867 | int line; | |
868 | CORE_ADDR pc; | |
869 | CORE_ADDR end; | |
870 | }; | |
871 | ||
872 | struct symtabs_and_lines | |
873 | { | |
874 | struct symtab_and_line *sals; | |
875 | int nelts; | |
876 | }; | |
877 | ||
878 | /* Given a pc value, return line number it is in. | |
879 | Second arg nonzero means if pc is on the boundary | |
880 | use the previous statement's line number. */ | |
881 | ||
882 | struct symtab_and_line find_pc_line (); | |
883 | ||
884 | /* Given a symtab and line number, return the pc there. */ | |
885 | extern CORE_ADDR find_line_pc (); | |
886 | extern int find_line_pc_range (); | |
887 | ||
888 | /* Given a string, return the line specified by it. | |
889 | For commands like "list" and "breakpoint". */ | |
890 | ||
891 | struct symtabs_and_lines decode_line_spec (); | |
892 | struct symtabs_and_lines decode_line_spec_1 (); | |
893 | struct symtabs_and_lines decode_line_1 (); | |
894 | ||
5c43db6b JG |
895 | /* Symmisc.c */ |
896 | void free_symtab (); | |
897 | ||
bd5635a1 RP |
898 | /* Symbol-reading stuff in symfile.c and solib.c. */ |
899 | struct symtab *psymtab_to_symtab (); | |
900 | void clear_solib (); | |
901 | void symbol_file_add (); | |
902 | ||
903 | /* source.c */ | |
904 | int identify_source_line (); | |
905 | void print_source_lines (); | |
e1ce8aa5 JK |
906 | void forget_cached_source_info ( |
907 | #ifdef __STDC__ | |
908 | void | |
909 | #endif | |
910 | ); | |
911 | void select_source_symtab ( | |
912 | #ifdef __STDC__ | |
913 | struct symtab * | |
914 | #endif | |
915 | ); | |
bd5635a1 RP |
916 | |
917 | char **make_symbol_completion_list (); | |
918 | ||
4a35d6e9 FF |
919 | /* Maximum and minimum values of built-in types */ |
920 | #define MAX_OF_TYPE(t) \ | |
921 | TYPE_UNSIGNED(t) ? UMAX_OF_SIZE(TYPE_LENGTH(t)) : MAX_OF_SIZE(TYPE_LENGTH(t)) | |
922 | ||
923 | #define MIN_OF_TYPE(t) \ | |
924 | TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) : MIN_OF_SIZE(TYPE_LENGTH(t)) | |
925 | ||
bd5635a1 | 926 | #endif /* symtab.h not already included. */ |