1 /* Definitions for reading symbol files into GDB.
2 Copyright (C) 1990, 1991, 1992 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 (SYMFILE_H)
23 /* This file requires that you first include "bfd.h". */
25 struct psymbol_allocation_list {
26 struct partial_symbol *list;
27 struct partial_symbol *next;
31 /* Structure to keep track of symbol reading functions for various
36 /* is the name, or name prefix, of the BFD "target type" that this
37 set of functions handles. E.g. "a.out" or "sunOs" or "coff" or "elf". */
41 /* counts how many bytes of sym_name should be checked against the
42 BFD target type of the file being read. If an exact match is
43 desired, specify the number of characters in sym_name plus 1 for the
44 NUL. If a prefix match is desired, specify the number of characters in
49 /* Initializes anything that is global to the entire symbol table. It is
50 called during symbol_file_add, when we begin debugging an entirely new
53 void (*sym_new_init) PARAMS ((struct objfile *));
55 /* Reads any initial information from a symbol file, and initializes the
56 struct sym_fns SF in preparation for sym_read(). It is called every
57 time we read a symbol file for any reason. */
59 void (*sym_init) PARAMS ((struct objfile *));
61 /* sym_read (objfile, addr, mainline)
62 Reads a symbol file into a psymtab (or possibly a symtab).
63 OBJFILE is the objfile struct for the file we are reading. ADDR
64 is the offset between the file's specified start address and
65 its true address in memory. MAINLINE is 1 if this is the
66 main symbol table being read, and 0 if a secondary
67 symbol file (e.g. shared library or dynamically loaded file)
70 void (*sym_read) PARAMS ((struct objfile *, CORE_ADDR, int));
72 /* Called when we are finished with an objfile. Should do all cleanup
73 that is specific to the object file format for the particular objfile. */
75 void (*sym_finish) PARAMS ((struct objfile *));
77 /* Finds the next struct sym_fns. They are allocated and initialized
78 in whatever module implements the functions pointed to; an
79 initializer calls add_symtab_fns to add them to the global chain. */
85 /* Master structure for keeping track of each input file from which
86 gdb reads symbols. One of these is allocated for each such file we
87 access, e.g. the exec_file, symbol_file, and any shared library object
93 /* All struct objfile's are chained together by their next pointers.
94 The global variable "object_files" points to the first link in this
99 /* The object file's name. Malloc'd; free it if you free this struct. */
103 /* Some flag bits for this objfile. */
105 unsigned short flags;
107 /* Each objfile points to a linked list of symtabs derived from this file,
108 one symtab structure for each compilation unit (source file). Each link
109 in the symtab list contains a backpointer to this objfile. */
111 struct symtab *symtabs;
113 /* Each objfile points to a linked list of partial symtabs derived from
114 this file, one partial symtab structure for each compilation unit
117 struct partial_symtab *psymtabs;
119 /* List of freed partial symtabs, available for re-use */
121 struct partial_symtab *free_psymtabs;
123 /* The object file's BFD. Can be null, in which case bfd_open (name) and
124 put the result here. */
128 /* The modification timestamp of the object file, as of the last time
129 we read its symbols. */
133 /* Obstacks to hold objects that should be freed when we load a new symbol
134 table from this object file. */
136 struct obstack psymbol_obstack; /* Partial symbols */
137 struct obstack symbol_obstack; /* Full symbols */
138 struct obstack type_obstack; /* Types */
140 /* Vectors of all partial symbols read in from file. The actual data
141 is stored in the psymbol_obstack. */
143 struct psymbol_allocation_list global_psymbols;
144 struct psymbol_allocation_list static_psymbols;
146 /* Each file contains a pointer to an array of minimal symbols for all
147 global symbols that are defined within the file. The array is terminated
148 by a "null symbol", one that has a NULL pointer for the name and a zero
149 value for the address. This makes it easy to walk through the array
150 when passed a pointer to somewhere in the middle of it. There is also
151 a count of the number of symbols, which does include the terminating
152 null symbol. The array itself, as well as all the data that it points
153 to, should be allocated on the symbol_obstack for this file. */
155 struct minimal_symbol *msymbols;
156 int minimal_symbol_count;
158 /* For object file formats which don't specify fundamental types, gdb
159 can create such types. For now, it maintains a vector of pointers
160 to these internally created fundamental types on a per objfile basis,
161 however it really should ultimately keep them on a per-compilation-unit
162 basis, to account for linkage-units that consist of a number of
163 compilation units that may have different fundamental types, such as
164 linking C modules with ADA modules, or linking C modules that are
165 compiled with 32-bit ints with C modules that are compiled with 64-bit
166 ints (not inherently evil with a smarter linker). */
168 struct type **fundamental_types;
170 /* The mmalloc() malloc-descriptor for this objfile if we are using
171 the memory mapped malloc() package to manage storage for this objfile's
172 data. NULL if we are not. */
176 /* Structure which keeps track of functions that manipulate objfile's
177 of the same type as this objfile. I.E. the function to read partial
178 symbols for example. Note that this structure is in statically
179 allocated memory, and is shared by all objfiles that use the
180 object module reader of this type. */
184 /* Hook for information which is shared by sym_init and sym_read for
185 this objfile. It is typically a pointer to malloc'd memory. */
191 /* Defines for the objfile flag word. */
193 /* Gdb can arrange to allocate storage for all objects related to a
194 particular objfile in a designated section of it's address space,
195 managed at a low level by mmap() and using a special version of
196 malloc that handles malloc/free/realloc on top of the mmap() interface.
197 This allows the "internal gdb state" for a particular objfile to be
198 dumped to a gdb state file and subsequently reloaded at a later time. */
200 #define OBJF_MAPPED (1 << 0) /* Objfile data is mmap'd */
204 extend_psymbol_list PARAMS ((struct psymbol_allocation_list *,
207 /* Add any kind of symbol to a psymbol_allocation_list. */
209 #define ADD_PSYMBOL_VT_TO_LIST(NAME,NAMELENGTH,NAMESPACE,CLASS,LIST,VALUE,VT) \
211 register struct partial_symbol *psym; \
212 if ((LIST).next >= (LIST).list + (LIST).size) \
213 extend_psymbol_list (&(LIST),objfile); \
214 psym = (LIST).next++; \
216 SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, \
218 memcpy (SYMBOL_NAME (psym), (NAME), (NAMELENGTH)); \
219 SYMBOL_NAME (psym)[(NAMELENGTH)] = '\0'; \
220 SYMBOL_NAMESPACE (psym) = (NAMESPACE); \
221 SYMBOL_CLASS (psym) = (CLASS); \
222 VT (psym) = (VALUE); \
227 /* Since one arg is a struct, we have to pass in a ptr and deref it (sigh) */
229 #define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \
230 add_psymbol_to_list (name, namelength, namespace, class, &list, value)
232 #define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value) \
233 add_psymbol_addr_to_list (name, namelength, namespace, class, &list, value)
237 /* Add a symbol with an integer value to a psymtab. */
239 #define ADD_PSYMBOL_TO_LIST(name, namelength, namespace, class, list, value) \
240 ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE)
242 /* Add a symbol with a CORE_ADDR value to a psymtab. */
244 #define ADD_PSYMBOL_ADDR_TO_LIST(name, namelength, namespace, class, list, value)\
245 ADD_PSYMBOL_VT_TO_LIST (name, namelength, namespace, class, list, value, SYMBOL_VALUE_ADDRESS)
252 sort_pst_symbols PARAMS ((struct partial_symtab *));
254 extern struct symtab *
255 allocate_symtab PARAMS ((char *, struct objfile *));
257 extern struct objfile *
258 allocate_objfile PARAMS ((bfd *, int));
261 free_objfile PARAMS ((struct objfile *));
264 free_all_objfiles PARAMS ((void));
267 free_named_symtabs PARAMS ((char *));
270 fill_in_vptr_fieldno PARAMS ((struct type *));
273 add_symtab_fns PARAMS ((struct sym_fns *));
276 syms_from_objfile PARAMS ((struct objfile *, CORE_ADDR, int, int));
278 extern struct partial_symtab *
279 start_psymtab_common PARAMS ((struct objfile *, CORE_ADDR, char *, CORE_ADDR,
280 struct partial_symbol *,
281 struct partial_symbol *));
283 /* Sorting your symbols for fast lookup or alphabetical printing. */
286 sort_block_syms PARAMS ((struct block *));
289 sort_symtab_syms PARAMS ((struct symtab *));
292 sort_all_symtab_syms PARAMS ((void));
294 /* Make a copy of the string at PTR with SIZE characters in the symbol obstack
295 (and add a null character at the end in the copy).
296 Returns the address of the copy. */
299 obsavestring PARAMS ((char *, int, struct obstack *));
301 /* Concatenate strings S1, S2 and S3; return the new string.
302 Space is found in the symbol_obstack. */
305 obconcat PARAMS ((struct obstack *obstackp, const char *, const char *,
310 /* The object file that the main symbol table was loaded from (e.g. the
311 argument to the "symbol-file" or "file" command). */
313 extern struct objfile *symfile_objfile;
315 /* Where execution starts in symfile */
317 extern CORE_ADDR entry_point;
319 /* Root of object file struct chain. */
321 extern struct objfile *object_files;
323 /* Traverse all object files. ALL_OBJFILES_SAFE works even if you delete
324 the objfile during the traversal. */
326 #define ALL_OBJFILES(obj) \
327 for (obj = object_files; 0 != obj; obj = obj->next)
329 #define ALL_OBJFILES_SAFE(obj,nxt) \
330 for (obj = object_files; obj? (nxt=obj->next, 1): 0; obj = nxt)
332 /* Support for complaining about things in the symbol file that aren't
335 Each such thing gets a counter. The first time we have the problem,
336 during a symbol read, we report it. At the end of symbol reading,
337 if verbose, we report how many of each problem we had. */
342 struct complaint *next;
345 /* Root of the chain of complaints that have at some point been issued.
346 This is used to reset the counters, and/or report the total counts. */
348 extern struct complaint complaint_root[1];
350 /* Functions that handle complaints. (in symfile.c) */
353 complain PARAMS ((struct complaint *, char *));
356 clear_complaints PARAMS ((int sym_reading, int noisy));
360 extern struct partial_symtab *
361 allocate_psymtab PARAMS ((char *, struct objfile *));
366 iterate_over_msymbols PARAMS ((PTR (*func) (struct objfile *,
367 struct minimal_symbol *,
368 PTR arg1, PTR arg2, PTR arg3),
369 PTR arg1, PTR arg2, PTR arg3));
371 /* From objfiles.c */
374 iterate_over_objfiles PARAMS ((PTR (*func) (struct objfile *,
375 PTR arg1, PTR arg2, PTR arg3),
376 PTR arg1, PTR arg2, PTR arg3));
379 iterate_over_symtabs PARAMS ((PTR (*func) (struct objfile *, struct symtab *,
380 PTR arg1, PTR arg2, PTR arg3),
381 PTR arg1, PTR arg2, PTR arg3));
384 iterate_over_psymtabs PARAMS ((PTR (*func) (struct objfile *,
385 struct partial_symtab *,
386 PTR arg1, PTR arg2, PTR arg3),
387 PTR arg1, PTR arg2, PTR arg3));
389 /* From dwarfread.c */
392 dwarf_build_psymtabs PARAMS ((int, char *, CORE_ADDR, int, unsigned int,
393 unsigned int, unsigned int, unsigned int,
396 #endif /* !defined(SYMFILE_H) */