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