1 /* Symbol table definitions for GDB.
2 Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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. */
20 #if !defined (SYMTAB_H)
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. */
29 extern struct obstack *symbol_obstack;
30 extern struct obstack *psymbol_obstack;
32 /* Some definitions and declarations to go with use of obstacks. */
33 #define obstack_chunk_alloc xmalloc
34 #define obstack_chunk_free free
36 /* Some macros for char-based bitfields. */
37 #define B_SET(a,x) (a[x>>3] |= (1 << (x&7)))
38 #define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7)))
39 #define B_TST(a,x) (a[x>>3] & (1 << (x&7)))
40 #define B_TYPE unsigned char
41 #define B_BYTES(x) ( 1 + ((x)>>3) )
42 #define B_CLRALL(a,x) bzero (a, B_BYTES(x))
44 /* gdb can know one or several symbol tables at the same time;
45 the ultimate intent is to have one for each separately-compiled module.
46 Each such symbol table is recorded by a struct symtab, and they
47 are all chained together. */
49 /* In addition, gdb can record any number of miscellaneous undebuggable
50 functions' addresses. In a system that appends _ to function names,
51 the _'s are removed from the names stored in this table. */
53 /* Actually, the misc function list is used to store *all* of the
54 global symbols (text, data, bss, and abs). It is sometimes used
55 to figure out what symtabs to read in. The "type" field is used
56 occasionally. Calling it the misc "function" vector is now a misnomer.
58 The misc_info field is available for machine-specific information
59 that can be cached along with a misc function vector entry. The
60 AMD 29000 tdep.c uses it to remember things it has decoded from the
61 instructions in the function header, so it doesn't have to rederive
62 the info constantly (over a serial line). It is initialized to zero
63 and stays that way until target-dependent code sets it. */
65 enum misc_function_type {mf_unknown = 0, mf_text, mf_data, mf_bss, mf_abs};
71 char *misc_info; /* Random pointer to misc info. void * but for old C */
72 enum misc_function_type type;
75 /* Address and length of the vector recording all misc function names/addresses. */
77 struct misc_function *misc_function_vector;
78 int misc_function_count;
80 /* Different kinds of data types are distinguished by the `code' field. */
84 TYPE_CODE_UNDEF, /* Not used; catches errors */
85 TYPE_CODE_PTR, /* Pointer type */
86 TYPE_CODE_ARRAY, /* Array type, lower bound zero */
87 TYPE_CODE_STRUCT, /* C struct or Pascal record */
88 TYPE_CODE_UNION, /* C union or Pascal variant part */
89 TYPE_CODE_ENUM, /* Enumeration type */
90 TYPE_CODE_FUNC, /* Function type */
91 TYPE_CODE_INT, /* Integer type */
92 TYPE_CODE_FLT, /* Floating type */
93 TYPE_CODE_VOID, /* Void type (values zero length) */
94 TYPE_CODE_SET, /* Pascal sets */
95 TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */
96 TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */
97 TYPE_CODE_ERROR, /* Unknown type */
100 TYPE_CODE_MEMBER, /* Member type */
101 TYPE_CODE_METHOD, /* Method type */
102 TYPE_CODE_REF, /* C++ Reference types */
105 TYPE_CODE_CHAR, /* *real* character type */
106 TYPE_CODE_BOOL, /* Builtin Modula-2 BOOLEAN */
109 /* This appears in a type's flags word for an unsigned integer type. */
110 #define TYPE_FLAG_UNSIGNED 1
111 /* This appears in a type's flags word
112 if it is a (pointer to a|function returning a)* built in scalar type.
113 These types are never freed. */
114 #define TYPE_FLAG_PERM 4
115 /* This appears in a type's flags word if it is a stub type (eg. if
116 someone referenced a type that wasn't definined in a source file
117 via (struct sir_not_appearing_in_this_film *)). */
118 #define TYPE_FLAG_STUB 8
122 /* Code for kind of type */
124 /* Name of this type, or zero if none.
125 This is used for printing only, except by poorly designed C++ code.
126 Type names specified as input are defined by symbols. */
128 /* Length in bytes of storage for a value of this type */
130 /* For a pointer type, describes the type of object pointed to.
131 For an array type, describes the type of the elements.
132 For a function or method type, describes the type of the value.
133 For a range type, describes the type of the full range.
134 For a record type, it's the "main variant" of the record type,
135 used for computing pointers to members.
137 struct type *target_type;
138 /* Type that is a pointer to this type.
139 Zero if no such pointer-to type is known yet.
140 The debugger may add the address of such a type
141 if it has to construct one later. */
142 struct type *pointer_type;
143 /* C++: also need a reference type. */
144 struct type *reference_type;
146 /* Type that is a function returning this type.
147 Zero if no such function type is known here.
148 The debugger may add the address of such a type
149 if it has to construct one later. */
150 struct type *function_type;
152 /* Flags about this type. */
154 /* Number of fields described for this type */
156 /* For structure and union types, a description of each field.
157 For set and pascal array types, there is one "field",
158 whose type is the domain type of the set or array.
159 For range types, there are two "fields",
160 the minimum and maximum values (both inclusive).
161 For enum types, each possible value is described by one "field".
163 Using a pointer to a separate array of fields
164 allows all types to have the same size, which is useful
165 because we can allocate the space for a type before
166 we know what to put in it. */
169 /* Position of this field, counting in bits from start of
170 containing structure. For a function type, this is the
171 position in the argument list of this argument.
172 For a range bound or enum value, this is the value itself. */
174 /* Size of this field, in bits, or zero if not packed.
175 For an unpacked field, the field's type's length
176 says how many bytes the field occupies. */
178 /* In a struct or enum type, type of this field.
179 In a function type, type of this argument.
180 In an array type, the domain-type of the array. */
182 /* Name of field, value or argument.
183 Zero for range bounds and array domains. */
187 /* For types with virtual functions, VPTR_BASETYPE is the base class which
188 defined the virtual function table pointer. VPTR_FIELDNO is
189 the field number of that pointer in the structure.
191 For types that are pointer to member types, VPTR_BASETYPE
192 ifs the type that this pointer is a member of.
195 struct type *vptr_basetype;
199 /* Slot to point to additional language-specific fields of this type. */
202 struct type **arg_types;
203 struct cplus_struct_type *cplus_stuff;
207 /* C++ language-specific information for TYPE_CODE_STRUCT nodes. */
208 struct cplus_struct_type
210 /* Handling of pointers to members:
211 TYPE_MAIN_VARIANT is used for pointer and pointer
212 to member types. Normally it is the value of the address of its
213 containing type. However, for pointers to members, we must be
214 able to allocate pointer to member types and look them up
215 from some place of reference.
216 NEXT_VARIANT is the next element in the chain.
218 A long time ago (Jul 88; GDB 2.5) Tiemann said that
219 MAIN_VARIANT/NEXT_VARIANT may no longer be necessary and that he
220 might eliminate it. I don't know whether this is still true (or
222 struct type *next_variant;
224 B_TYPE *virtual_field_bits; /* if base class is virtual */
225 B_TYPE *private_field_bits;
226 B_TYPE *protected_field_bits;
228 /* Number of methods described for this type */
230 /* Number of base classes this type derives from. */
233 /* Number of methods described for this type plus all the
234 methods that it derives from. */
235 int nfn_fields_total;
237 /* For classes, structures, and unions, a description of each field,
238 which consists of an overloaded name, followed by the types of
239 arguments that the method expects, and then the name after it
240 has been renamed to make it distinct. */
243 /* The overloaded name. */
245 /* The number of methods with this name. */
247 /* The list of methods. */
250 /* The return value of the method */
252 /* The argument list */
254 /* The name after it has been processed */
257 /* For virtual functions. */
258 /* First baseclass that defines this virtual function. */
259 struct type *fcontext;
260 unsigned int is_const : 1;
261 unsigned int is_volatile : 1;
262 /* Index into that baseclass's virtual function table,
263 minus 2; else if static: VOFFSET_STATIC; else: 0. */
264 unsigned voffset : 30;
265 # define VOFFSET_STATIC 1
268 B_TYPE *private_fn_field_bits;
269 B_TYPE *protected_fn_field_bits;
273 unsigned char via_protected;
274 unsigned char via_public;
277 /* All of the name-scope contours of the program
278 are represented by `struct block' objects.
279 All of these objects are pointed to by the blockvector.
281 Each block represents one name scope.
282 Each lexical context has its own block.
284 The first two blocks in the blockvector are special.
285 The first one contains all the symbols defined in this compilation
286 whose scope is the entire program linked together.
287 The second one contains all the symbols whose scope is the
288 entire compilation excluding other separate compilations.
289 In C, these correspond to global symbols and static symbols.
291 Each block records a range of core addresses for the code that
292 is in the scope of the block. The first two special blocks
293 give, for the range of code, the entire range of code produced
294 by the compilation that the symbol segment belongs to.
296 The blocks appear in the blockvector
297 in order of increasing starting-address,
298 and, within that, in order of decreasing ending-address.
300 This implies that within the body of one function
301 the blocks appear in the order of a depth-first tree walk. */
305 /* Number of blocks in the list. */
307 /* The blocks themselves. */
308 struct block *block[1];
311 /* Special block numbers */
312 #define GLOBAL_BLOCK 0
313 #define STATIC_BLOCK 1
314 #define FIRST_LOCAL_BLOCK 2
318 /* Addresses in the executable code that are in this block.
319 Note: in an unrelocated symbol segment in a file,
320 these are always zero. They can be filled in from the
321 N_LBRAC and N_RBRAC symbols in the loader symbol table. */
322 CORE_ADDR startaddr, endaddr;
323 /* The symbol that names this block,
324 if the block is the body of a function;
326 Note: In an unrelocated symbol segment in an object file,
327 this field may be zero even when the block has a name.
328 That is because the block is output before the name
329 (since the name resides in a higher block).
330 Since the symbol does point to the block (as its value),
331 it is possible to find the block and set its name properly. */
332 struct symbol *function;
333 /* The `struct block' for the containing block, or 0 if none. */
334 /* Note that in an unrelocated symbol segment in an object file
335 this pointer may be zero when the correct value should be
336 the second special block (for symbols whose scope is one compilation).
337 This is because the compiler ouptuts the special blocks at the
338 very end, after the other blocks. */
339 struct block *superblock;
340 /* A flag indicating whether or not the fucntion corresponding
341 to this block was compiled with gcc or not. If there is no
342 function corresponding to this block, this meaning of this flag
343 is undefined. (In practice it will be 1 if the block was created
344 while processing a file compiled with gcc and 0 when not). */
345 unsigned char gcc_compile_flag;
346 /* Number of local symbols. */
349 struct symbol *sym[1];
352 /* Represent one symbol name; a variable, constant, function or typedef. */
354 /* Different name spaces for symbols. Looking up a symbol specifies
355 a namespace and ignores symbol definitions in other name spaces.
357 VAR_NAMESPACE is the usual namespace.
358 In C, this contains variables, function names, typedef names
359 and enum type values.
361 STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
362 Thus, if `struct foo' is used in a C program,
363 it produces a symbol named `foo' in the STRUCT_NAMESPACE.
365 LABEL_NAMESPACE may be used for names of labels (for gotos);
366 currently it is not used and labels are not recorded at all. */
368 /* For a non-global symbol allocated statically,
369 the correct core address cannot be determined by the compiler.
370 The compiler puts an index number into the symbol's value field.
371 This index number can be matched with the "desc" field of
372 an entry in the loader symbol table. */
376 UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE,
379 /* An address-class says where to find the value of a symbol. */
383 LOC_UNDEF, /* Not used; catches errors */
384 LOC_CONST, /* Value is constant int SYMBOL_VALUE, host byteorder */
385 LOC_STATIC, /* Value is at fixed address SYMBOL_VALUE_ADDRESS */
386 LOC_REGISTER, /* Value is in register */
387 LOC_ARG, /* Value is at spec'd offset in arglist */
388 LOC_REF_ARG, /* Value address is at spec'd offset in arglist. */
389 LOC_REGPARM, /* Value is at spec'd offset in register window */
390 LOC_LOCAL, /* Value is at spec'd offset in stack frame */
391 LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE
392 Symbols in the namespace STRUCT_NAMESPACE
393 all have this class. */
394 LOC_LABEL, /* Value is address SYMBOL_VALUE_ADDRESS in the code */
395 LOC_BLOCK, /* Value is address SYMBOL_VALUE_BLOCK of a
396 `struct block'. Function names have this class. */
397 LOC_CONST_BYTES, /* Value is a constant byte-sequence pointed to by
398 SYMBOL_VALUE_ADDRESS, in target byte order. */
399 LOC_LOCAL_ARG, /* Value is arg at spec'd offset in stack frame.
400 Differs from LOC_LOCAL in that symbol is an
401 argument; differs from LOC_ARG in that we find it
402 in the frame (FRAME_LOCALS_ADDRESS), not in the
403 arglist (FRAME_ARGS_ADDRESS). Added for i960,
404 which passes args in regs then copies to frame. */
411 /* Name space code. */
412 enum namespace namespace;
414 enum address_class class;
415 /* Data type of value */
418 /* Line number of definition. */
421 /* constant value, or address if static, or register number,
422 or offset in arguments, or offset in stack frame. All of
423 these are in host byte order (though what they point to might
424 be in target byte order, e.g. LOC_CONST_BYTES). */
427 long value; /* for LOC_CONST, LOC_REGISTER, LOC_ARG,
428 LOC_REF_ARG, LOC_REGPARM, LOC_LOCAL */
429 struct block *block; /* for LOC_BLOCK */
430 char *bytes; /* for LOC_CONST_BYTES */
431 CORE_ADDR address; /* for LOC_STATIC, LOC_LABEL */
432 struct symbol *chain; /* for opaque typedef struct chain */
438 /* A partial_symbol records the name, namespace, and address class of
439 symbols whose types we have not parsed yet. For functions, it also
440 contains their memory address, so we can find them from a PC value.
441 Each partial_symbol sits in a partial_symtab, all of which are chained
442 on the partial_symtab_list and which points to the corresponding
443 normal symtab once the partial_symtab has been referenced. */
445 struct partial_symbol
449 /* Name space code. */
450 enum namespace namespace;
451 /* Address class (for info_symbols) */
452 enum address_class class;
453 /* Value (only used for static functions currently). Done this
454 way so that we can use the struct symbol macros.
455 Note that the address of a function is SYMBOL_VALUE_ADDRESS (pst)
456 in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st))
457 in a symbol table. */
466 /* Source-file information.
467 This describes the relation between source files and line numbers
468 and addresses in the program text. */
472 int length; /* Number of source files described */
473 struct source *source[1]; /* Descriptions of the files */
476 /* Each item represents a line-->pc (or the reverse) mapping. This is
477 somewhat more wasteful of space than one might wish, but since only
478 the files which are actually debugged are read in to core, we don't
481 Each item used to be an int; either minus a line number, or a
482 program counter. If it represents a line number, that is the line
483 described by the next program counter value. If it is positive, it
484 is the program counter at which the code for the next line starts. */
486 struct linetable_entry
495 struct linetable_entry item[1];
498 /* All the information on one source file. */
502 char *name; /* Name of file */
503 struct linetable contents;
506 /* Each source file is represented by a struct symtab.
507 These objects are chained through the `next' field. */
511 /* Chain of all existing symtabs. */
513 /* List of all symbol scope blocks for this symtab. */
514 struct blockvector *blockvector;
515 /* Table mapping core addresses to line numbers for this file.
516 Can be NULL if none. */
517 struct linetable *linetable;
518 /* Name of this source file. */
520 /* Directory in which it was compiled, or NULL if we don't know. */
522 /* This component says how to free the data we point to:
523 free_contents => do a tree walk and free each object.
524 free_nothing => do nothing; some other symtab will free
525 the data this one uses.
526 free_linetable => free just the linetable. */
527 enum free_code {free_nothing, free_contents, free_linetable}
529 /* Pointer to one block of storage to be freed, if nonzero. */
530 /* This is IN ADDITION to the action indicated by free_code. */
532 /* Total number of lines found in source file. */
534 /* Array mapping line number to character position. */
536 /* Language of this source file. */
537 enum language language;
538 /* String of version information. May be zero. */
540 /* Full name of file as found by searching the source path.
541 0 if not yet known. */
544 /* Object file from which this symbol information was read. */
545 struct objfile *objfile;
546 /* Chain of all symtabs owned by that objfile. */
547 struct symtab *objfile_chain;
549 /* Anything extra for this symtab. This is for target machines
550 with special debugging info of some sort (which cannot just
551 be represented in a normal symtab). */
552 #if defined (EXTRA_SYMTAB_INFO)
557 /* Each source file that has not been fully read in is represented by
558 a partial_symtab. This contains the information on where in the
559 executable the debugging symbols for a specific file are, and a
560 list of names of global symbols which are located in this file.
561 They are all chained on partial_symtab_list.
563 Even after the source file has been read into a symtab, the
564 partial_symtab remains around. They are allocated on an obstack,
565 psymbol_obstack. FIXME, this is bad for dynamic linking or VxWorks-
566 style execution of a bunch of .o's. */
567 struct partial_symtab
569 /* Chain of all existing partial symtabs. */
570 struct partial_symtab *next;
571 /* Name of the source file which this partial_symtab defines */
574 /* Information about the object file from which symbols should be read. */
575 struct objfile *objfile;
576 /* Chain of psymtabs owned by this objfile */
577 struct partial_symtab *objfile_chain;
579 /* Address relative to which the symbols in this file are. Need to
580 relocate by this amount when reading in symbols from the symbol
583 /* Range of text addresses covered by this file; texthigh is the
584 beginning of the next section. */
585 CORE_ADDR textlow, texthigh;
586 /* Array of pointers to all of the partial_symtab's which this one
587 depends on. Since this array can only be set to previous or
588 the current (?) psymtab, this dependency tree is guaranteed not
589 to have any loops. */
590 struct partial_symtab **dependencies;
591 int number_of_dependencies;
592 /* Global symbol list. This list will be sorted after readin to
593 improve access. Binary search will be the usual method of
594 finding a symbol within it. globals_offset is an integer offset
595 within global_psymbols[]. */
596 int globals_offset, n_global_syms;
597 /* Static symbol list. This list will *not* be sorted after readin;
598 to find a symbol in it, exhaustive search must be used. This is
599 reasonable because searches through this list will eventually
600 lead to either the read in of a files symbols for real (assumed
601 to take a *lot* of time; check) or an error (and we don't care
602 how long errors take). This is an offset and size within
603 static_psymbols[]. */
604 int statics_offset, n_static_syms;
605 /* Pointer to symtab eventually allocated for this source file, 0 if
606 !readin or if we haven't looked for the symtab after it was readin. */
607 struct symtab *symtab;
608 /* Pointer to function which will read in the symtab corresponding to
610 void (*read_symtab) ();
611 /* Information that lets read_symtab() locate the part of the symbol table
612 that this psymtab corresponds to. This information is private to the
613 format-dependent symbol reading routines. For further detail examine
614 the various symbol reading modules. Should really be (void *) but is
615 (char *) as with other such gdb variables. (FIXME) */
616 char *read_symtab_private;
617 /* Non-zero if the symtab corresponding to this psymtab has been
619 unsigned char readin;
622 /* A fast way to get from a psymtab to its symtab (after the first time). */
623 #define PSYMTAB_TO_SYMTAB(pst) ((pst)->symtab? \
625 psymtab_to_symtab (pst) )
627 /* This is the list of struct symtab's that gdb considers current. */
629 struct symtab *symtab_list;
631 /* This is the list of struct partial_symtab's that gdb may need to access */
633 struct partial_symtab *partial_symtab_list;
635 /* This symtab variable specifies the current file for printing source lines */
637 struct symtab *current_source_symtab;
639 /* This is the next line to print for listing source lines. */
641 int current_source_line;
643 #define BLOCKVECTOR(symtab) (symtab)->blockvector
645 #define LINETABLE(symtab) (symtab)->linetable
647 /* Macros normally used to access components of symbol table structures. */
649 #define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
650 #define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
652 #define BLOCK_START(bl) (bl)->startaddr
653 #define BLOCK_END(bl) (bl)->endaddr
654 #define BLOCK_NSYMS(bl) (bl)->nsyms
655 #define BLOCK_SYM(bl, n) (bl)->sym[n]
656 #define BLOCK_FUNCTION(bl) (bl)->function
657 #define BLOCK_SUPERBLOCK(bl) (bl)->superblock
658 #define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
660 /* Nonzero if symbols of block BL should be sorted alphabetically. */
661 #define BLOCK_SHOULD_SORT(bl) ((bl)->nsyms >= 40)
663 #define SYMBOL_NAME(symbol) (symbol)->name
664 #define SYMBOL_NAMESPACE(symbol) (symbol)->namespace
665 #define SYMBOL_CLASS(symbol) (symbol)->class
666 #define SYMBOL_VALUE(symbol) (symbol)->value.value
667 #define SYMBOL_VALUE_ADDRESS(symbol) (symbol)->value.address
668 #define SYMBOL_VALUE_BYTES(symbol) (symbol)->value.bytes
669 #define SYMBOL_BLOCK_VALUE(symbol) (symbol)->value.block
670 #define SYMBOL_VALUE_CHAIN(symbol) (symbol)->value.chain
671 #define SYMBOL_TYPE(symbol) (symbol)->type
672 #define SYMBOL_LINE(symbol) (symbol)->line
674 #define TYPE_NAME(thistype) (thistype)->name
675 #define TYPE_TARGET_TYPE(thistype) (thistype)->target_type
676 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
677 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
678 #define TYPE_FUNCTION_TYPE(thistype) (thistype)->function_type
679 #define TYPE_MAIN_VARIANT(thistype) (thistype)->target_type
680 #define TYPE_NEXT_VARIANT(thistype) (TYPE_CPLUS_SPECIFIC (thistype))->next_variant
681 #define TYPE_LENGTH(thistype) (thistype)->length
682 #define TYPE_FLAGS(thistype) (thistype)->flags
683 #define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED)
684 #define TYPE_CODE(thistype) (thistype)->code
685 #define TYPE_NFIELDS(thistype) (thistype)->nfields
686 #define TYPE_FIELDS(thistype) (thistype)->fields
688 #define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype
689 #define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype
690 #define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno
691 #define TYPE_FN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fields
692 #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
693 #define TYPE_NFN_FIELDS_TOTAL(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields_total
694 #define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types
695 #define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff
696 #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type
697 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
698 #define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name
699 #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype)->fields[index].bitpos
700 #define BASETYPE_VIA_PUBLIC(thistype, index) (!TYPE_FIELD_PRIVATE(thistype, index))
701 #define BASETYPE_VIA_VIRTUAL(thistype, index) \
702 B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index))
704 #define TYPE_FIELD(thistype, n) (thistype)->fields[n]
705 #define TYPE_FIELD_TYPE(thistype, n) (thistype)->fields[n].type
706 #define TYPE_FIELD_NAME(thistype, n) (thistype)->fields[n].name
707 #define TYPE_FIELD_VALUE(thistype, n) (* (int*) &(thistype)->fields[n].type)
708 #define TYPE_FIELD_BITPOS(thistype, n) (thistype)->fields[n].bitpos
709 #define TYPE_FIELD_BITSIZE(thistype, n) (thistype)->fields[n].bitsize
710 #define TYPE_FIELD_PACKED(thistype, n) (thistype)->fields[n].bitsize
712 #define TYPE_FIELD_PRIVATE_BITS(thistype) \
713 TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
714 #define TYPE_FIELD_PROTECTED_BITS(thistype) \
715 TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
716 #define TYPE_FIELD_VIRTUAL_BITS(thistype) \
717 TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
718 #define SET_TYPE_FIELD_PRIVATE(thistype, n) \
719 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
720 #define SET_TYPE_FIELD_PROTECTED(thistype, n) \
721 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
722 #define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
723 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
724 #define TYPE_FIELD_PRIVATE(thistype, n) \
725 B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
726 #define TYPE_FIELD_PROTECTED(thistype, n) \
727 B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
728 #define TYPE_FIELD_VIRTUAL(thistype, n) \
729 B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
731 #define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitpos == -1)
732 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((char *)(thistype)->fields[n].bitsize)
734 #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
735 #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
736 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
737 #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
738 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
740 #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
741 #define TYPE_FN_FIELD_NAME(thisfn, n) (thisfn)[n].name
742 #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
743 #define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type)
744 #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
745 #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
746 #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
747 #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
748 #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
750 #define TYPE_FN_PRIVATE_BITS(thisfn) (thisfn).private_fn_field_bits
751 #define TYPE_FN_PROTECTED_BITS(thisfn) (thisfn).protected_fn_field_bits
752 #define SET_TYPE_FN_PRIVATE(thisfn, n) B_SET ((thisfn).private_fn_field_bits, n)
753 #define SET_TYPE_FN_PROTECTED(thisfn, n) B_SET ((thisfn).protected_fn_field_bits, n)
754 #define TYPE_FN_PRIVATE(thisfn, n) B_TST ((thisfn).private_fn_field_bits, n)
755 #define TYPE_FN_PROTECTED(thisfn, n) B_TST ((thisfn).protected_fn_field_bits, n)
757 /* The virtual function table is now an array of structures
758 which have the form { int16 offset, delta; void *pfn; }.
760 In normal virtual function tables, OFFSET is unused.
761 DELTA is the amount which is added to the apparent object's base
762 address in order to point to the actual object to which the
763 virtual function should be applied.
764 PFN is a pointer to the virtual function. */
766 #define VTBL_FNADDR_OFFSET 2
768 /* Macro that yields non-zero value iff NAME is the prefix
769 for C++ operator names. If you leave out the parenthesis
772 Currently 'o' 'p' CPLUS_MARKER is used for both the symbol in the
773 symbol-file and the names in gdb's symbol table. */
774 #define OPNAME_PREFIX_P(NAME) ((NAME)[0] == 'o' && (NAME)[1] == 'p' \
775 && (NAME)[2] == CPLUS_MARKER)
777 #define VTBL_PREFIX_P(NAME) ((NAME)[3] == CPLUS_MARKER \
778 && !strncmp ((NAME), "_vt", 3))
780 /* Functions that work on the objects described above */
782 extern struct symtab *lookup_symtab ();
783 extern struct symbol *lookup_symbol ();
784 extern struct symbol *lookup_block_symbol ();
785 extern int lookup_misc_func ();
786 extern void check_stub_type ();
787 extern void check_stub_method ();
788 extern struct type *lookup_primitive_typename ();
789 extern struct type *lookup_typename ();
790 extern struct type *lookup_unsigned_typename ();
791 extern struct type *lookup_struct ();
792 extern struct type *lookup_union ();
793 extern struct type *lookup_enum ();
794 extern struct type *lookup_struct_elt_type ();
795 extern struct type *lookup_pointer_type ();
796 extern struct type *lookup_function_type ();
797 extern struct type *create_array_type ();
798 extern struct symbol *block_function ();
799 extern struct symbol *find_pc_function ();
800 extern int find_pc_partial_function ();
801 extern void clear_pc_function_cache ();
802 extern struct partial_symtab *lookup_partial_symtab ();
803 extern struct partial_symtab *find_pc_psymtab ();
804 extern struct symtab *find_pc_symtab ();
805 extern struct partial_symbol *find_pc_psymbol ();
806 extern int find_pc_misc_function ();
807 extern int find_pc_line_pc_range ();
808 extern char *type_name_no_tag ();
809 extern int contained_in();
812 extern struct type *lookup_template_type ();
813 extern struct type *lookup_reference_type ();
814 extern struct type *lookup_member_type ();
815 extern struct type *lookup_method_type ();
816 extern void smash_to_method_type ();
817 void smash_to_member_type (
819 struct type *, struct type *, struct type *
822 extern struct type *allocate_stub_method ();
823 /* end of C++ stuff. */
825 extern void reread_symbols ();
827 extern struct type *builtin_type_void;
828 extern struct type *builtin_type_char;
829 extern struct type *builtin_type_short;
830 extern struct type *builtin_type_int;
831 extern struct type *builtin_type_long;
832 extern struct type *builtin_type_unsigned_char;
833 extern struct type *builtin_type_unsigned_short;
834 extern struct type *builtin_type_unsigned_int;
835 extern struct type *builtin_type_unsigned_long;
836 extern struct type *builtin_type_float;
837 extern struct type *builtin_type_double;
838 extern struct type *builtin_type_long_double;
839 extern struct type *builtin_type_complex;
840 extern struct type *builtin_type_double_complex;
841 /* This type represents a type that was unrecognized in symbol
843 extern struct type *builtin_type_error;
845 extern struct type *builtin_type_long_long;
846 extern struct type *builtin_type_unsigned_long_long;
849 extern struct type *builtin_type_m2_char;
850 extern struct type *builtin_type_m2_int;
851 extern struct type *builtin_type_m2_card;
852 extern struct type *builtin_type_m2_real;
853 extern struct type *builtin_type_m2_bool;
855 /* LONG_LONG is defined if the host has "long long". */
857 #define BUILTIN_TYPE_LONGEST builtin_type_long_long
858 #define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long_long
859 /* This should not be a typedef, because "unsigned LONGEST" needs
861 #define LONGEST long long
863 #else /* not LONG_LONG. */
865 #define BUILTIN_TYPE_LONGEST builtin_type_long
866 #define BUILTIN_TYPE_UNSIGNED_LONGEST builtin_type_unsigned_long
869 #endif /* not LONG_LONG. */
871 struct symtab_and_line
873 struct symtab *symtab;
879 struct symtabs_and_lines
881 struct symtab_and_line *sals;
885 /* Given a pc value, return line number it is in.
886 Second arg nonzero means if pc is on the boundary
887 use the previous statement's line number. */
889 struct symtab_and_line find_pc_line ();
891 /* Given a symtab and line number, return the pc there. */
892 extern CORE_ADDR find_line_pc ();
893 extern int find_line_pc_range ();
895 /* Given a string, return the line specified by it.
896 For commands like "list" and "breakpoint". */
898 struct symtabs_and_lines decode_line_spec ();
899 struct symtabs_and_lines decode_line_spec_1 ();
900 struct symtabs_and_lines decode_line_1 ();
905 /* Symbol-reading stuff in symfile.c and solib.c. */
906 struct symtab *psymtab_to_symtab ();
908 void symbol_file_add ();
911 int identify_source_line ();
912 void print_source_lines ();
913 void forget_cached_source_info (
918 void select_source_symtab (
924 char **make_symbol_completion_list ();
926 /* Maximum and minimum values of built-in types */
927 #define MAX_OF_TYPE(t) \
928 TYPE_UNSIGNED(t) ? UMAX_OF_SIZE(TYPE_LENGTH(t)) : MAX_OF_SIZE(TYPE_LENGTH(t))
930 #define MIN_OF_TYPE(t) \
931 TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) : MIN_OF_SIZE(TYPE_LENGTH(t))
933 #endif /* symtab.h not already included. */