]>
Commit | Line | Data |
---|---|---|
c0302457 JG |
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 | ||
1ab3bf1b JG |
20 | #if !defined (BUILDSYM_H) |
21 | #define BUILDSYM_H 1 | |
22 | ||
c0302457 JG |
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. | |
26 | ||
27 | They originated in dbxread.c of gdb-4.2, and were split out to | |
28 | make xcoffread.c more maintainable by sharing code. | |
29 | ||
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. */ | |
34 | ||
35 | #ifndef EXTERN | |
d07734e3 | 36 | #define EXTERN extern |
c0302457 JG |
37 | #endif |
38 | ||
d07734e3 | 39 | #define HASHSIZE 127 /* Size of things hashed via hashname() */ |
c0302457 | 40 | |
c0302457 | 41 | /* Name of source file whose symbol data we are now processing. |
d07734e3 | 42 | This comes from a symbol of type N_SO. */ |
c0302457 JG |
43 | |
44 | EXTERN char *last_source_file; | |
45 | ||
46 | /* Core address of start of text of current source file. | |
d07734e3 | 47 | This too comes from the N_SO symbol. */ |
c0302457 JG |
48 | |
49 | EXTERN CORE_ADDR last_source_start_addr; | |
50 | ||
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. */ | |
54 | ||
55 | struct subfile | |
56 | { | |
57 | struct subfile *next; | |
58 | char *name; | |
59 | char *dirname; | |
60 | struct linetable *line_vector; | |
61 | int line_vector_length; | |
c0302457 JG |
62 | }; |
63 | ||
64 | EXTERN struct subfile *subfiles; | |
65 | ||
66 | EXTERN struct subfile *current_subfile; | |
67 | ||
68 | /* Global variable which, when set, indicates that we are processing a | |
69 | .o file compiled with gcc */ | |
70 | ||
71 | EXTERN unsigned char processing_gcc_compilation; | |
72 | ||
93297ea0 | 73 | /* When set, we are processing a .o file compiled by sun acc */ |
d07734e3 | 74 | |
93297ea0 JG |
75 | EXTERN unsigned char processing_acc_compilation; |
76 | ||
c0302457 JG |
77 | /* Count symbols as they are processed, for error messages. */ |
78 | ||
79 | EXTERN unsigned int symnum; | |
80 | ||
c0302457 JG |
81 | /* Record the symbols defined for each context in a list. |
82 | We don't create a struct block for the context until we | |
83 | know how long to make it. */ | |
84 | ||
85 | #define PENDINGSIZE 100 | |
86 | ||
87 | struct pending | |
88 | { | |
89 | struct pending *next; | |
90 | int nsyms; | |
91 | struct symbol *symbol[PENDINGSIZE]; | |
92 | }; | |
93 | ||
94 | /* List of free `struct pending' structures for reuse. */ | |
d07734e3 | 95 | |
c0302457 JG |
96 | EXTERN struct pending *free_pendings; |
97 | ||
98 | /* Here are the three lists that symbols are put on. */ | |
99 | ||
100 | EXTERN struct pending *file_symbols; /* static at top level, and types */ | |
101 | ||
102 | EXTERN struct pending *global_symbols; /* global functions and variables */ | |
103 | ||
4137c5fc JG |
104 | EXTERN struct pending *local_symbols; /* everything local to lexic context */ |
105 | ||
c0302457 JG |
106 | /* Stack representing unclosed lexical contexts |
107 | (that will become blocks, eventually). */ | |
108 | ||
109 | struct context_stack | |
110 | { | |
d07734e3 FF |
111 | /* Outer locals at the time we entered */ |
112 | ||
113 | struct pending *locals; | |
114 | ||
115 | /* Pointer into blocklist as of entry */ | |
116 | ||
117 | struct pending_block *old_blocks; | |
118 | ||
119 | /* Name of function, if any, defining context*/ | |
120 | ||
121 | struct symbol *name; | |
122 | ||
123 | /* PC where this context starts */ | |
124 | ||
125 | CORE_ADDR start_addr; | |
126 | ||
127 | /* Temp slot for exception handling. */ | |
128 | ||
129 | CORE_ADDR end_addr; | |
130 | ||
131 | /* For error-checking matching push/pop */ | |
132 | ||
133 | int depth; | |
134 | ||
c0302457 JG |
135 | }; |
136 | ||
137 | EXTERN struct context_stack *context_stack; | |
138 | ||
139 | /* Index of first unused entry in context stack. */ | |
d07734e3 | 140 | |
c0302457 JG |
141 | EXTERN int context_stack_depth; |
142 | ||
143 | /* Currently allocated size of context stack. */ | |
144 | ||
145 | EXTERN int context_stack_size; | |
146 | ||
a048c8f5 JG |
147 | /* Macro "function" for popping contexts from the stack. Pushing is done |
148 | by a real function, push_context. This returns a pointer to a struct | |
149 | context_stack. */ | |
150 | ||
d07734e3 | 151 | #define pop_context() (&context_stack[--context_stack_depth]); |
a048c8f5 | 152 | |
c0302457 JG |
153 | /* Nonzero if within a function (so symbols should be local, |
154 | if nothing says specifically). */ | |
155 | ||
156 | EXTERN int within_function; | |
157 | ||
158 | /* List of blocks already made (lexical contexts already closed). | |
159 | This is used at the end to make the blockvector. */ | |
160 | ||
161 | struct pending_block | |
162 | { | |
163 | struct pending_block *next; | |
164 | struct block *block; | |
165 | }; | |
166 | ||
167 | EXTERN struct pending_block *pending_blocks; | |
168 | ||
c0302457 | 169 | \f |
a048c8f5 JG |
170 | struct subfile_stack |
171 | { | |
172 | struct subfile_stack *next; | |
173 | char *name; | |
a048c8f5 JG |
174 | }; |
175 | ||
176 | EXTERN struct subfile_stack *subfile_stack; | |
aab77d5f | 177 | |
aab77d5f PB |
178 | #define next_symbol_text() (*next_symbol_text_func)() |
179 | ||
180 | /* Function to invoke get the next symbol. Return the symbol name. */ | |
181 | ||
1ab3bf1b JG |
182 | EXTERN char *(*next_symbol_text_func) PARAMS ((void)); |
183 | ||
d07734e3 FF |
184 | /* Vector of types defined so far, indexed by their type numbers. |
185 | Used for both stabs and coff. | |
186 | (In newer sun systems, dbx uses a pair of numbers in parens, | |
187 | as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be | |
188 | translated through the type_translations hash table to get | |
189 | the index into the type vector.) */ | |
1ab3bf1b | 190 | |
d07734e3 | 191 | EXTERN struct type **type_vector; |
1ab3bf1b | 192 | |
d07734e3 | 193 | /* Number of elements allocated for type_vector currently. */ |
1ab3bf1b | 194 | |
d07734e3 | 195 | EXTERN int type_vector_length; |
1ab3bf1b | 196 | |
d07734e3 FF |
197 | /* Initial size of type vector. Is realloc'd larger if needed, |
198 | and realloc'd down to the size actually used, when completed. */ | |
1ab3bf1b | 199 | |
d07734e3 FF |
200 | #define INITIAL_TYPE_VECTOR_LENGTH 160 |
201 | ||
202 | extern void | |
203 | add_symbol_to_list PARAMS ((struct symbol *, struct pending **)); | |
204 | ||
205 | extern struct symbol * | |
206 | find_symbol_in_list PARAMS ((struct pending *, char *, int)); | |
1ab3bf1b JG |
207 | |
208 | extern void | |
209 | finish_block PARAMS ((struct symbol *, struct pending **, | |
210 | struct pending_block *, CORE_ADDR, CORE_ADDR, | |
211 | struct objfile *)); | |
212 | ||
1ab3bf1b JG |
213 | extern void |
214 | really_free_pendings PARAMS ((int foo)); | |
215 | ||
216 | extern void | |
217 | start_subfile PARAMS ((char *, char *)); | |
218 | ||
3416d90b FF |
219 | extern void |
220 | patch_subfile_names PARAMS ((struct subfile *subfile, char *name)); | |
221 | ||
1ab3bf1b JG |
222 | extern void |
223 | push_subfile PARAMS ((void)); | |
224 | ||
225 | extern char * | |
226 | pop_subfile PARAMS ((void)); | |
227 | ||
228 | extern struct symtab * | |
d07734e3 | 229 | end_symtab PARAMS ((CORE_ADDR, int, int, struct objfile *)); |
1ab3bf1b JG |
230 | |
231 | extern void | |
232 | scan_file_globals PARAMS ((struct objfile *)); | |
233 | ||
234 | extern void | |
235 | buildsym_new_init PARAMS ((void)); | |
236 | ||
237 | extern void | |
238 | buildsym_init PARAMS ((void)); | |
239 | ||
240 | extern struct context_stack * | |
241 | push_context PARAMS ((int, CORE_ADDR)); | |
242 | ||
243 | extern void | |
244 | record_line PARAMS ((struct subfile *, int, CORE_ADDR)); | |
245 | ||
246 | extern void | |
247 | start_symtab PARAMS ((char *, char *, CORE_ADDR)); | |
248 | ||
1ab3bf1b | 249 | extern struct partial_symtab * |
2670f34d | 250 | start_psymtab PARAMS ((struct objfile *, struct section_offsets *, char *, |
d07734e3 FF |
251 | CORE_ADDR, int, struct partial_symbol *, |
252 | struct partial_symbol *)); | |
1ab3bf1b JG |
253 | |
254 | extern void | |
255 | end_psymtab PARAMS ((struct partial_symtab *, char **, int, int, CORE_ADDR, | |
256 | struct partial_symtab **, int)); | |
257 | ||
258 | extern void | |
2670f34d JG |
259 | process_one_symbol PARAMS ((int, int, CORE_ADDR, char *, |
260 | struct section_offsets *, struct objfile *)); | |
1ab3bf1b JG |
261 | extern int |
262 | hashname PARAMS ((char *)); | |
263 | ||
d07734e3 FF |
264 | #undef EXTERN |
265 | ||
1ab3bf1b | 266 | #endif /* defined (BUILDSYM_H) */ |