Commit | Line | Data |
---|---|---|
c0302457 | 1 | /* Build symbol tables in GDB's internal format. |
436d4143 | 2 | Copyright (C) 1986-1996 Free Software Foundation, Inc. |
c0302457 JG |
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 | |
6c9638b4 | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
c0302457 | 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; | |
2e4964ad | 62 | enum language language; |
609fd033 | 63 | char *debugformat; |
c0302457 JG |
64 | }; |
65 | ||
66 | EXTERN struct subfile *subfiles; | |
67 | ||
68 | EXTERN struct subfile *current_subfile; | |
69 | ||
70 | /* Global variable which, when set, indicates that we are processing a | |
71 | .o file compiled with gcc */ | |
72 | ||
73 | EXTERN unsigned char processing_gcc_compilation; | |
74 | ||
e64ec645 JK |
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 | |
79 | compatible. */ | |
d07734e3 | 80 | |
93297ea0 JG |
81 | EXTERN unsigned char processing_acc_compilation; |
82 | ||
4770ff08 DT |
83 | /* elz: added this flag to know when a block is compiled with HP |
84 | compilers (cc, aCC). This is necessary because of the macro | |
85 | COERCE_FLOAT_TO_DOUBLE defined in tm_hppa.h, which causes | |
86 | a coercion of float to double to always occur in parameter passing | |
87 | for a function called by gdb (see the function value_arg_coerce in | |
88 | valops.c). This is necessary only if the target | |
89 | was compiled with gcc, not with HP compilers or with g++ */ | |
90 | ||
91 | EXTERN unsigned char processing_hp_compilation; | |
92 | ||
c0302457 JG |
93 | /* Count symbols as they are processed, for error messages. */ |
94 | ||
95 | EXTERN unsigned int symnum; | |
96 | ||
c0302457 JG |
97 | /* Record the symbols defined for each context in a list. |
98 | We don't create a struct block for the context until we | |
99 | know how long to make it. */ | |
100 | ||
101 | #define PENDINGSIZE 100 | |
102 | ||
103 | struct pending | |
104 | { | |
105 | struct pending *next; | |
106 | int nsyms; | |
107 | struct symbol *symbol[PENDINGSIZE]; | |
108 | }; | |
109 | ||
c0302457 JG |
110 | /* Here are the three lists that symbols are put on. */ |
111 | ||
112 | EXTERN struct pending *file_symbols; /* static at top level, and types */ | |
113 | ||
114 | EXTERN struct pending *global_symbols; /* global functions and variables */ | |
115 | ||
4137c5fc JG |
116 | EXTERN struct pending *local_symbols; /* everything local to lexic context */ |
117 | ||
4770ff08 DT |
118 | EXTERN struct pending *param_symbols; /* func params local to lexic context */ |
119 | ||
c0302457 JG |
120 | /* Stack representing unclosed lexical contexts |
121 | (that will become blocks, eventually). */ | |
122 | ||
123 | struct context_stack | |
124 | { | |
d07734e3 FF |
125 | /* Outer locals at the time we entered */ |
126 | ||
127 | struct pending *locals; | |
128 | ||
4770ff08 DT |
129 | /* Pending func params at the time we entered */ |
130 | ||
131 | struct pending *params; | |
132 | ||
d07734e3 FF |
133 | /* Pointer into blocklist as of entry */ |
134 | ||
135 | struct pending_block *old_blocks; | |
136 | ||
137 | /* Name of function, if any, defining context*/ | |
138 | ||
139 | struct symbol *name; | |
140 | ||
141 | /* PC where this context starts */ | |
142 | ||
143 | CORE_ADDR start_addr; | |
144 | ||
145 | /* Temp slot for exception handling. */ | |
146 | ||
147 | CORE_ADDR end_addr; | |
148 | ||
149 | /* For error-checking matching push/pop */ | |
150 | ||
151 | int depth; | |
152 | ||
c0302457 JG |
153 | }; |
154 | ||
155 | EXTERN struct context_stack *context_stack; | |
156 | ||
157 | /* Index of first unused entry in context stack. */ | |
d07734e3 | 158 | |
c0302457 JG |
159 | EXTERN int context_stack_depth; |
160 | ||
161 | /* Currently allocated size of context stack. */ | |
162 | ||
163 | EXTERN int context_stack_size; | |
164 | ||
a048c8f5 JG |
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 | |
167 | context_stack. */ | |
168 | ||
d07734e3 | 169 | #define pop_context() (&context_stack[--context_stack_depth]); |
a048c8f5 | 170 | |
c0302457 JG |
171 | /* Nonzero if within a function (so symbols should be local, |
172 | if nothing says specifically). */ | |
173 | ||
174 | EXTERN int within_function; | |
175 | ||
176 | /* List of blocks already made (lexical contexts already closed). | |
177 | This is used at the end to make the blockvector. */ | |
178 | ||
179 | struct pending_block | |
180 | { | |
181 | struct pending_block *next; | |
182 | struct block *block; | |
183 | }; | |
184 | ||
f85d9973 RU |
185 | /* Pointer to the head of a linked list of symbol blocks which have |
186 | already been finalized (lexical contexts already closed) and which are | |
187 | just waiting to be built into a blockvector when finalizing the | |
188 | associated symtab. */ | |
189 | ||
190 | EXTERN struct pending_block *pending_blocks; | |
191 | ||
c0302457 | 192 | \f |
a048c8f5 JG |
193 | struct subfile_stack |
194 | { | |
195 | struct subfile_stack *next; | |
196 | char *name; | |
a048c8f5 JG |
197 | }; |
198 | ||
199 | EXTERN struct subfile_stack *subfile_stack; | |
aab77d5f | 200 | |
2dd30c72 | 201 | #define next_symbol_text(objfile) (*next_symbol_text_func)(objfile) |
aab77d5f PB |
202 | |
203 | /* Function to invoke get the next symbol. Return the symbol name. */ | |
204 | ||
2dd30c72 | 205 | EXTERN char *(*next_symbol_text_func) PARAMS ((struct objfile *)); |
1ab3bf1b | 206 | |
d07734e3 FF |
207 | /* Vector of types defined so far, indexed by their type numbers. |
208 | Used for both stabs and coff. | |
209 | (In newer sun systems, dbx uses a pair of numbers in parens, | |
210 | as in "(SUBFILENUM,NUMWITHINSUBFILE)". Then these numbers must be | |
211 | translated through the type_translations hash table to get | |
212 | the index into the type vector.) */ | |
1ab3bf1b | 213 | |
d07734e3 | 214 | EXTERN struct type **type_vector; |
1ab3bf1b | 215 | |
d07734e3 | 216 | /* Number of elements allocated for type_vector currently. */ |
1ab3bf1b | 217 | |
d07734e3 | 218 | EXTERN int type_vector_length; |
1ab3bf1b | 219 | |
d07734e3 FF |
220 | /* Initial size of type vector. Is realloc'd larger if needed, |
221 | and realloc'd down to the size actually used, when completed. */ | |
1ab3bf1b | 222 | |
d07734e3 FF |
223 | #define INITIAL_TYPE_VECTOR_LENGTH 160 |
224 | ||
225 | extern void | |
226 | add_symbol_to_list PARAMS ((struct symbol *, struct pending **)); | |
227 | ||
228 | extern struct symbol * | |
229 | find_symbol_in_list PARAMS ((struct pending *, char *, int)); | |
1ab3bf1b JG |
230 | |
231 | extern void | |
232 | finish_block PARAMS ((struct symbol *, struct pending **, | |
233 | struct pending_block *, CORE_ADDR, CORE_ADDR, | |
234 | struct objfile *)); | |
235 | ||
1ab3bf1b JG |
236 | extern void |
237 | really_free_pendings PARAMS ((int foo)); | |
238 | ||
239 | extern void | |
240 | start_subfile PARAMS ((char *, char *)); | |
241 | ||
3416d90b FF |
242 | extern void |
243 | patch_subfile_names PARAMS ((struct subfile *subfile, char *name)); | |
244 | ||
1ab3bf1b JG |
245 | extern void |
246 | push_subfile PARAMS ((void)); | |
247 | ||
248 | extern char * | |
249 | pop_subfile PARAMS ((void)); | |
250 | ||
251 | extern struct symtab * | |
436d4143 | 252 | end_symtab PARAMS ((CORE_ADDR, struct objfile *, int)); |
1ab3bf1b JG |
253 | |
254 | extern void | |
255 | scan_file_globals PARAMS ((struct objfile *)); | |
256 | ||
257 | extern void | |
258 | buildsym_new_init PARAMS ((void)); | |
259 | ||
260 | extern void | |
261 | buildsym_init PARAMS ((void)); | |
262 | ||
263 | extern struct context_stack * | |
264 | push_context PARAMS ((int, CORE_ADDR)); | |
265 | ||
266 | extern void | |
267 | record_line PARAMS ((struct subfile *, int, CORE_ADDR)); | |
268 | ||
269 | extern void | |
270 | start_symtab PARAMS ((char *, char *, CORE_ADDR)); | |
271 | ||
1ab3bf1b JG |
272 | extern int |
273 | hashname PARAMS ((char *)); | |
274 | ||
a7f56d5a FF |
275 | extern void |
276 | free_pending_blocks PARAMS ((void)); | |
277 | ||
278 | /* FIXME: Note that this is used only in buildsym.c and dstread.c, | |
279 | which should be fixed to not need direct access to make_blockvector. */ | |
280 | ||
281 | extern struct blockvector * | |
282 | make_blockvector PARAMS ((struct objfile *)); | |
283 | ||
284 | /* FIXME: Note that this is used only in buildsym.c and dstread.c, | |
285 | which should be fixed to not need direct access to record_pending_block. */ | |
286 | ||
287 | extern void | |
288 | record_pending_block PARAMS ((struct objfile *, struct block *, | |
289 | struct pending_block *)); | |
290 | ||
609fd033 FF |
291 | extern void |
292 | record_debugformat PARAMS ((char *)); | |
293 | ||
4770ff08 DT |
294 | extern void |
295 | merge_symbol_lists PARAMS ((struct pending **, struct pending **)); | |
296 | ||
d07734e3 FF |
297 | #undef EXTERN |
298 | ||
1ab3bf1b | 299 | #endif /* defined (BUILDSYM_H) */ |