1 /* Build symbol tables in GDB's internal format.
2 Copyright (C) 1986-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 (BUILDSYM_H)
23 /* This module provides definitions used for creating and adding to
24 the symbol table. These routines are called from various symbol-
25 file-reading routines.
27 They originated in dbxread.c of gdb-4.2, and were split out to
28 make xcoffread.c more maintainable by sharing code.
30 Variables declared in this file can be defined by #define-ing
31 the name EXTERN to null. It is used to declare variables that
32 are normally extern, but which get defined in a single module
33 using this technique. */
39 /* Convert stab register number (from `r' declaration) to a gdb REGNUM. */
41 #ifndef STAB_REG_TO_REGNUM
42 #define STAB_REG_TO_REGNUM(VALUE) (VALUE)
45 /* Name of source file whose symbol data we are now processing.
46 This comes from a symbol of type N_SO. */
48 EXTERN
char *last_source_file
;
50 /* Core address of start of text of current source file.
51 This too comes from the N_SO symbol. */
53 EXTERN CORE_ADDR last_source_start_addr
;
55 /* The list of sub-source-files within the current individual compilation.
56 Each file gets its own symtab with its own linetable and associated info,
57 but they all share one blockvector. */
64 struct linetable
*line_vector
;
65 int line_vector_length
;
68 EXTERN
struct subfile
*subfiles
;
70 EXTERN
struct subfile
*current_subfile
;
72 /* Global variable which, when set, indicates that we are processing a
73 .o file compiled with gcc */
75 EXTERN
unsigned char processing_gcc_compilation
;
77 /* Count symbols as they are processed, for error messages. */
79 EXTERN
unsigned int symnum
;
81 /* Vector of types defined so far, indexed by their dbx type numbers.
82 (In newer sun systems, dbx uses a pair of numbers in parens,
83 as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
84 translated through the type_translations hash table to get
85 the index into the type vector.) */
87 EXTERN
struct type
**type_vector
;
89 /* Number of elements allocated for type_vector currently. */
91 EXTERN
int type_vector_length
;
93 /* Hash table of global symbols whose values are not known yet.
94 They are chained thru the SYMBOL_VALUE_CHAIN, since we don't
95 have the correct data for that slot yet. */
96 /* The use of the LOC_BLOCK code in this chain is nonstandard--
97 it refers to a FORTRAN common block rather than the usual meaning. */
100 EXTERN
struct symbol
*global_sym_chain
[HASHSIZE
];
102 /* Record the symbols defined for each context in a list.
103 We don't create a struct block for the context until we
104 know how long to make it. */
106 #define PENDINGSIZE 100
110 struct pending
*next
;
112 struct symbol
*symbol
[PENDINGSIZE
];
115 /* List of free `struct pending' structures for reuse. */
116 EXTERN
struct pending
*free_pendings
;
118 /* Here are the three lists that symbols are put on. */
120 EXTERN
struct pending
*file_symbols
; /* static at top level, and types */
122 EXTERN
struct pending
*global_symbols
; /* global functions and variables */
124 EXTERN
struct pending
*local_symbols
; /* everything local to lexic context */
126 /* Kludge for xcoffread.c */
127 struct pending_stabs
{
132 EXTERN
struct pending_stabs
*global_stabs
;
134 /* List of symbols declared since the last BCOMM. This list is a tail
135 of local_symbols. When ECOMM is seen, the symbols on the list
136 are noted so their proper addresses can be filled in later,
137 using the common block base address gotten from the assembler
140 EXTERN
struct pending
*common_block
;
141 EXTERN
int common_block_i
;
143 /* Stack representing unclosed lexical contexts
144 (that will become blocks, eventually). */
148 struct pending
*locals
; /* Outer locals at the time we entered */
149 struct pending_block
*old_blocks
; /* Pointer into blocklist as of entry */
150 struct symbol
*name
; /* Name of function, if any, defining context*/
151 CORE_ADDR start_addr
; /* PC where this context starts */
152 CORE_ADDR end_addr
; /* Temp slot for exception handling. */
153 int depth
; /* For error-checking matching push/pop */
156 EXTERN
struct context_stack
*context_stack
;
158 /* Index of first unused entry in context stack. */
159 EXTERN
int context_stack_depth
;
161 /* Currently allocated size of context stack. */
163 EXTERN
int context_stack_size
;
165 /* Macro "function" for popping contexts from the stack. Pushing is done
166 by a real function, push_context. This returns a pointer to a struct
169 #define pop_context() \
170 (&context_stack[--context_stack_depth]);
172 /* Nonzero if within a function (so symbols should be local,
173 if nothing says specifically). */
175 EXTERN
int within_function
;
177 /* List of blocks already made (lexical contexts already closed).
178 This is used at the end to make the blockvector. */
182 struct pending_block
*next
;
186 EXTERN
struct pending_block
*pending_blocks
;
188 /* Global variable which, when set, indicates that we are processing a
189 .o file compiled with gcc */
191 EXTERN
unsigned char processing_gcc_compilation
;
193 /* The type code that process_one_symbol saw on its previous invocation.
194 Used to detect pairs of N_SO symbols. */
196 EXTERN
int previous_stab_code
;
198 /* Setup a define to deal cleanly with the underscore problem */
200 #ifdef NAMES_HAVE_UNDERSCORE
201 #define HASH_OFFSET 1
203 #define HASH_OFFSET 0
206 /* Support for Sun changes to dbx symbol format */
208 /* For each identified header file, we have a table of types defined
211 header_files maps header file names to their type tables.
212 It is a vector of n_header_files elements.
213 Each element describes one header file.
214 It contains a vector of types.
216 Sometimes it can happen that the same header file produces
217 different results when included in different places.
218 This can result from conditionals or from different
219 things done before including the file.
220 When this happens, there are multiple entries for the file in this table,
221 one entry for each distinct set of results.
222 The entries are distinguished by the INSTANCE field.
223 The INSTANCE field appears in the N_BINCL and N_EXCL symbol table and is
224 used to match header-file references to their corresponding data. */
228 char *name
; /* Name of header file */
229 int instance
; /* Numeric code distinguishing instances
230 of one header file that produced
231 different results when included.
232 It comes from the N_BINCL or N_EXCL. */
233 struct type
**vector
; /* Pointer to vector of types */
234 int length
; /* Allocated length (# elts) of that vector */
237 EXTERN
struct header_file
*header_files
;
239 EXTERN
int n_header_files
;
241 EXTERN
int n_allocated_header_files
;
243 /* Within each object file, various header files are assigned numbers.
244 A type is defined or referred to with a pair of numbers
245 (FILENUM,TYPENUM) where FILENUM is the number of the header file
246 and TYPENUM is the number within that header file.
247 TYPENUM is the index within the vector of types for that header file.
249 FILENUM == 1 is special; it refers to the main source of the object file,
250 and not to any header file. FILENUM != 1 is interpreted by looking it up
251 in the following table, which contains indices in header_files. */
253 EXTERN
int *this_object_header_files
;
255 EXTERN
int n_this_object_header_files
;
257 EXTERN
int n_allocated_this_object_header_files
;
259 /* When a header file is getting special overriding definitions
260 for one source file, record here the header_files index
261 of its normal definition vector.
262 At other times, this is -1. */
264 EXTERN
int header_file_prev_index
;
268 struct subfile_stack
*next
;
273 EXTERN
struct subfile_stack
*subfile_stack
;
275 extern struct complaint unknown_symtype_complaint
;
277 #define next_symbol_text() (*next_symbol_text_func)()
279 /* Function to invoke get the next symbol. Return the symbol name. */
281 EXTERN
char *(*next_symbol_text_func
) PARAMS ((void));
284 add_symbol_to_list
PARAMS ((struct symbol
*, struct pending
**));
286 extern struct symbol
*
287 find_symbol_in_list
PARAMS ((struct pending
*, char *, int));
290 read_type_number
PARAMS ((char **, int *));
293 read_type
PARAMS ((char **, struct objfile
*));
295 extern struct type
**
296 dbx_lookup_type
PARAMS ((int [2]));
299 read_number
PARAMS ((char **, int));
302 finish_block
PARAMS ((struct symbol
*, struct pending
**,
303 struct pending_block
*, CORE_ADDR
, CORE_ADDR
,
307 add_undefined_type
PARAMS ((struct type
*));
310 really_free_pendings
PARAMS ((int foo
));
313 start_subfile
PARAMS ((char *, char *));
316 push_subfile
PARAMS ((void));
319 pop_subfile
PARAMS ((void));
321 extern struct symtab
*
322 end_symtab
PARAMS ((CORE_ADDR
, int, int,struct objfile
*));
325 scan_file_globals
PARAMS ((struct objfile
*));
328 buildsym_new_init
PARAMS ((void));
331 buildsym_init
PARAMS ((void));
333 extern struct context_stack
*
334 push_context
PARAMS ((int, CORE_ADDR
));
337 record_line
PARAMS ((struct subfile
*, int, CORE_ADDR
));
340 start_symtab
PARAMS ((char *, char *, CORE_ADDR
));
342 extern struct symbol
*
343 define_symbol
PARAMS ((unsigned int, char *, int, int, struct objfile
*));
345 extern struct partial_symtab
*
346 start_psymtab
PARAMS ((struct objfile
*, CORE_ADDR
, char *, CORE_ADDR
, int,
347 struct partial_symbol
*, struct partial_symbol
*));
350 end_psymtab
PARAMS ((struct partial_symtab
*, char **, int, int, CORE_ADDR
,
351 struct partial_symtab
**, int));
354 process_one_symbol
PARAMS ((int, int, CORE_ADDR
, char *, int,
358 hashname
PARAMS ((char *));
360 #endif /* defined (BUILDSYM_H) */