1 /* Build symbol tables in GDB's internal format.
2 Copyright (C) 1986-1996 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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
;
66 EXTERN
struct subfile
*subfiles
;
68 EXTERN
struct subfile
*current_subfile
;
70 /* Global variable which, when set, indicates that we are processing a
71 .o file compiled with gcc */
73 EXTERN
unsigned char processing_gcc_compilation
;
75 /* When set, we are processing a .o file compiled by sun acc. This is
76 misnamed; it refers to all stabs-in-elf implementations which use
77 N_UNDF the way Sun does, including Solaris gcc. Hopefully all
78 stabs-in-elf implementations ever invented will choose to be
81 EXTERN
unsigned char processing_acc_compilation
;
83 /* Count symbols as they are processed, for error messages. */
85 EXTERN
unsigned int symnum
;
87 /* Record the symbols defined for each context in a list.
88 We don't create a struct block for the context until we
89 know how long to make it. */
91 #define PENDINGSIZE 100
97 struct symbol
*symbol
[PENDINGSIZE
];
100 /* Here are the three lists that symbols are put on. */
102 EXTERN
struct pending
*file_symbols
; /* static at top level, and types */
104 EXTERN
struct pending
*global_symbols
; /* global functions and variables */
106 EXTERN
struct pending
*local_symbols
; /* everything local to lexic context */
108 /* Stack representing unclosed lexical contexts
109 (that will become blocks, eventually). */
113 /* Outer locals at the time we entered */
115 struct pending
*locals
;
117 /* Pointer into blocklist as of entry */
119 struct pending_block
*old_blocks
;
121 /* Name of function, if any, defining context*/
125 /* PC where this context starts */
127 CORE_ADDR start_addr
;
129 /* Temp slot for exception handling. */
133 /* For error-checking matching push/pop */
139 EXTERN
struct context_stack
*context_stack
;
141 /* Index of first unused entry in context stack. */
143 EXTERN
int context_stack_depth
;
145 /* Currently allocated size of context stack. */
147 EXTERN
int context_stack_size
;
149 /* Macro "function" for popping contexts from the stack. Pushing is done
150 by a real function, push_context. This returns a pointer to a struct
153 #define pop_context() (&context_stack[--context_stack_depth]);
155 /* Nonzero if within a function (so symbols should be local,
156 if nothing says specifically). */
158 EXTERN
int within_function
;
160 /* List of blocks already made (lexical contexts already closed).
161 This is used at the end to make the blockvector. */
165 struct pending_block
*next
;
169 /* Pointer to the head of a linked list of symbol blocks which have
170 already been finalized (lexical contexts already closed) and which are
171 just waiting to be built into a blockvector when finalizing the
172 associated symtab. */
174 EXTERN
struct pending_block
*pending_blocks
;
179 struct subfile_stack
*next
;
183 EXTERN
struct subfile_stack
*subfile_stack
;
185 #define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)
187 /* Function to invoke get the next symbol. Return the symbol name. */
189 EXTERN
char *(*next_symbol_text_func
) PARAMS ((struct objfile
*));
191 /* Vector of types defined so far, indexed by their type numbers.
192 Used for both stabs and coff.
193 (In newer sun systems, dbx uses a pair of numbers in parens,
194 as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be
195 translated through the type_translations hash table to get
196 the index into the type vector.) */
198 EXTERN
struct type
**type_vector
;
200 /* Number of elements allocated for type_vector currently. */
202 EXTERN
int type_vector_length
;
204 /* Initial size of type vector. Is realloc'd larger if needed,
205 and realloc'd down to the size actually used, when completed. */
207 #define INITIAL_TYPE_VECTOR_LENGTH 160
210 add_symbol_to_list
PARAMS ((struct symbol
*, struct pending
**));
212 extern struct symbol
*
213 find_symbol_in_list
PARAMS ((struct pending
*, char *, int));
216 finish_block
PARAMS ((struct symbol
*, struct pending
**,
217 struct pending_block
*, CORE_ADDR
, CORE_ADDR
,
221 really_free_pendings
PARAMS ((int foo
));
224 start_subfile
PARAMS ((char *, char *));
227 patch_subfile_names
PARAMS ((struct subfile
*subfile
, char *name
));
230 push_subfile
PARAMS ((void));
233 pop_subfile
PARAMS ((void));
235 extern struct symtab
*
236 end_symtab
PARAMS ((CORE_ADDR
, struct objfile
*, int));
239 scan_file_globals
PARAMS ((struct objfile
*));
242 buildsym_new_init
PARAMS ((void));
245 buildsym_init
PARAMS ((void));
247 extern struct context_stack
*
248 push_context
PARAMS ((int, CORE_ADDR
));
251 record_line
PARAMS ((struct subfile
*, int, CORE_ADDR
));
254 start_symtab
PARAMS ((char *, char *, CORE_ADDR
));
257 hashname
PARAMS ((char *));
260 free_pending_blocks
PARAMS ((void));
262 /* FIXME: Note that this is used only in buildsym.c and dstread.c,
263 which should be fixed to not need direct access to make_blockvector. */
265 extern struct blockvector
*
266 make_blockvector
PARAMS ((struct objfile
*));
268 /* FIXME: Note that this is used only in buildsym.c and dstread.c,
269 which should be fixed to not need direct access to record_pending_block. */
272 record_pending_block
PARAMS ((struct objfile
*, struct block
*,
273 struct pending_block
*));
276 record_debugformat
PARAMS ((char *));
280 #endif /* defined (BUILDSYM_H) */