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