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