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 #define HASHSIZE 127 /* Size of things hashed via hashname() */
41 /* Name of source file whose symbol data we are now processing.
42 This comes from a symbol of type N_SO. */
44 EXTERN
char *last_source_file
;
46 /* Core address of start of text of current source file.
47 This too comes from the N_SO symbol. */
49 EXTERN CORE_ADDR last_source_start_addr
;
51 /* The list of sub-source-files within the current individual compilation.
52 Each file gets its own symtab with its own linetable and associated info,
53 but they all share one blockvector. */
60 struct linetable
*line_vector
;
61 int line_vector_length
;
62 enum language language
;
65 EXTERN
struct subfile
*subfiles
;
67 EXTERN
struct subfile
*current_subfile
;
69 /* Global variable which, when set, indicates that we are processing a
70 .o file compiled with gcc */
72 EXTERN
unsigned char processing_gcc_compilation
;
74 /* When set, we are processing a .o file compiled by sun acc. This is
75 misnamed; it refers to all stabs-in-elf implementations which use
76 N_UNDF the way Sun does, including Solaris gcc. Hopefully all
77 stabs-in-elf implementations ever invented will choose to be
80 EXTERN
unsigned char processing_acc_compilation
;
82 /* Count symbols as they are processed, for error messages. */
84 EXTERN
unsigned int symnum
;
86 /* Record the symbols defined for each context in a list.
87 We don't create a struct block for the context until we
88 know how long to make it. */
90 #define PENDINGSIZE 100
96 struct symbol
*symbol
[PENDINGSIZE
];
99 /* List of free `struct pending' structures for reuse. */
101 EXTERN
struct pending
*free_pendings
;
103 /* Here are the three lists that symbols are put on. */
105 EXTERN
struct pending
*file_symbols
; /* static at top level, and types */
107 EXTERN
struct pending
*global_symbols
; /* global functions and variables */
109 EXTERN
struct pending
*local_symbols
; /* everything local to lexic context */
111 /* Stack representing unclosed lexical contexts
112 (that will become blocks, eventually). */
116 /* Outer locals at the time we entered */
118 struct pending
*locals
;
120 /* Pointer into blocklist as of entry */
122 struct pending_block
*old_blocks
;
124 /* Name of function, if any, defining context*/
128 /* PC where this context starts */
130 CORE_ADDR start_addr
;
132 /* Temp slot for exception handling. */
136 /* For error-checking matching push/pop */
142 EXTERN
struct context_stack
*context_stack
;
144 /* Index of first unused entry in context stack. */
146 EXTERN
int context_stack_depth
;
148 /* Currently allocated size of context stack. */
150 EXTERN
int context_stack_size
;
152 /* Macro "function" for popping contexts from the stack. Pushing is done
153 by a real function, push_context. This returns a pointer to a struct
156 #define pop_context() (&context_stack[--context_stack_depth]);
158 /* Nonzero if within a function (so symbols should be local,
159 if nothing says specifically). */
161 EXTERN
int within_function
;
163 /* List of blocks already made (lexical contexts already closed).
164 This is used at the end to make the blockvector. */
168 struct pending_block
*next
;
172 EXTERN
struct pending_block
*pending_blocks
;
177 struct subfile_stack
*next
;
181 EXTERN
struct subfile_stack
*subfile_stack
;
183 #define next_symbol_text() (*next_symbol_text_func)()
185 /* Function to invoke get the next symbol. Return the symbol name. */
187 EXTERN
char *(*next_symbol_text_func
) PARAMS ((void));
189 /* Vector of types defined so far, indexed by their type numbers.
190 Used for both stabs and coff.
191 (In newer sun systems, dbx uses a pair of numbers in parens,
192 as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
193 translated through the type_translations hash table to get
194 the index into the type vector.) */
196 EXTERN
struct type
**type_vector
;
198 /* Number of elements allocated for type_vector currently. */
200 EXTERN
int type_vector_length
;
202 /* Initial size of type vector. Is realloc'd larger if needed,
203 and realloc'd down to the size actually used, when completed. */
205 #define INITIAL_TYPE_VECTOR_LENGTH 160
208 add_symbol_to_list
PARAMS ((struct symbol
*, struct pending
**));
210 extern struct symbol
*
211 find_symbol_in_list
PARAMS ((struct pending
*, char *, int));
214 finish_block
PARAMS ((struct symbol
*, struct pending
**,
215 struct pending_block
*, CORE_ADDR
, CORE_ADDR
,
219 really_free_pendings
PARAMS ((int foo
));
222 start_subfile
PARAMS ((char *, char *));
225 patch_subfile_names
PARAMS ((struct subfile
*subfile
, char *name
));
228 push_subfile
PARAMS ((void));
231 pop_subfile
PARAMS ((void));
233 extern struct symtab
*
234 end_symtab
PARAMS ((CORE_ADDR
, int, int, struct objfile
*, int));
237 scan_file_globals
PARAMS ((struct objfile
*));
240 buildsym_new_init
PARAMS ((void));
243 buildsym_init
PARAMS ((void));
245 extern struct context_stack
*
246 push_context
PARAMS ((int, CORE_ADDR
));
249 record_line
PARAMS ((struct subfile
*, int, CORE_ADDR
));
252 start_symtab
PARAMS ((char *, char *, CORE_ADDR
));
254 extern struct partial_symtab
*
255 start_psymtab
PARAMS ((struct objfile
*, struct section_offsets
*, char *,
256 CORE_ADDR
, int, struct partial_symbol
*,
257 struct partial_symbol
*));
260 end_psymtab
PARAMS ((struct partial_symtab
*, char **, int, int, CORE_ADDR
,
261 struct partial_symtab
**, int));
264 process_one_symbol
PARAMS ((int, int, CORE_ADDR
, char *,
265 struct section_offsets
*, struct objfile
*));
267 hashname
PARAMS ((char *));
271 #endif /* defined (BUILDSYM_H) */