symfile.h revision 19370
1239313Sdim/* Definitions for reading symbol files into GDB.
2239313Sdim   Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996
3239313Sdim   Free Software Foundation, Inc.
4239313Sdim
5239313SdimThis file is part of GDB.
6239313Sdim
7239313SdimThis program is free software; you can redistribute it and/or modify
8239313Sdimit under the terms of the GNU General Public License as published by
9239313Sdimthe Free Software Foundation; either version 2 of the License, or
10239313Sdim(at your option) any later version.
11239313Sdim
12239313SdimThis program is distributed in the hope that it will be useful,
13239313Sdimbut WITHOUT ANY WARRANTY; without even the implied warranty of
14239313SdimMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15239313SdimGNU General Public License for more details.
16239313Sdim
17239313SdimYou should have received a copy of the GNU General Public License
18239313Sdimalong with this program; if not, write to the Free Software
19239313SdimFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20239313Sdim
21239313Sdim#if !defined (SYMFILE_H)
22239313Sdim#define SYMFILE_H
23239313Sdim
24239313Sdim/* This file requires that you first include "bfd.h".  */
25239313Sdim
26239313Sdim/* Partial symbols are stored in the psymbol_cache and pointers to them
27239313Sdim   are kept in a dynamically grown array that is obtained from malloc and
28239313Sdim   grown as necessary via realloc.  Each objfile typically has two of these,
29239313Sdim   one for global symbols and one for static symbols.  Although this adds
30239313Sdim   a level of indirection for storing or accessing the partial symbols,
31239313Sdim   it allows us to throw away duplicate psymbols and set all pointers
32239313Sdim   to the single saved instance. */
33239313Sdim
34239313Sdimstruct psymbol_allocation_list {
35239313Sdim  struct partial_symbol **list;	/* Pointer to first partial symbol pointer*/
36239313Sdim  struct partial_symbol **next;	/* Pointer to next avail storage for pointer */
37239313Sdim  int size;			/* Number of symbols */
38239313Sdim};
39239313Sdim
40239313Sdim/* Structure to keep track of symbol reading functions for various
41239313Sdim   object file types.  */
42239313Sdim
43239313Sdimstruct sym_fns {
44239313Sdim
45239313Sdim  /* BFD flavour that we handle, or (as a special kludge, see xcoffread.c,
46239313Sdim     (enum bfd_flavour)-1 for xcoff).  */
47239313Sdim
48239313Sdim  enum bfd_flavour sym_flavour;
49239313Sdim
50239313Sdim  /* Initializes anything that is global to the entire symbol table.  It is
51239313Sdim     called during symbol_file_add, when we begin debugging an entirely new
52239313Sdim     program. */
53239313Sdim
54239313Sdim  void (*sym_new_init) PARAMS ((struct objfile *));
55239313Sdim
56239313Sdim  /* Reads any initial information from a symbol file, and initializes the
57239313Sdim     struct sym_fns SF in preparation for sym_read().  It is called every
58239313Sdim     time we read a symbol file for any reason. */
59239313Sdim
60239313Sdim  void (*sym_init) PARAMS ((struct objfile *));
61239313Sdim
62239313Sdim  /* sym_read (objfile, addr, mainline)
63239313Sdim     Reads a symbol file into a psymtab (or possibly a symtab).
64239313Sdim     OBJFILE is the objfile struct for the file we are reading.
65239313Sdim     SECTION_OFFSETS
66239313Sdim     are the offset between the file's specified section addresses and
67239313Sdim     their true addresses in memory.
68239313Sdim     MAINLINE is 1 if this is the
69239313Sdim     main symbol table being read, and 0 if a secondary
70239313Sdim     symbol file (e.g. shared library or dynamically loaded file)
71239313Sdim     is being read.  */
72239313Sdim
73239313Sdim  void (*sym_read) PARAMS ((struct objfile *, struct section_offsets *, int));
74263508Sdim
75239313Sdim  /* Called when we are finished with an objfile.  Should do all cleanup
76239313Sdim     that is specific to the object file format for the particular objfile. */
77239313Sdim
78239313Sdim  void (*sym_finish) PARAMS ((struct objfile *));
79263508Sdim
80239313Sdim  /* This function produces a file-dependent section_offsets structure,
81239313Sdim     allocated in the objfile's storage, and based on the parameter.
82263508Sdim     The parameter is currently a CORE_ADDR (FIXME!) for backward compatibility
83239313Sdim     with the higher levels of GDB.  It should probably be changed to
84239313Sdim     a string, where NULL means the default, and others are parsed in a file
85239313Sdim     dependent way.  The result of this function is handed in to sym_read.  */
86263508Sdim
87263508Sdim  struct section_offsets *(*sym_offsets) PARAMS ((struct objfile *, CORE_ADDR));
88263508Sdim
89239313Sdim  /* Finds the next struct sym_fns.  They are allocated and initialized
90239313Sdim     in whatever module implements the functions pointed to; an
91     initializer calls add_symtab_fns to add them to the global chain.  */
92
93  struct sym_fns *next;
94
95};
96
97extern void
98extend_psymbol_list PARAMS ((struct psymbol_allocation_list *,
99			     struct objfile *));
100
101/* Add any kind of symbol to a psymbol_allocation_list. */
102
103/* #include "demangle.h" */
104
105extern void
106add_psymbol_to_list PARAMS ((char *, int, namespace_enum, enum address_class,
107			     struct psymbol_allocation_list *, long, CORE_ADDR,
108			     enum language, struct objfile *));
109
110extern void init_psymbol_list PARAMS ((struct objfile *, int));
111
112extern void
113sort_pst_symbols PARAMS ((struct partial_symtab *));
114
115extern struct symtab *
116allocate_symtab PARAMS ((char *, struct objfile *));
117
118extern int
119free_named_symtabs PARAMS ((char *));
120
121extern void
122fill_in_vptr_fieldno PARAMS ((struct type *));
123
124extern void
125add_symtab_fns PARAMS ((struct sym_fns *));
126
127extern void
128init_entry_point_info PARAMS ((struct objfile *));
129
130extern void
131syms_from_objfile PARAMS ((struct objfile *, CORE_ADDR, int, int));
132
133extern void
134new_symfile_objfile PARAMS ((struct objfile *, int, int));
135
136extern struct partial_symtab *
137start_psymtab_common PARAMS ((struct objfile *, struct section_offsets *,
138			      char *, CORE_ADDR,
139			      struct partial_symbol **,
140			      struct partial_symbol **));
141
142/* Sorting your symbols for fast lookup or alphabetical printing.  */
143
144extern void
145sort_block_syms PARAMS ((struct block *));
146
147extern void
148sort_symtab_syms PARAMS ((struct symtab *));
149
150/* Make a copy of the string at PTR with SIZE characters in the symbol obstack
151   (and add a null character at the end in the copy).
152   Returns the address of the copy.  */
153
154extern char *
155obsavestring PARAMS ((char *, int, struct obstack *));
156
157/* Concatenate strings S1, S2 and S3; return the new string.
158   Space is found in the symbol_obstack.  */
159
160extern char *
161obconcat PARAMS ((struct obstack *obstackp, const char *, const char *,
162		  const char *));
163
164			/*   Variables   */
165
166/* whether to auto load solibs at startup time:  0/1. */
167
168extern int auto_solib_add;
169
170/* From symfile.c */
171
172extern struct partial_symtab *
173allocate_psymtab PARAMS ((char *, struct objfile *));
174
175extern void find_lowest_section PARAMS ((bfd *, asection *, PTR));
176
177/* Remote targets may wish to use this as their load function.  */
178extern void generic_load PARAMS ((char *name, int from_tty));
179
180/* From dwarfread.c */
181
182extern void
183dwarf_build_psymtabs PARAMS ((struct objfile *, struct section_offsets *, int,
184			      file_ptr, unsigned int, file_ptr, unsigned int));
185
186/* From mdebugread.c */
187
188/* Hack to force structures to exist before use in parameter list.  */
189struct ecoff_debug_hack
190{
191  struct ecoff_debug_swap *a;
192  struct ecoff_debug_info *b;
193};
194extern void
195mdebug_build_psymtabs PARAMS ((struct objfile *,
196			       const struct ecoff_debug_swap *,
197			       struct ecoff_debug_info *,
198			       struct section_offsets *));
199
200extern void
201elfmdebug_build_psymtabs PARAMS ((struct objfile *,
202				  const struct ecoff_debug_swap *,
203				  asection *,
204				  struct section_offsets *));
205
206/* From demangle.c */
207
208extern void
209set_demangling_style PARAMS ((char *));
210
211#endif	/* !defined(SYMFILE_H) */
212