xref: /dflybsd-src/contrib/gdb-7/gdb/symfile.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Definitions for reading symbol files into GDB.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1990-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    This file is part of GDB.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
85796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
95796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
105796c8dcSSimon Schubert    (at your option) any later version.
115796c8dcSSimon Schubert 
125796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
135796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
145796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
155796c8dcSSimon Schubert    GNU General Public License for more details.
165796c8dcSSimon Schubert 
175796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
185796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
195796c8dcSSimon Schubert 
205796c8dcSSimon Schubert #if !defined (SYMFILE_H)
215796c8dcSSimon Schubert #define SYMFILE_H
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert /* This file requires that you first include "bfd.h".  */
245796c8dcSSimon Schubert #include "symtab.h"
25*ef5ccd6cSJohn Marino #include "probe.h"
265796c8dcSSimon Schubert 
275796c8dcSSimon Schubert /* Opaque declarations.  */
285796c8dcSSimon Schubert struct target_section;
295796c8dcSSimon Schubert struct objfile;
305796c8dcSSimon Schubert struct obj_section;
315796c8dcSSimon Schubert struct obstack;
325796c8dcSSimon Schubert struct block;
33*ef5ccd6cSJohn Marino struct probe;
34*ef5ccd6cSJohn Marino struct value;
35*ef5ccd6cSJohn Marino struct frame_info;
36*ef5ccd6cSJohn Marino struct agent_expr;
37*ef5ccd6cSJohn Marino struct axs_value;
385796c8dcSSimon Schubert 
39c50c785cSJohn Marino /* Comparison function for symbol look ups.  */
40c50c785cSJohn Marino 
41c50c785cSJohn Marino typedef int (symbol_compare_ftype) (const char *string1,
42c50c785cSJohn Marino 				    const char *string2);
43c50c785cSJohn Marino 
445796c8dcSSimon Schubert /* Partial symbols are stored in the psymbol_cache and pointers to
455796c8dcSSimon Schubert    them are kept in a dynamically grown array that is obtained from
465796c8dcSSimon Schubert    malloc and grown as necessary via realloc.  Each objfile typically
475796c8dcSSimon Schubert    has two of these, one for global symbols and one for static
485796c8dcSSimon Schubert    symbols.  Although this adds a level of indirection for storing or
495796c8dcSSimon Schubert    accessing the partial symbols, it allows us to throw away duplicate
505796c8dcSSimon Schubert    psymbols and set all pointers to the single saved instance.  */
515796c8dcSSimon Schubert 
525796c8dcSSimon Schubert struct psymbol_allocation_list
535796c8dcSSimon Schubert {
545796c8dcSSimon Schubert 
555796c8dcSSimon Schubert   /* Pointer to beginning of dynamically allocated array of pointers
565796c8dcSSimon Schubert      to partial symbols.  The array is dynamically expanded as
575796c8dcSSimon Schubert      necessary to accommodate more pointers.  */
585796c8dcSSimon Schubert 
595796c8dcSSimon Schubert   struct partial_symbol **list;
605796c8dcSSimon Schubert 
615796c8dcSSimon Schubert   /* Pointer to next available slot in which to store a pointer to a
625796c8dcSSimon Schubert      partial symbol.  */
635796c8dcSSimon Schubert 
645796c8dcSSimon Schubert   struct partial_symbol **next;
655796c8dcSSimon Schubert 
665796c8dcSSimon Schubert   /* Number of allocated pointer slots in current dynamic array (not
675796c8dcSSimon Schubert      the number of bytes of storage).  The "next" pointer will always
685796c8dcSSimon Schubert      point somewhere between list[0] and list[size], and when at
695796c8dcSSimon Schubert      list[size] the array will be expanded on the next attempt to
705796c8dcSSimon Schubert      store a pointer.  */
715796c8dcSSimon Schubert 
725796c8dcSSimon Schubert   int size;
735796c8dcSSimon Schubert };
745796c8dcSSimon Schubert 
755796c8dcSSimon Schubert /* Define an array of addresses to accommodate non-contiguous dynamic
765796c8dcSSimon Schubert    loading of modules.  This is for use when entering commands, so we
775796c8dcSSimon Schubert    can keep track of the section names until we read the file and can
785796c8dcSSimon Schubert    map them to bfd sections.  This structure is also used by solib.c
795796c8dcSSimon Schubert    to communicate the section addresses in shared objects to
805796c8dcSSimon Schubert    symbol_file_add ().  */
815796c8dcSSimon Schubert 
825796c8dcSSimon Schubert struct section_addr_info
835796c8dcSSimon Schubert {
845796c8dcSSimon Schubert   /* The number of sections for which address information is
855796c8dcSSimon Schubert      available.  */
865796c8dcSSimon Schubert   size_t num_sections;
875796c8dcSSimon Schubert   /* Sections whose names are file format dependent.  */
885796c8dcSSimon Schubert   struct other_sections
895796c8dcSSimon Schubert   {
905796c8dcSSimon Schubert     CORE_ADDR addr;
915796c8dcSSimon Schubert     char *name;
92cf7f2e2dSJohn Marino 
93a45ae5f8SJohn Marino     /* SECTINDEX must be valid for associated BFD or set to -1.  */
945796c8dcSSimon Schubert     int sectindex;
955796c8dcSSimon Schubert   } other[1];
965796c8dcSSimon Schubert };
975796c8dcSSimon Schubert 
985796c8dcSSimon Schubert 
995796c8dcSSimon Schubert /* A table listing the load segments in a symfile, and which segment
1005796c8dcSSimon Schubert    each BFD section belongs to.  */
1015796c8dcSSimon Schubert struct symfile_segment_data
1025796c8dcSSimon Schubert {
1035796c8dcSSimon Schubert   /* How many segments are present in this file.  If there are
1045796c8dcSSimon Schubert      two, the text segment is the first one and the data segment
1055796c8dcSSimon Schubert      is the second one.  */
1065796c8dcSSimon Schubert   int num_segments;
1075796c8dcSSimon Schubert 
1085796c8dcSSimon Schubert   /* If NUM_SEGMENTS is greater than zero, the original base address
1095796c8dcSSimon Schubert      of each segment.  */
1105796c8dcSSimon Schubert   CORE_ADDR *segment_bases;
1115796c8dcSSimon Schubert 
1125796c8dcSSimon Schubert   /* If NUM_SEGMENTS is greater than zero, the memory size of each
1135796c8dcSSimon Schubert      segment.  */
1145796c8dcSSimon Schubert   CORE_ADDR *segment_sizes;
1155796c8dcSSimon Schubert 
1165796c8dcSSimon Schubert   /* If NUM_SEGMENTS is greater than zero, this is an array of entries
1175796c8dcSSimon Schubert      recording which segment contains each BFD section.
1185796c8dcSSimon Schubert      SEGMENT_INFO[I] is S+1 if the I'th BFD section belongs to segment
1195796c8dcSSimon Schubert      S, or zero if it is not in any segment.  */
1205796c8dcSSimon Schubert   int *segment_info;
1215796c8dcSSimon Schubert };
1225796c8dcSSimon Schubert 
123a45ae5f8SJohn Marino /* Callback for quick_symbol_functions->map_symbol_filenames.  */
124a45ae5f8SJohn Marino 
125a45ae5f8SJohn Marino typedef void (symbol_filename_ftype) (const char *filename,
126a45ae5f8SJohn Marino 				      const char *fullname, void *data);
127a45ae5f8SJohn Marino 
128cf7f2e2dSJohn Marino /* The "quick" symbol functions exist so that symbol readers can
129cf7f2e2dSJohn Marino    avoiding an initial read of all the symbols.  For example, symbol
130cf7f2e2dSJohn Marino    readers might choose to use the "partial symbol table" utilities,
131cf7f2e2dSJohn Marino    which is one implementation of the quick symbol functions.
132cf7f2e2dSJohn Marino 
133cf7f2e2dSJohn Marino    The quick symbol functions are generally opaque: the underlying
134cf7f2e2dSJohn Marino    representation is hidden from the caller.
135cf7f2e2dSJohn Marino 
136cf7f2e2dSJohn Marino    In general, these functions should only look at whatever special
137cf7f2e2dSJohn Marino    index the symbol reader creates -- looking through the symbol
138cf7f2e2dSJohn Marino    tables themselves is handled by generic code.  If a function is
139cf7f2e2dSJohn Marino    defined as returning a "symbol table", this means that the function
140cf7f2e2dSJohn Marino    should only return a newly-created symbol table; it should not
141cf7f2e2dSJohn Marino    examine pre-existing ones.
142cf7f2e2dSJohn Marino 
143cf7f2e2dSJohn Marino    The exact list of functions here was determined in an ad hoc way
144cf7f2e2dSJohn Marino    based on gdb's history.  */
145cf7f2e2dSJohn Marino 
146cf7f2e2dSJohn Marino struct quick_symbol_functions
147cf7f2e2dSJohn Marino {
148cf7f2e2dSJohn Marino   /* Return true if this objfile has any "partial" symbols
149cf7f2e2dSJohn Marino      available.  */
150cf7f2e2dSJohn Marino   int (*has_symbols) (struct objfile *objfile);
151cf7f2e2dSJohn Marino 
152cf7f2e2dSJohn Marino   /* Return the symbol table for the "last" file appearing in
153cf7f2e2dSJohn Marino      OBJFILE.  */
154cf7f2e2dSJohn Marino   struct symtab *(*find_last_source_symtab) (struct objfile *objfile);
155cf7f2e2dSJohn Marino 
156cf7f2e2dSJohn Marino   /* Forget all cached full file names for OBJFILE.  */
157cf7f2e2dSJohn Marino   void (*forget_cached_source_info) (struct objfile *objfile);
158cf7f2e2dSJohn Marino 
159a45ae5f8SJohn Marino   /* Expand and iterate over each "partial" symbol table in OBJFILE
160a45ae5f8SJohn Marino      where the source file is named NAME.
161cf7f2e2dSJohn Marino 
162*ef5ccd6cSJohn Marino      If NAME is not absolute, a match after a '/' in the symbol table's
163*ef5ccd6cSJohn Marino      file name will also work, REAL_PATH is NULL then.  If NAME is
164*ef5ccd6cSJohn Marino      absolute then REAL_PATH is non-NULL absolute file name as resolved
165*ef5ccd6cSJohn Marino      via gdb_realpath from NAME.
166cf7f2e2dSJohn Marino 
167a45ae5f8SJohn Marino      If a match is found, the "partial" symbol table is expanded.
168a45ae5f8SJohn Marino      Then, this calls iterate_over_some_symtabs (or equivalent) over
169a45ae5f8SJohn Marino      all newly-created symbol tables, passing CALLBACK and DATA to it.
170a45ae5f8SJohn Marino      The result of this call is returned.  */
171a45ae5f8SJohn Marino   int (*map_symtabs_matching_filename) (struct objfile *objfile,
172cf7f2e2dSJohn Marino 					const char *name,
173cf7f2e2dSJohn Marino 					const char *real_path,
174a45ae5f8SJohn Marino 					int (*callback) (struct symtab *,
175a45ae5f8SJohn Marino 							 void *),
176a45ae5f8SJohn Marino 					void *data);
177cf7f2e2dSJohn Marino 
178cf7f2e2dSJohn Marino   /* Check to see if the symbol is defined in a "partial" symbol table
179cf7f2e2dSJohn Marino      of OBJFILE.  KIND should be either GLOBAL_BLOCK or STATIC_BLOCK,
180cf7f2e2dSJohn Marino      depending on whether we want to search global symbols or static
181cf7f2e2dSJohn Marino      symbols.  NAME is the name of the symbol to look for.  DOMAIN
182cf7f2e2dSJohn Marino      indicates what sort of symbol to search for.
183cf7f2e2dSJohn Marino 
184cf7f2e2dSJohn Marino      Returns the newly-expanded symbol table in which the symbol is
185*ef5ccd6cSJohn Marino      defined, or NULL if no such symbol table exists.  If OBJFILE
186*ef5ccd6cSJohn Marino      contains !TYPE_OPAQUE symbol prefer its symtab.  If it contains
187*ef5ccd6cSJohn Marino      only TYPE_OPAQUE symbol(s), return at least that symtab.  */
188cf7f2e2dSJohn Marino   struct symtab *(*lookup_symbol) (struct objfile *objfile,
189cf7f2e2dSJohn Marino 				   int kind, const char *name,
190cf7f2e2dSJohn Marino 				   domain_enum domain);
191cf7f2e2dSJohn Marino 
192cf7f2e2dSJohn Marino   /* Print statistics about any indices loaded for OBJFILE.  The
193cf7f2e2dSJohn Marino      statistics should be printed to gdb_stdout.  This is used for
194cf7f2e2dSJohn Marino      "maint print statistics".  */
195cf7f2e2dSJohn Marino   void (*print_stats) (struct objfile *objfile);
196cf7f2e2dSJohn Marino 
197cf7f2e2dSJohn Marino   /* Dump any indices loaded for OBJFILE.  The dump should go to
198cf7f2e2dSJohn Marino      gdb_stdout.  This is used for "maint print objfiles".  */
199cf7f2e2dSJohn Marino   void (*dump) (struct objfile *objfile);
200cf7f2e2dSJohn Marino 
201cf7f2e2dSJohn Marino   /* This is called by objfile_relocate to relocate any indices loaded
202cf7f2e2dSJohn Marino      for OBJFILE.  */
203cf7f2e2dSJohn Marino   void (*relocate) (struct objfile *objfile,
204cf7f2e2dSJohn Marino 		    struct section_offsets *new_offsets,
205cf7f2e2dSJohn Marino 		    struct section_offsets *delta);
206cf7f2e2dSJohn Marino 
207cf7f2e2dSJohn Marino   /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
208cf7f2e2dSJohn Marino      the corresponding symbol tables are loaded.  */
209cf7f2e2dSJohn Marino   void (*expand_symtabs_for_function) (struct objfile *objfile,
210cf7f2e2dSJohn Marino 				       const char *func_name);
211cf7f2e2dSJohn Marino 
212cf7f2e2dSJohn Marino   /* Read all symbol tables associated with OBJFILE.  */
213cf7f2e2dSJohn Marino   void (*expand_all_symtabs) (struct objfile *objfile);
214cf7f2e2dSJohn Marino 
215*ef5ccd6cSJohn Marino   /* Read all symbol tables associated with OBJFILE which have
216*ef5ccd6cSJohn Marino      symtab_to_fullname equal to FULLNAME.
217c50c785cSJohn Marino      This is for the purposes of examining code only, e.g., expand_line_sal.
218c50c785cSJohn Marino      The routine may ignore debug info that is known to not be useful with
219c50c785cSJohn Marino      code, e.g., DW_TAG_type_unit for dwarf debug info.  */
220*ef5ccd6cSJohn Marino   void (*expand_symtabs_with_fullname) (struct objfile *objfile,
221*ef5ccd6cSJohn Marino 					const char *fullname);
222cf7f2e2dSJohn Marino 
223a45ae5f8SJohn Marino   /* Return the file name of the file holding the global symbol in OBJFILE
224*ef5ccd6cSJohn Marino      named NAME.  If no such symbol exists in OBJFILE, return NULL.
225*ef5ccd6cSJohn Marino      Only file extension of returned filename is recognized.  */
226c50c785cSJohn Marino   const char *(*find_symbol_file) (struct objfile *objfile, const char *name);
227cf7f2e2dSJohn Marino 
228c50c785cSJohn Marino   /* Find global or static symbols in all tables that are in NAMESPACE
229c50c785cSJohn Marino      and for which MATCH (symbol name, NAME) == 0, passing each to
230a45ae5f8SJohn Marino      CALLBACK, reading in partial symbol tables as needed.  Look
231c50c785cSJohn Marino      through global symbols if GLOBAL and otherwise static symbols.
232c50c785cSJohn Marino      Passes NAME, NAMESPACE, and DATA to CALLBACK with each symbol
233c50c785cSJohn Marino      found.  After each block is processed, passes NULL to CALLBACK.
234a45ae5f8SJohn Marino      MATCH must be weaker than strcmp_iw_ordered in the sense that
235a45ae5f8SJohn Marino      strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0.  ORDERED_COMPARE,
236a45ae5f8SJohn Marino      if non-null, must be an ordering relation compatible with
237a45ae5f8SJohn Marino      strcmp_iw_ordered in the sense that
238a45ae5f8SJohn Marino             strcmp_iw_ordered(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0
239c50c785cSJohn Marino      and
240a45ae5f8SJohn Marino             strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0
241a45ae5f8SJohn Marino      (allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0).
242c50c785cSJohn Marino      CALLBACK returns 0 to indicate that the scan should continue, or
243c50c785cSJohn Marino      non-zero to indicate that the scan should be terminated.  */
244cf7f2e2dSJohn Marino 
245c50c785cSJohn Marino   void (*map_matching_symbols) (const char *name, domain_enum namespace,
246c50c785cSJohn Marino 				struct objfile *, int global,
247c50c785cSJohn Marino 				int (*callback) (struct block *,
248c50c785cSJohn Marino 						 struct symbol *, void *),
249c50c785cSJohn Marino 				void *data,
250c50c785cSJohn Marino 				symbol_compare_ftype *match,
251c50c785cSJohn Marino 				symbol_compare_ftype *ordered_compare);
252cf7f2e2dSJohn Marino 
253cf7f2e2dSJohn Marino   /* Expand all symbol tables in OBJFILE matching some criteria.
254cf7f2e2dSJohn Marino 
255cf7f2e2dSJohn Marino      FILE_MATCHER is called for each file in OBJFILE.  The file name
256cf7f2e2dSJohn Marino      and the DATA argument are passed to it.  If it returns zero, this
257c50c785cSJohn Marino      file is skipped.  If FILE_MATCHER is NULL such file is not skipped.
258*ef5ccd6cSJohn Marino      If BASENAMES is non-zero the function should consider only base name of
259*ef5ccd6cSJohn Marino      DATA (passed file name is already only the lbasename part).
260cf7f2e2dSJohn Marino 
261c50c785cSJohn Marino      Otherwise, if KIND does not match this symbol is skipped.
262c50c785cSJohn Marino 
263a45ae5f8SJohn Marino      If even KIND matches, then NAME_MATCHER is called for each symbol
264*ef5ccd6cSJohn Marino      defined in the file.  The symbol "search" name and DATA are passed
265*ef5ccd6cSJohn Marino      to NAME_MATCHER.
266cf7f2e2dSJohn Marino 
267cf7f2e2dSJohn Marino      If NAME_MATCHER returns zero, then this symbol is skipped.
268cf7f2e2dSJohn Marino 
269c50c785cSJohn Marino      Otherwise, this symbol's symbol table is expanded.
270cf7f2e2dSJohn Marino 
271cf7f2e2dSJohn Marino      DATA is user data that is passed unmodified to the callback
272cf7f2e2dSJohn Marino      functions.  */
273a45ae5f8SJohn Marino   void (*expand_symtabs_matching)
274a45ae5f8SJohn Marino     (struct objfile *objfile,
275*ef5ccd6cSJohn Marino      int (*file_matcher) (const char *, void *, int basenames),
276*ef5ccd6cSJohn Marino      int (*name_matcher) (const char *, void *),
277a45ae5f8SJohn Marino      enum search_domain kind,
278cf7f2e2dSJohn Marino      void *data);
279cf7f2e2dSJohn Marino 
280cf7f2e2dSJohn Marino   /* Return the symbol table from OBJFILE that contains PC and
281cf7f2e2dSJohn Marino      SECTION.  Return NULL if there is no such symbol table.  This
282cf7f2e2dSJohn Marino      should return the symbol table that contains a symbol whose
283cf7f2e2dSJohn Marino      address exactly matches PC, or, if there is no exact match, the
284cf7f2e2dSJohn Marino      symbol table that contains a symbol whose address is closest to
285cf7f2e2dSJohn Marino      PC.  */
286cf7f2e2dSJohn Marino   struct symtab *(*find_pc_sect_symtab) (struct objfile *objfile,
287cf7f2e2dSJohn Marino 					 struct minimal_symbol *msymbol,
288cf7f2e2dSJohn Marino 					 CORE_ADDR pc,
289cf7f2e2dSJohn Marino 					 struct obj_section *section,
290cf7f2e2dSJohn Marino 					 int warn_if_readin);
291cf7f2e2dSJohn Marino 
292c50c785cSJohn Marino   /* Call a callback for every file defined in OBJFILE whose symtab is
293a45ae5f8SJohn Marino      not already read in.  FUN is the callback.  It is passed the file's
294a45ae5f8SJohn Marino      FILENAME, the file's FULLNAME (if need_fullname is non-zero), and
295a45ae5f8SJohn Marino      the DATA passed to this function.  */
296cf7f2e2dSJohn Marino   void (*map_symbol_filenames) (struct objfile *objfile,
297a45ae5f8SJohn Marino 				symbol_filename_ftype *fun, void *data,
298a45ae5f8SJohn Marino 				int need_fullname);
299cf7f2e2dSJohn Marino };
300cf7f2e2dSJohn Marino 
301*ef5ccd6cSJohn Marino /* Structure of functions used for probe support.  If one of these functions
302*ef5ccd6cSJohn Marino    is provided, all must be.  */
303*ef5ccd6cSJohn Marino 
304*ef5ccd6cSJohn Marino struct sym_probe_fns
305*ef5ccd6cSJohn Marino {
306*ef5ccd6cSJohn Marino   /* If non-NULL, return an array of probe objects.
307*ef5ccd6cSJohn Marino 
308*ef5ccd6cSJohn Marino      The returned value does not have to be freed and it has lifetime of the
309*ef5ccd6cSJohn Marino      OBJFILE.  */
310*ef5ccd6cSJohn Marino   VEC (probe_p) *(*sym_get_probes) (struct objfile *);
311*ef5ccd6cSJohn Marino 
312*ef5ccd6cSJohn Marino   /* Return the number of arguments available to PROBE.  PROBE will
313*ef5ccd6cSJohn Marino      have come from a call to this objfile's sym_get_probes method.
314*ef5ccd6cSJohn Marino      If you provide an implementation of sym_get_probes, you must
315*ef5ccd6cSJohn Marino      implement this method as well.  */
316*ef5ccd6cSJohn Marino   unsigned (*sym_get_probe_argument_count) (struct probe *probe);
317*ef5ccd6cSJohn Marino 
318*ef5ccd6cSJohn Marino   /* Evaluate the Nth argument available to PROBE.  PROBE will have
319*ef5ccd6cSJohn Marino      come from a call to this objfile's sym_get_probes method.  N will
320*ef5ccd6cSJohn Marino      be between 0 and the number of arguments available to this probe.
321*ef5ccd6cSJohn Marino      FRAME is the frame in which the evaluation is done; the frame's
322*ef5ccd6cSJohn Marino      PC will match the address of the probe.  If you provide an
323*ef5ccd6cSJohn Marino      implementation of sym_get_probes, you must implement this method
324*ef5ccd6cSJohn Marino      as well.  */
325*ef5ccd6cSJohn Marino   struct value *(*sym_evaluate_probe_argument) (struct probe *probe,
326*ef5ccd6cSJohn Marino 						unsigned n);
327*ef5ccd6cSJohn Marino 
328*ef5ccd6cSJohn Marino   /* Compile the Nth probe argument to an agent expression.  PROBE
329*ef5ccd6cSJohn Marino      will have come from a call to this objfile's sym_get_probes
330*ef5ccd6cSJohn Marino      method.  N will be between 0 and the number of arguments
331*ef5ccd6cSJohn Marino      available to this probe.  EXPR and VALUE are the agent expression
332*ef5ccd6cSJohn Marino      that is being updated.  */
333*ef5ccd6cSJohn Marino   void (*sym_compile_to_ax) (struct probe *probe,
334*ef5ccd6cSJohn Marino 			     struct agent_expr *expr,
335*ef5ccd6cSJohn Marino 			     struct axs_value *value,
336*ef5ccd6cSJohn Marino 			     unsigned n);
337*ef5ccd6cSJohn Marino 
338*ef5ccd6cSJohn Marino   /* Relocate the probe section of OBJFILE.  */
339*ef5ccd6cSJohn Marino   void (*sym_relocate_probe) (struct objfile *objfile,
340*ef5ccd6cSJohn Marino 			      struct section_offsets *new_offsets,
341*ef5ccd6cSJohn Marino 			      struct section_offsets *delta);
342*ef5ccd6cSJohn Marino };
343*ef5ccd6cSJohn Marino 
3445796c8dcSSimon Schubert /* Structure to keep track of symbol reading functions for various
3455796c8dcSSimon Schubert    object file types.  */
3465796c8dcSSimon Schubert 
3475796c8dcSSimon Schubert struct sym_fns
3485796c8dcSSimon Schubert {
3495796c8dcSSimon Schubert 
3505796c8dcSSimon Schubert   /* BFD flavour that we handle, or (as a special kludge, see
3515796c8dcSSimon Schubert      xcoffread.c, (enum bfd_flavour)-1 for xcoff).  */
3525796c8dcSSimon Schubert 
3535796c8dcSSimon Schubert   enum bfd_flavour sym_flavour;
3545796c8dcSSimon Schubert 
3555796c8dcSSimon Schubert   /* Initializes anything that is global to the entire symbol table.
3565796c8dcSSimon Schubert      It is called during symbol_file_add, when we begin debugging an
3575796c8dcSSimon Schubert      entirely new program.  */
3585796c8dcSSimon Schubert 
3595796c8dcSSimon Schubert   void (*sym_new_init) (struct objfile *);
3605796c8dcSSimon Schubert 
3615796c8dcSSimon Schubert   /* Reads any initial information from a symbol file, and initializes
3625796c8dcSSimon Schubert      the struct sym_fns SF in preparation for sym_read().  It is
3635796c8dcSSimon Schubert      called every time we read a symbol file for any reason.  */
3645796c8dcSSimon Schubert 
3655796c8dcSSimon Schubert   void (*sym_init) (struct objfile *);
3665796c8dcSSimon Schubert 
367cf7f2e2dSJohn Marino   /* sym_read (objfile, symfile_flags) Reads a symbol file into a psymtab
3685796c8dcSSimon Schubert      (or possibly a symtab).  OBJFILE is the objfile struct for the
369cf7f2e2dSJohn Marino      file we are reading.  SYMFILE_FLAGS are the flags passed to
370cf7f2e2dSJohn Marino      symbol_file_add & co.  */
3715796c8dcSSimon Schubert 
3725796c8dcSSimon Schubert   void (*sym_read) (struct objfile *, int);
3735796c8dcSSimon Schubert 
374c50c785cSJohn Marino   /* Read the partial symbols for an objfile.  This may be NULL, in which case
375c50c785cSJohn Marino      gdb has to check other ways if this objfile has any symbols.  This may
376c50c785cSJohn Marino      only be non-NULL if the objfile actually does have debuginfo available.
377c50c785cSJohn Marino      */
378c50c785cSJohn Marino 
379c50c785cSJohn Marino   void (*sym_read_psymbols) (struct objfile *);
380c50c785cSJohn Marino 
3815796c8dcSSimon Schubert   /* Called when we are finished with an objfile.  Should do all
3825796c8dcSSimon Schubert      cleanup that is specific to the object file format for the
3835796c8dcSSimon Schubert      particular objfile.  */
3845796c8dcSSimon Schubert 
3855796c8dcSSimon Schubert   void (*sym_finish) (struct objfile *);
3865796c8dcSSimon Schubert 
3875796c8dcSSimon Schubert   /* This function produces a file-dependent section_offsets
3885796c8dcSSimon Schubert      structure, allocated in the objfile's storage, and based on the
3895796c8dcSSimon Schubert      parameter.  The parameter is currently a CORE_ADDR (FIXME!) for
3905796c8dcSSimon Schubert      backward compatibility with the higher levels of GDB.  It should
3915796c8dcSSimon Schubert      probably be changed to a string, where NULL means the default,
3925796c8dcSSimon Schubert      and others are parsed in a file dependent way.  */
3935796c8dcSSimon Schubert 
3945796c8dcSSimon Schubert   void (*sym_offsets) (struct objfile *, struct section_addr_info *);
3955796c8dcSSimon Schubert 
3965796c8dcSSimon Schubert   /* This function produces a format-independent description of
3975796c8dcSSimon Schubert      the segments of ABFD.  Each segment is a unit of the file
3985796c8dcSSimon Schubert      which may be relocated independently.  */
3995796c8dcSSimon Schubert 
4005796c8dcSSimon Schubert   struct symfile_segment_data *(*sym_segments) (bfd *abfd);
4015796c8dcSSimon Schubert 
4025796c8dcSSimon Schubert   /* This function should read the linetable from the objfile when
4035796c8dcSSimon Schubert      the line table cannot be read while processing the debugging
4045796c8dcSSimon Schubert      information.  */
405cf7f2e2dSJohn Marino 
4065796c8dcSSimon Schubert   void (*sym_read_linetable) (void);
4075796c8dcSSimon Schubert 
408cf7f2e2dSJohn Marino   /* Relocate the contents of a debug section SECTP.  The
409cf7f2e2dSJohn Marino      contents are stored in BUF if it is non-NULL, or returned in a
410cf7f2e2dSJohn Marino      malloc'd buffer otherwise.  */
411cf7f2e2dSJohn Marino 
412cf7f2e2dSJohn Marino   bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf);
413cf7f2e2dSJohn Marino 
414*ef5ccd6cSJohn Marino   /* If non-NULL, this objfile has probe support, and all the probe
415*ef5ccd6cSJohn Marino      functions referred to here will be non-NULL.  */
416*ef5ccd6cSJohn Marino   const struct sym_probe_fns *sym_probe_fns;
417*ef5ccd6cSJohn Marino 
418cf7f2e2dSJohn Marino   /* The "quick" (aka partial) symbol functions for this symbol
419cf7f2e2dSJohn Marino      reader.  */
420cf7f2e2dSJohn Marino   const struct quick_symbol_functions *qf;
4215796c8dcSSimon Schubert };
4225796c8dcSSimon Schubert 
423cf7f2e2dSJohn Marino extern struct section_addr_info *
424cf7f2e2dSJohn Marino   build_section_addr_info_from_objfile (const struct objfile *objfile);
425cf7f2e2dSJohn Marino 
426cf7f2e2dSJohn Marino extern void relative_addr_info_to_section_offsets
427cf7f2e2dSJohn Marino   (struct section_offsets *section_offsets, int num_sections,
428cf7f2e2dSJohn Marino    struct section_addr_info *addrs);
429cf7f2e2dSJohn Marino 
430cf7f2e2dSJohn Marino extern void addr_info_make_relative (struct section_addr_info *addrs,
431cf7f2e2dSJohn Marino 				     bfd *abfd);
432cf7f2e2dSJohn Marino 
4335796c8dcSSimon Schubert /* The default version of sym_fns.sym_offsets for readers that don't
4345796c8dcSSimon Schubert    do anything special.  */
4355796c8dcSSimon Schubert 
4365796c8dcSSimon Schubert extern void default_symfile_offsets (struct objfile *objfile,
4375796c8dcSSimon Schubert 				     struct section_addr_info *);
4385796c8dcSSimon Schubert 
4395796c8dcSSimon Schubert /* The default version of sym_fns.sym_segments for readers that don't
4405796c8dcSSimon Schubert    do anything special.  */
4415796c8dcSSimon Schubert 
4425796c8dcSSimon Schubert extern struct symfile_segment_data *default_symfile_segments (bfd *abfd);
4435796c8dcSSimon Schubert 
444cf7f2e2dSJohn Marino /* The default version of sym_fns.sym_relocate for readers that don't
445cf7f2e2dSJohn Marino    do anything special.  */
446cf7f2e2dSJohn Marino 
447cf7f2e2dSJohn Marino extern bfd_byte *default_symfile_relocate (struct objfile *objfile,
448cf7f2e2dSJohn Marino                                            asection *sectp, bfd_byte *buf);
449cf7f2e2dSJohn Marino 
450*ef5ccd6cSJohn Marino extern struct symtab *allocate_symtab (const char *, struct objfile *)
451*ef5ccd6cSJohn Marino   ATTRIBUTE_NONNULL (1);
4525796c8dcSSimon Schubert 
453c50c785cSJohn Marino extern void add_symtab_fns (const struct sym_fns *);
4545796c8dcSSimon Schubert 
4555796c8dcSSimon Schubert /* This enum encodes bit-flags passed as ADD_FLAGS parameter to
4565796c8dcSSimon Schubert    syms_from_objfile, symbol_file_add, etc.  */
4575796c8dcSSimon Schubert 
4585796c8dcSSimon Schubert enum symfile_add_flags
4595796c8dcSSimon Schubert   {
4605796c8dcSSimon Schubert     /* Be chatty about what you are doing.  */
4615796c8dcSSimon Schubert     SYMFILE_VERBOSE = 1 << 1,
4625796c8dcSSimon Schubert 
4635796c8dcSSimon Schubert     /* This is the main symbol file (as opposed to symbol file for dynamically
4645796c8dcSSimon Schubert        loaded code).  */
4655796c8dcSSimon Schubert     SYMFILE_MAINLINE = 1 << 2,
4665796c8dcSSimon Schubert 
4675796c8dcSSimon Schubert     /* Do not call breakpoint_re_set when adding this symbol file.  */
468c50c785cSJohn Marino     SYMFILE_DEFER_BP_RESET = 1 << 3,
469c50c785cSJohn Marino 
470c50c785cSJohn Marino     /* Do not immediately read symbols for this file.  By default,
471c50c785cSJohn Marino        symbols are read when the objfile is created.  */
472c50c785cSJohn Marino     SYMFILE_NO_READ = 1 << 4
4735796c8dcSSimon Schubert   };
4745796c8dcSSimon Schubert 
4755796c8dcSSimon Schubert extern void syms_from_objfile (struct objfile *,
4765796c8dcSSimon Schubert 			       struct section_addr_info *,
4775796c8dcSSimon Schubert 			       struct section_offsets *, int, int);
4785796c8dcSSimon Schubert 
4795796c8dcSSimon Schubert extern void new_symfile_objfile (struct objfile *, int);
4805796c8dcSSimon Schubert 
4815796c8dcSSimon Schubert extern struct objfile *symbol_file_add (char *, int,
4825796c8dcSSimon Schubert 					struct section_addr_info *, int);
4835796c8dcSSimon Schubert 
4845796c8dcSSimon Schubert extern struct objfile *symbol_file_add_from_bfd (bfd *, int,
4855796c8dcSSimon Schubert                                                  struct section_addr_info *,
486a45ae5f8SJohn Marino                                                  int, struct objfile *parent);
4875796c8dcSSimon Schubert 
488cf7f2e2dSJohn Marino extern void symbol_file_add_separate (bfd *, int, struct objfile *);
489cf7f2e2dSJohn Marino 
490cf7f2e2dSJohn Marino extern char *find_separate_debug_file_by_debuglink (struct objfile *);
491cf7f2e2dSJohn Marino 
4925796c8dcSSimon Schubert /* Create a new section_addr_info, with room for NUM_SECTIONS.  */
4935796c8dcSSimon Schubert 
4945796c8dcSSimon Schubert extern struct section_addr_info *alloc_section_addr_info (size_t
4955796c8dcSSimon Schubert 							  num_sections);
4965796c8dcSSimon Schubert 
4975796c8dcSSimon Schubert /* Build (allocate and populate) a section_addr_info struct from an
4985796c8dcSSimon Schubert    existing section table.  */
4995796c8dcSSimon Schubert 
5005796c8dcSSimon Schubert extern struct section_addr_info
5015796c8dcSSimon Schubert   *build_section_addr_info_from_section_table (const struct target_section
5025796c8dcSSimon Schubert 					       *start,
5035796c8dcSSimon Schubert 					       const struct target_section
5045796c8dcSSimon Schubert 					       *end);
5055796c8dcSSimon Schubert 
5065796c8dcSSimon Schubert /* Free all memory allocated by
5075796c8dcSSimon Schubert    build_section_addr_info_from_section_table.  */
5085796c8dcSSimon Schubert 
5095796c8dcSSimon Schubert extern void free_section_addr_info (struct section_addr_info *);
5105796c8dcSSimon Schubert 
5115796c8dcSSimon Schubert 
5125796c8dcSSimon Schubert 			/*   Variables   */
5135796c8dcSSimon Schubert 
5145796c8dcSSimon Schubert /* If non-zero, shared library symbols will be added automatically
5155796c8dcSSimon Schubert    when the inferior is created, new libraries are loaded, or when
5165796c8dcSSimon Schubert    attaching to the inferior.  This is almost always what users will
5175796c8dcSSimon Schubert    want to have happen; but for very large programs, the startup time
5185796c8dcSSimon Schubert    will be excessive, and so if this is a problem, the user can clear
5195796c8dcSSimon Schubert    this flag and then add the shared library symbols as needed.  Note
5205796c8dcSSimon Schubert    that there is a potential for confusion, since if the shared
5215796c8dcSSimon Schubert    library symbols are not loaded, commands like "info fun" will *not*
5225796c8dcSSimon Schubert    report all the functions that are actually present.  */
5235796c8dcSSimon Schubert 
5245796c8dcSSimon Schubert extern int auto_solib_add;
5255796c8dcSSimon Schubert 
5265796c8dcSSimon Schubert /* From symfile.c */
5275796c8dcSSimon Schubert 
5285796c8dcSSimon Schubert extern void set_initial_language (void);
5295796c8dcSSimon Schubert 
5305796c8dcSSimon Schubert extern void find_lowest_section (bfd *, asection *, void *);
5315796c8dcSSimon Schubert 
5325796c8dcSSimon Schubert extern bfd *symfile_bfd_open (char *);
5335796c8dcSSimon Schubert 
534*ef5ccd6cSJohn Marino extern bfd *gdb_bfd_open_maybe_remote (const char *);
535cf7f2e2dSJohn Marino 
5365796c8dcSSimon Schubert extern int get_section_index (struct objfile *, char *);
5375796c8dcSSimon Schubert 
5385796c8dcSSimon Schubert /* Utility functions for overlay sections: */
5395796c8dcSSimon Schubert extern enum overlay_debugging_state
5405796c8dcSSimon Schubert {
5415796c8dcSSimon Schubert   ovly_off,
5425796c8dcSSimon Schubert   ovly_on,
5435796c8dcSSimon Schubert   ovly_auto
5445796c8dcSSimon Schubert } overlay_debugging;
5455796c8dcSSimon Schubert extern int overlay_cache_invalid;
5465796c8dcSSimon Schubert 
5475796c8dcSSimon Schubert /* Return the "mapped" overlay section containing the PC.  */
5485796c8dcSSimon Schubert extern struct obj_section *find_pc_mapped_section (CORE_ADDR);
5495796c8dcSSimon Schubert 
5505796c8dcSSimon Schubert /* Return any overlay section containing the PC (even in its LMA
5515796c8dcSSimon Schubert    region).  */
5525796c8dcSSimon Schubert extern struct obj_section *find_pc_overlay (CORE_ADDR);
5535796c8dcSSimon Schubert 
5545796c8dcSSimon Schubert /* Return true if the section is an overlay.  */
5555796c8dcSSimon Schubert extern int section_is_overlay (struct obj_section *);
5565796c8dcSSimon Schubert 
5575796c8dcSSimon Schubert /* Return true if the overlay section is currently "mapped".  */
5585796c8dcSSimon Schubert extern int section_is_mapped (struct obj_section *);
5595796c8dcSSimon Schubert 
5605796c8dcSSimon Schubert /* Return true if pc belongs to section's VMA.  */
5615796c8dcSSimon Schubert extern CORE_ADDR pc_in_mapped_range (CORE_ADDR, struct obj_section *);
5625796c8dcSSimon Schubert 
5635796c8dcSSimon Schubert /* Return true if pc belongs to section's LMA.  */
5645796c8dcSSimon Schubert extern CORE_ADDR pc_in_unmapped_range (CORE_ADDR, struct obj_section *);
5655796c8dcSSimon Schubert 
5665796c8dcSSimon Schubert /* Map an address from a section's LMA to its VMA.  */
5675796c8dcSSimon Schubert extern CORE_ADDR overlay_mapped_address (CORE_ADDR, struct obj_section *);
5685796c8dcSSimon Schubert 
5695796c8dcSSimon Schubert /* Map an address from a section's VMA to its LMA.  */
5705796c8dcSSimon Schubert extern CORE_ADDR overlay_unmapped_address (CORE_ADDR, struct obj_section *);
5715796c8dcSSimon Schubert 
5725796c8dcSSimon Schubert /* Convert an address in an overlay section (force into VMA range).  */
5735796c8dcSSimon Schubert extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *);
5745796c8dcSSimon Schubert 
5755796c8dcSSimon Schubert /* Load symbols from a file.  */
5765796c8dcSSimon Schubert extern void symbol_file_add_main (char *args, int from_tty);
5775796c8dcSSimon Schubert 
5785796c8dcSSimon Schubert /* Clear GDB symbol tables.  */
5795796c8dcSSimon Schubert extern void symbol_file_clear (int from_tty);
5805796c8dcSSimon Schubert 
5815796c8dcSSimon Schubert /* Default overlay update function.  */
5825796c8dcSSimon Schubert extern void simple_overlay_update (struct obj_section *);
5835796c8dcSSimon Schubert 
584cf7f2e2dSJohn Marino extern bfd_byte *symfile_relocate_debug_section (struct objfile *, asection *,
585cf7f2e2dSJohn Marino 						 bfd_byte *);
5865796c8dcSSimon Schubert 
5875796c8dcSSimon Schubert extern int symfile_map_offsets_to_segments (bfd *,
5885796c8dcSSimon Schubert 					    struct symfile_segment_data *,
5895796c8dcSSimon Schubert 					    struct section_offsets *,
5905796c8dcSSimon Schubert 					    int, const CORE_ADDR *);
5915796c8dcSSimon Schubert struct symfile_segment_data *get_symfile_segment_data (bfd *abfd);
5925796c8dcSSimon Schubert void free_symfile_segment_data (struct symfile_segment_data *data);
5935796c8dcSSimon Schubert 
594cf7f2e2dSJohn Marino extern struct cleanup *increment_reading_symtab (void);
595cf7f2e2dSJohn Marino 
5965796c8dcSSimon Schubert /* From dwarf2read.c */
5975796c8dcSSimon Schubert 
598a45ae5f8SJohn Marino /* Names for a dwarf2 debugging section.  The field NORMAL is the normal
599a45ae5f8SJohn Marino    section name (usually from the DWARF standard), while the field COMPRESSED
600a45ae5f8SJohn Marino    is the name of compressed sections.  If your object file format doesn't
601a45ae5f8SJohn Marino    support compressed sections, the field COMPRESSED can be NULL.  Likewise,
602a45ae5f8SJohn Marino    the debugging section is not supported, the field NORMAL can be NULL too.
603a45ae5f8SJohn Marino    It doesn't make sense to have a NULL NORMAL field but a non-NULL COMPRESSED
604a45ae5f8SJohn Marino    field.  */
605a45ae5f8SJohn Marino 
606a45ae5f8SJohn Marino struct dwarf2_section_names {
607a45ae5f8SJohn Marino   const char *normal;
608a45ae5f8SJohn Marino   const char *compressed;
609a45ae5f8SJohn Marino };
610a45ae5f8SJohn Marino 
611a45ae5f8SJohn Marino /* List of names for dward2 debugging sections.  Also most object file formats
612a45ae5f8SJohn Marino    use the standardized (ie ELF) names, some (eg XCOFF) have customized names
613a45ae5f8SJohn Marino    due to restrictions.
614a45ae5f8SJohn Marino    The table for the standard names is defined in dwarf2read.c.  Please
615a45ae5f8SJohn Marino    update all instances of dwarf2_debug_sections if you add a field to this
616a45ae5f8SJohn Marino    structure.  It is always safe to use { NULL, NULL } in this case.  */
617a45ae5f8SJohn Marino 
618a45ae5f8SJohn Marino struct dwarf2_debug_sections {
619a45ae5f8SJohn Marino   struct dwarf2_section_names info;
620a45ae5f8SJohn Marino   struct dwarf2_section_names abbrev;
621a45ae5f8SJohn Marino   struct dwarf2_section_names line;
622a45ae5f8SJohn Marino   struct dwarf2_section_names loc;
623a45ae5f8SJohn Marino   struct dwarf2_section_names macinfo;
624a45ae5f8SJohn Marino   struct dwarf2_section_names macro;
625a45ae5f8SJohn Marino   struct dwarf2_section_names str;
626a45ae5f8SJohn Marino   struct dwarf2_section_names ranges;
627a45ae5f8SJohn Marino   struct dwarf2_section_names types;
628*ef5ccd6cSJohn Marino   struct dwarf2_section_names addr;
629a45ae5f8SJohn Marino   struct dwarf2_section_names frame;
630a45ae5f8SJohn Marino   struct dwarf2_section_names eh_frame;
631a45ae5f8SJohn Marino   struct dwarf2_section_names gdb_index;
632a45ae5f8SJohn Marino   /* This field has no meaning, but exists solely to catch changes to
633a45ae5f8SJohn Marino      this structure which are not reflected in some instance.  */
634a45ae5f8SJohn Marino   int sentinel;
635a45ae5f8SJohn Marino };
636a45ae5f8SJohn Marino 
637a45ae5f8SJohn Marino extern int dwarf2_has_info (struct objfile *,
638a45ae5f8SJohn Marino                             const struct dwarf2_debug_sections *);
639a45ae5f8SJohn Marino 
640a45ae5f8SJohn Marino /* Dwarf2 sections that can be accessed by dwarf2_get_section_info.  */
641a45ae5f8SJohn Marino enum dwarf2_section_enum {
642a45ae5f8SJohn Marino   DWARF2_DEBUG_FRAME,
643a45ae5f8SJohn Marino   DWARF2_EH_FRAME
644a45ae5f8SJohn Marino };
645a45ae5f8SJohn Marino 
646a45ae5f8SJohn Marino extern void dwarf2_get_section_info (struct objfile *,
647a45ae5f8SJohn Marino                                      enum dwarf2_section_enum,
648a45ae5f8SJohn Marino 				     asection **, gdb_byte **,
649a45ae5f8SJohn Marino 				     bfd_size_type *);
6505796c8dcSSimon Schubert 
651c50c785cSJohn Marino extern int dwarf2_initialize_objfile (struct objfile *);
652cf7f2e2dSJohn Marino extern void dwarf2_build_psymtabs (struct objfile *);
6535796c8dcSSimon Schubert extern void dwarf2_build_frame_info (struct objfile *);
6545796c8dcSSimon Schubert 
6555796c8dcSSimon Schubert void dwarf2_free_objfile (struct objfile *);
6565796c8dcSSimon Schubert 
6575796c8dcSSimon Schubert /* From mdebugread.c */
6585796c8dcSSimon Schubert 
6595796c8dcSSimon Schubert extern void mdebug_build_psymtabs (struct objfile *,
6605796c8dcSSimon Schubert 				   const struct ecoff_debug_swap *,
6615796c8dcSSimon Schubert 				   struct ecoff_debug_info *);
6625796c8dcSSimon Schubert 
6635796c8dcSSimon Schubert extern void elfmdebug_build_psymtabs (struct objfile *,
6645796c8dcSSimon Schubert 				      const struct ecoff_debug_swap *,
6655796c8dcSSimon Schubert 				      asection *);
6665796c8dcSSimon Schubert 
667*ef5ccd6cSJohn Marino /* From minidebug.c.  */
668*ef5ccd6cSJohn Marino 
669*ef5ccd6cSJohn Marino extern bfd *find_separate_debug_file_in_section (struct objfile *);
670*ef5ccd6cSJohn Marino 
6715796c8dcSSimon Schubert #endif /* !defined(SYMFILE_H) */
672