]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/buildsym.h
* infrun.c: Fixed typo in comment.
[thirdparty/binutils-gdb.git] / gdb / buildsym.h
1 /* Build symbol tables in GDB's internal format.
2 Copyright (C) 1986-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 /* This module provides definitions used for creating and adding to
21 the symbol table. These routines are called from various symbol-
22 file-reading routines.
23
24 They originated in dbxread.c of gdb-4.2, and were split out to
25 make xcoffread.c more maintainable by sharing code.
26
27 Variables declared in this file can be defined by #define-ing
28 the name EXTERN to null. It is used to declare variables that
29 are normally extern, but which get defined in a single module
30 using this technique. */
31
32 #ifndef EXTERN
33 #define EXTERN extern
34 #endif
35
36 extern void add_symbol_to_list ();
37 extern struct type *read_type ();
38 extern struct type *read_range_type ();
39 extern struct type *read_enum_type ();
40 extern struct type *read_struct_type ();
41 extern struct type *read_array_type ();
42 extern struct type **read_args ();
43 extern struct type **dbx_lookup_type ();
44 extern long read_number ();
45 extern void finish_block ();
46 extern struct blockvector *make_blockvector ();
47 extern void really_free_pendings ();
48 extern void start_subfile ();
49 extern struct symtab *end_symtab ();
50 extern void scan_file_globals ();
51 extern void buildsym_new_init ();
52 extern void buildsym_init ();
53
54 /* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
55
56 #ifndef STAB_REG_TO_REGNUM
57 #define STAB_REG_TO_REGNUM(VALUE) (VALUE)
58 #endif
59 \f
60 /* Name of source file whose symbol data we are now processing.
61 This comes from a symbol of type N_SO. */
62
63 EXTERN char *last_source_file;
64
65 /* Core address of start of text of current source file.
66 This too comes from the N_SO symbol. */
67
68 EXTERN CORE_ADDR last_source_start_addr;
69
70 /* The list of sub-source-files within the current individual compilation.
71 Each file gets its own symtab with its own linetable and associated info,
72 but they all share one blockvector. */
73
74 struct subfile
75 {
76 struct subfile *next;
77 char *name;
78 char *dirname;
79 struct linetable *line_vector;
80 int line_vector_length;
81 };
82
83 EXTERN struct subfile *subfiles;
84
85 EXTERN struct subfile *current_subfile;
86
87 /* Global variable which, when set, indicates that we are processing a
88 .o file compiled with gcc */
89
90 EXTERN unsigned char processing_gcc_compilation;
91
92 /* Count symbols as they are processed, for error messages. */
93
94 EXTERN unsigned int symnum;
95
96 /* Vector of types defined so far, indexed by their dbx type numbers.
97 (In newer sun systems, dbx uses a pair of numbers in parens,
98 as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
99 translated through the type_translations hash table to get
100 the index into the type vector.) */
101
102 EXTERN struct type **type_vector;
103
104 /* Number of elements allocated for type_vector currently. */
105
106 EXTERN int type_vector_length;
107
108 /* Hash table of global symbols whose values are not known yet.
109 They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
110 have the correct data for that slot yet. */
111 /* The use of the LOC_BLOCK code in this chain is nonstandard--
112 it refers to a FORTRAN common block rather than the usual meaning. */
113
114 #define HASHSIZE 127
115 EXTERN struct symbol *global_sym_chain[HASHSIZE];
116
117 /* Record the symbols defined for each context in a list.
118 We don't create a struct block for the context until we
119 know how long to make it. */
120
121 #define PENDINGSIZE 100
122
123 struct pending
124 {
125 struct pending *next;
126 int nsyms;
127 struct symbol *symbol[PENDINGSIZE];
128 };
129
130 /* List of free `struct pending' structures for reuse. */
131 EXTERN struct pending *free_pendings;
132
133 /* Here are the three lists that symbols are put on. */
134
135 EXTERN struct pending *file_symbols; /* static at top level, and types */
136
137 EXTERN struct pending *global_symbols; /* global functions and variables */
138
139 EXTERN struct pending *local_symbols; /* everything local to lexic context */
140
141 /* Kludge for xcoffread.c */
142 struct pending_stabs {
143 int count, length;
144 char *stab[1];
145 };
146
147 EXTERN struct pending_stabs *global_stabs;
148 EXTERN struct pending_stabs *file_stabs;
149
150 /* List of symbols declared since the last BCOMM. This list is a tail
151 of local_symbols. When ECOMM is seen, the symbols on the list
152 are noted so their proper addresses can be filled in later,
153 using the common block base address gotten from the assembler
154 stabs. */
155
156 EXTERN struct pending *common_block;
157 EXTERN int common_block_i;
158
159 /* Stack representing unclosed lexical contexts
160 (that will become blocks, eventually). */
161
162 struct context_stack
163 {
164 struct pending *locals;
165 struct pending_block *old_blocks;
166 struct symbol *name;
167 CORE_ADDR start_addr;
168 CORE_ADDR end_addr; /* Temp slot for exception handling. */
169 int depth;
170 };
171
172 EXTERN struct context_stack *context_stack;
173
174 /* Index of first unused entry in context stack. */
175 EXTERN int context_stack_depth;
176
177 /* Currently allocated size of context stack. */
178
179 EXTERN int context_stack_size;
180
181 /* Nonzero if within a function (so symbols should be local,
182 if nothing says specifically). */
183
184 EXTERN int within_function;
185
186 /* List of blocks already made (lexical contexts already closed).
187 This is used at the end to make the blockvector. */
188
189 struct pending_block
190 {
191 struct pending_block *next;
192 struct block *block;
193 };
194
195 EXTERN struct pending_block *pending_blocks;
196
197 extern CORE_ADDR startup_file_start; /* From blockframe.c */
198 extern CORE_ADDR startup_file_end; /* From blockframe.c */
199
200 /* Global variable which, when set, indicates that we are processing a
201 .o file compiled with gcc */
202
203 EXTERN unsigned char processing_gcc_compilation;
204
205 /* Setup a define to deal cleanly with the underscore problem */
206
207 #ifdef NAMES_HAVE_UNDERSCORE
208 #define HASH_OFFSET 1
209 #else
210 #define HASH_OFFSET 0
211 #endif
212 \f
213 /* Support for Sun changes to dbx symbol format */
214
215 /* For each identified header file, we have a table of types defined
216 in that header file.
217
218 header_files maps header file names to their type tables.
219 It is a vector of n_header_files elements.
220 Each element describes one header file.
221 It contains a vector of types.
222
223 Sometimes it can happen that the same header file produces
224 different results when included in different places.
225 This can result from conditionals or from different
226 things done before including the file.
227 When this happens, there are multiple entries for the file in this table,
228 one entry for each distinct set of results.
229 The entries are distinguished by the INSTANCE field.
230 The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is
231 used to match header-file references to their corresponding data. */
232
233 struct header_file
234 {
235 char *name; /* Name of header file */
236 int instance; /* Numeric code distinguishing instances
237 of one header file that produced
238 different results when included.
239 It comes from the N_BINCL or N_EXCL. */
240 struct type **vector; /* Pointer to vector of types */
241 int length; /* Allocated length (# elts) of that vector */
242 };
243
244 EXTERN struct header_file *header_files;
245
246 EXTERN int n_header_files;
247
248 EXTERN int n_allocated_header_files;
249
250 /* Within each object file, various header files are assigned numbers.
251 A type is defined or referred to with a pair of numbers
252 (FILENUM,TYPENUM) where FILENUM is the number of the header file
253 and TYPENUM is the number within that header file.
254 TYPENUM is the index within the vector of types for that header file.
255
256 FILENUM == 1 is special; it refers to the main source of the object file,
257 and not to any header file. FILENUM != 1 is interpreted by looking it up
258 in the following table, which contains indices in header_files. */
259
260 EXTERN int *this_object_header_files;
261
262 EXTERN int n_this_object_header_files;
263
264 EXTERN int n_allocated_this_object_header_files;