More dos scripts
[deliverable/binutils-gdb.git] / gdb / buildsym.h
CommitLineData
c0302457
JG
1/* Build symbol tables in GDB's internal format.
2 Copyright (C) 1986-1991 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
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
17along with this program; if not, write to the Free Software
18Foundation, 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
36extern void add_symbol_to_list ();
a048c8f5
JG
37struct symbol *find_symbol_in_list ();
38extern void read_type_number ();
c0302457
JG
39extern struct type *read_type ();
40extern struct type *read_range_type ();
41extern struct type *read_enum_type ();
42extern struct type *read_struct_type ();
43extern struct type *read_array_type ();
44extern struct type **read_args ();
45extern struct type **dbx_lookup_type ();
46extern long read_number ();
47extern void finish_block ();
48extern struct blockvector *make_blockvector ();
a048c8f5 49extern void add_undefined_type ();
c0302457 50extern void really_free_pendings ();
4137c5fc 51extern void start_subfile ();
a048c8f5
JG
52extern void push_subfile ();
53extern char *pop_subfile ();
c0302457
JG
54extern struct symtab *end_symtab ();
55extern void scan_file_globals ();
56extern void buildsym_new_init ();
57extern void buildsym_init ();
a048c8f5
JG
58extern struct context_stack *push_context ();
59extern void record_line ();
60extern void start_symtab ();
61extern struct symbol *define_symbol ();
7e258d18
PB
62extern struct partial_symtab *start_psymtab ();
63extern void end_psymtab();
64
c0302457
JG
65
66/* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
67
68#ifndef STAB_REG_TO_REGNUM
69#define STAB_REG_TO_REGNUM(VALUE) (VALUE)
70#endif
71\f
72/* Name of source file whose symbol data we are now processing.
73 This comes from a symbol of type N_SO. */
74
75EXTERN char *last_source_file;
76
77/* Core address of start of text of current source file.
78 This too comes from the N_SO symbol. */
79
80EXTERN CORE_ADDR last_source_start_addr;
81
82/* The list of sub-source-files within the current individual compilation.
83 Each file gets its own symtab with its own linetable and associated info,
84 but they all share one blockvector. */
85
86struct subfile
87{
88 struct subfile *next;
89 char *name;
90 char *dirname;
91 struct linetable *line_vector;
92 int line_vector_length;
c0302457
JG
93};
94
95EXTERN struct subfile *subfiles;
96
97EXTERN struct subfile *current_subfile;
98
99/* Global variable which, when set, indicates that we are processing a
100 .o file compiled with gcc */
101
102EXTERN unsigned char processing_gcc_compilation;
103
104/* Count symbols as they are processed, for error messages. */
105
106EXTERN unsigned int symnum;
107
108/* Vector of types defined so far, indexed by their dbx type numbers.
109 (In newer sun systems, dbx uses a pair of numbers in parens,
110 as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
111 translated through the type_translations hash table to get
112 the index into the type vector.) */
113
114EXTERN struct type **type_vector;
115
116/* Number of elements allocated for type_vector currently. */
117
118EXTERN int type_vector_length;
119
c0302457
JG
120/* Hash table of global symbols whose values are not known yet.
121 They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
122 have the correct data for that slot yet. */
123/* The use of the LOC_BLOCK code in this chain is nonstandard--
124 it refers to a FORTRAN common block rather than the usual meaning. */
125
126#define HASHSIZE 127
127EXTERN struct symbol *global_sym_chain[HASHSIZE];
128
129/* Record the symbols defined for each context in a list.
130 We don't create a struct block for the context until we
131 know how long to make it. */
132
133#define PENDINGSIZE 100
134
135struct pending
136{
137 struct pending *next;
138 int nsyms;
139 struct symbol *symbol[PENDINGSIZE];
140};
141
142/* List of free `struct pending' structures for reuse. */
143EXTERN struct pending *free_pendings;
144
145/* Here are the three lists that symbols are put on. */
146
147EXTERN struct pending *file_symbols; /* static at top level, and types */
148
149EXTERN struct pending *global_symbols; /* global functions and variables */
150
4137c5fc
JG
151EXTERN struct pending *local_symbols; /* everything local to lexic context */
152
153/* Kludge for xcoffread.c */
154struct pending_stabs {
155 int count, length;
156 char *stab[1];
157};
158
159EXTERN struct pending_stabs *global_stabs;
160EXTERN struct pending_stabs *file_stabs;
c0302457
JG
161
162/* List of symbols declared since the last BCOMM. This list is a tail
163 of local_symbols. When ECOMM is seen, the symbols on the list
164 are noted so their proper addresses can be filled in later,
165 using the common block base address gotten from the assembler
166 stabs. */
167
168EXTERN struct pending *common_block;
169EXTERN int common_block_i;
170
171/* Stack representing unclosed lexical contexts
172 (that will become blocks, eventually). */
173
174struct context_stack
175{
a048c8f5
JG
176 struct pending *locals; /* Outer locals at the time we entered */
177 struct pending_block *old_blocks; /* Pointer into blocklist as of entry */
178 struct symbol *name; /* Name of function, if any, defining context*/
179 CORE_ADDR start_addr; /* PC where this context starts */
c0302457 180 CORE_ADDR end_addr; /* Temp slot for exception handling. */
a048c8f5 181 int depth; /* For error-checking matching push/pop */
c0302457
JG
182};
183
184EXTERN struct context_stack *context_stack;
185
186/* Index of first unused entry in context stack. */
187EXTERN int context_stack_depth;
188
189/* Currently allocated size of context stack. */
190
191EXTERN int context_stack_size;
192
a048c8f5
JG
193/* Macro "function" for popping contexts from the stack. Pushing is done
194 by a real function, push_context. This returns a pointer to a struct
195 context_stack. */
196
197#define pop_context() \
198 (&context_stack[--context_stack_depth]);
199
c0302457
JG
200/* Nonzero if within a function (so symbols should be local,
201 if nothing says specifically). */
202
203EXTERN int within_function;
204
205/* List of blocks already made (lexical contexts already closed).
206 This is used at the end to make the blockvector. */
207
208struct pending_block
209{
210 struct pending_block *next;
211 struct block *block;
212};
213
214EXTERN struct pending_block *pending_blocks;
215
216extern CORE_ADDR startup_file_start; /* From blockframe.c */
217extern CORE_ADDR startup_file_end; /* From blockframe.c */
218
219/* Global variable which, when set, indicates that we are processing a
220 .o file compiled with gcc */
221
222EXTERN unsigned char processing_gcc_compilation;
223
7e258d18
PB
224/* The type code that process_one_symbol saw on its previous invocation.
225 Used to detect pairs of N_SO symbols. */
226
227EXTERN int previous_stab_code;
228
c0302457
JG
229/* Setup a define to deal cleanly with the underscore problem */
230
231#ifdef NAMES_HAVE_UNDERSCORE
232#define HASH_OFFSET 1
233#else
234#define HASH_OFFSET 0
235#endif
236\f
237/* Support for Sun changes to dbx symbol format */
238
239/* For each identified header file, we have a table of types defined
240 in that header file.
241
242 header_files maps header file names to their type tables.
243 It is a vector of n_header_files elements.
244 Each element describes one header file.
245 It contains a vector of types.
246
247 Sometimes it can happen that the same header file produces
248 different results when included in different places.
249 This can result from conditionals or from different
250 things done before including the file.
251 When this happens, there are multiple entries for the file in this table,
252 one entry for each distinct set of results.
253 The entries are distinguished by the INSTANCE field.
254 The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is
255 used to match header-file references to their corresponding data. */
256
257struct header_file
258{
259 char *name; /* Name of header file */
260 int instance; /* Numeric code distinguishing instances
261 of one header file that produced
262 different results when included.
263 It comes from the N_BINCL or N_EXCL. */
264 struct type **vector; /* Pointer to vector of types */
265 int length; /* Allocated length (# elts) of that vector */
266};
267
268EXTERN struct header_file *header_files;
269
270EXTERN int n_header_files;
271
272EXTERN int n_allocated_header_files;
273
274/* Within each object file, various header files are assigned numbers.
275 A type is defined or referred to with a pair of numbers
276 (FILENUM,TYPENUM) where FILENUM is the number of the header file
277 and TYPENUM is the number within that header file.
278 TYPENUM is the index within the vector of types for that header file.
279
280 FILENUM == 1 is special; it refers to the main source of the object file,
281 and not to any header file. FILENUM != 1 is interpreted by looking it up
282 in the following table, which contains indices in header_files. */
283
284EXTERN int *this_object_header_files;
285
286EXTERN int n_this_object_header_files;
287
288EXTERN int n_allocated_this_object_header_files;
a048c8f5
JG
289
290/* When a header file is getting special overriding definitions
291 for one source file, record here the header_files index
292 of its normal definition vector.
293 At other times, this is -1. */
294
295EXTERN int header_file_prev_index;
296
297struct subfile_stack
298{
299 struct subfile_stack *next;
300 char *name;
301 int prev_index;
302};
303
304EXTERN struct subfile_stack *subfile_stack;
aab77d5f
PB
305
306extern struct complaint unknown_symtype_complaint;
307
308#define next_symbol_text() (*next_symbol_text_func)()
309
310/* Function to invoke get the next symbol. Return the symbol name. */
311
312EXTERN char * (*next_symbol_text_func)();
This page took 0.04335 seconds and 4 git commands to generate.