Fri Sep 18 14:07:44 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
[deliverable/binutils-gdb.git] / gdb / buildsym.h
CommitLineData
c0302457 1/* Build symbol tables in GDB's internal format.
436d4143 2 Copyright (C) 1986-1996 Free Software Foundation, Inc.
c0302457
JG
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
6c9638b4 18Foundation, 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
44EXTERN 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
49EXTERN 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
55struct 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
66EXTERN struct subfile *subfiles;
67
68EXTERN struct subfile *current_subfile;
69
70/* Global variable which, when set, indicates that we are processing a
71 .o file compiled with gcc */
72
73EXTERN 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
81EXTERN unsigned char processing_acc_compilation;
82
c0302457
JG
83/* Count symbols as they are processed, for error messages. */
84
85EXTERN unsigned int symnum;
86
c0302457
JG
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. */
90
91#define PENDINGSIZE 100
92
93struct pending
94{
95 struct pending *next;
96 int nsyms;
97 struct symbol *symbol[PENDINGSIZE];
98};
99
c0302457
JG
100/* Here are the three lists that symbols are put on. */
101
102EXTERN struct pending *file_symbols; /* static at top level, and types */
103
104EXTERN struct pending *global_symbols; /* global functions and variables */
105
4137c5fc
JG
106EXTERN struct pending *local_symbols; /* everything local to lexic context */
107
c0302457
JG
108/* Stack representing unclosed lexical contexts
109 (that will become blocks, eventually). */
110
111struct context_stack
112{
d07734e3
FF
113 /* Outer locals at the time we entered */
114
115 struct pending *locals;
116
117 /* Pointer into blocklist as of entry */
118
119 struct pending_block *old_blocks;
120
121 /* Name of function, if any, defining context*/
122
123 struct symbol *name;
124
125 /* PC where this context starts */
126
127 CORE_ADDR start_addr;
128
129 /* Temp slot for exception handling. */
130
131 CORE_ADDR end_addr;
132
133 /* For error-checking matching push/pop */
134
135 int depth;
136
c0302457
JG
137};
138
139EXTERN struct context_stack *context_stack;
140
141/* Index of first unused entry in context stack. */
d07734e3 142
c0302457
JG
143EXTERN int context_stack_depth;
144
145/* Currently allocated size of context stack. */
146
147EXTERN int context_stack_size;
148
a048c8f5
JG
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
151 context_stack. */
152
d07734e3 153#define pop_context() (&context_stack[--context_stack_depth]);
a048c8f5 154
c0302457
JG
155/* Nonzero if within a function (so symbols should be local,
156 if nothing says specifically). */
157
158EXTERN int within_function;
159
160/* List of blocks already made (lexical contexts already closed).
161 This is used at the end to make the blockvector. */
162
163struct pending_block
164{
165 struct pending_block *next;
166 struct block *block;
167};
168
f85d9973
RU
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. */
173
174EXTERN struct pending_block *pending_blocks;
175
c0302457 176\f
a048c8f5
JG
177struct subfile_stack
178{
179 struct subfile_stack *next;
180 char *name;
a048c8f5
JG
181};
182
183EXTERN struct subfile_stack *subfile_stack;
aab77d5f 184
2dd30c72 185#define next_symbol_text(objfile) (*next_symbol_text_func)(objfile)
aab77d5f
PB
186
187/* Function to invoke get the next symbol. Return the symbol name. */
188
2dd30c72 189EXTERN char *(*next_symbol_text_func) PARAMS ((struct objfile *));
1ab3bf1b 190
d07734e3
FF
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.) */
1ab3bf1b 197
d07734e3 198EXTERN struct type **type_vector;
1ab3bf1b 199
d07734e3 200/* Number of elements allocated for type_vector currently. */
1ab3bf1b 201
d07734e3 202EXTERN int type_vector_length;
1ab3bf1b 203
d07734e3
FF
204/* Initial size of type vector. Is realloc'd larger if needed,
205 and realloc'd down to the size actually used, when completed. */
1ab3bf1b 206
d07734e3
FF
207#define INITIAL_TYPE_VECTOR_LENGTH 160
208
209extern void
210add_symbol_to_list PARAMS ((struct symbol *, struct pending **));
211
212extern struct symbol *
213find_symbol_in_list PARAMS ((struct pending *, char *, int));
1ab3bf1b
JG
214
215extern void
216finish_block PARAMS ((struct symbol *, struct pending **,
217 struct pending_block *, CORE_ADDR, CORE_ADDR,
218 struct objfile *));
219
1ab3bf1b
JG
220extern void
221really_free_pendings PARAMS ((int foo));
222
223extern void
224start_subfile PARAMS ((char *, char *));
225
3416d90b
FF
226extern void
227patch_subfile_names PARAMS ((struct subfile *subfile, char *name));
228
1ab3bf1b
JG
229extern void
230push_subfile PARAMS ((void));
231
232extern char *
233pop_subfile PARAMS ((void));
234
235extern struct symtab *
436d4143 236end_symtab PARAMS ((CORE_ADDR, struct objfile *, int));
1ab3bf1b
JG
237
238extern void
239scan_file_globals PARAMS ((struct objfile *));
240
241extern void
242buildsym_new_init PARAMS ((void));
243
244extern void
245buildsym_init PARAMS ((void));
246
247extern struct context_stack *
248push_context PARAMS ((int, CORE_ADDR));
249
250extern void
251record_line PARAMS ((struct subfile *, int, CORE_ADDR));
252
253extern void
254start_symtab PARAMS ((char *, char *, CORE_ADDR));
255
1ab3bf1b
JG
256extern int
257hashname PARAMS ((char *));
258
a7f56d5a
FF
259extern void
260free_pending_blocks PARAMS ((void));
261
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. */
264
265extern struct blockvector *
266make_blockvector PARAMS ((struct objfile *));
267
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. */
270
271extern void
272record_pending_block PARAMS ((struct objfile *, struct block *,
273 struct pending_block *));
274
609fd033
FF
275extern void
276record_debugformat PARAMS ((char *));
277
d07734e3
FF
278#undef EXTERN
279
1ab3bf1b 280#endif /* defined (BUILDSYM_H) */
This page took 0.310285 seconds and 4 git commands to generate.