15796c8dcSSimon Schubert /* Definitions for reading symbol files into GDB. 25796c8dcSSimon Schubert 35796c8dcSSimon Schubert Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4*c50c785cSJohn Marino 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010, 2011 55796c8dcSSimon Schubert Free Software Foundation, Inc. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This file is part of GDB. 85796c8dcSSimon Schubert 95796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 105796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 115796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 125796c8dcSSimon Schubert (at your option) any later version. 135796c8dcSSimon Schubert 145796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 155796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 165796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 175796c8dcSSimon Schubert GNU General Public License for more details. 185796c8dcSSimon Schubert 195796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 205796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 215796c8dcSSimon Schubert 225796c8dcSSimon Schubert #if !defined (SYMFILE_H) 235796c8dcSSimon Schubert #define SYMFILE_H 245796c8dcSSimon Schubert 255796c8dcSSimon Schubert /* This file requires that you first include "bfd.h". */ 265796c8dcSSimon Schubert #include "symtab.h" 275796c8dcSSimon Schubert 285796c8dcSSimon Schubert /* Opaque declarations. */ 295796c8dcSSimon Schubert struct target_section; 305796c8dcSSimon Schubert struct objfile; 315796c8dcSSimon Schubert struct obj_section; 325796c8dcSSimon Schubert struct obstack; 335796c8dcSSimon Schubert struct block; 345796c8dcSSimon Schubert 35*c50c785cSJohn Marino /* Comparison function for symbol look ups. */ 36*c50c785cSJohn Marino 37*c50c785cSJohn Marino typedef int (symbol_compare_ftype) (const char *string1, 38*c50c785cSJohn Marino const char *string2); 39*c50c785cSJohn Marino 405796c8dcSSimon Schubert /* Partial symbols are stored in the psymbol_cache and pointers to 415796c8dcSSimon Schubert them are kept in a dynamically grown array that is obtained from 425796c8dcSSimon Schubert malloc and grown as necessary via realloc. Each objfile typically 435796c8dcSSimon Schubert has two of these, one for global symbols and one for static 445796c8dcSSimon Schubert symbols. Although this adds a level of indirection for storing or 455796c8dcSSimon Schubert accessing the partial symbols, it allows us to throw away duplicate 465796c8dcSSimon Schubert psymbols and set all pointers to the single saved instance. */ 475796c8dcSSimon Schubert 485796c8dcSSimon Schubert struct psymbol_allocation_list 495796c8dcSSimon Schubert { 505796c8dcSSimon Schubert 515796c8dcSSimon Schubert /* Pointer to beginning of dynamically allocated array of pointers 525796c8dcSSimon Schubert to partial symbols. The array is dynamically expanded as 535796c8dcSSimon Schubert necessary to accommodate more pointers. */ 545796c8dcSSimon Schubert 555796c8dcSSimon Schubert struct partial_symbol **list; 565796c8dcSSimon Schubert 575796c8dcSSimon Schubert /* Pointer to next available slot in which to store a pointer to a 585796c8dcSSimon Schubert partial symbol. */ 595796c8dcSSimon Schubert 605796c8dcSSimon Schubert struct partial_symbol **next; 615796c8dcSSimon Schubert 625796c8dcSSimon Schubert /* Number of allocated pointer slots in current dynamic array (not 635796c8dcSSimon Schubert the number of bytes of storage). The "next" pointer will always 645796c8dcSSimon Schubert point somewhere between list[0] and list[size], and when at 655796c8dcSSimon Schubert list[size] the array will be expanded on the next attempt to 665796c8dcSSimon Schubert store a pointer. */ 675796c8dcSSimon Schubert 685796c8dcSSimon Schubert int size; 695796c8dcSSimon Schubert }; 705796c8dcSSimon Schubert 715796c8dcSSimon Schubert /* Define an array of addresses to accommodate non-contiguous dynamic 725796c8dcSSimon Schubert loading of modules. This is for use when entering commands, so we 735796c8dcSSimon Schubert can keep track of the section names until we read the file and can 745796c8dcSSimon Schubert map them to bfd sections. This structure is also used by solib.c 755796c8dcSSimon Schubert to communicate the section addresses in shared objects to 765796c8dcSSimon Schubert symbol_file_add (). */ 775796c8dcSSimon Schubert 785796c8dcSSimon Schubert struct section_addr_info 795796c8dcSSimon Schubert { 805796c8dcSSimon Schubert /* The number of sections for which address information is 815796c8dcSSimon Schubert available. */ 825796c8dcSSimon Schubert size_t num_sections; 835796c8dcSSimon Schubert /* Sections whose names are file format dependent. */ 845796c8dcSSimon Schubert struct other_sections 855796c8dcSSimon Schubert { 865796c8dcSSimon Schubert CORE_ADDR addr; 875796c8dcSSimon Schubert char *name; 88cf7f2e2dSJohn Marino 89cf7f2e2dSJohn Marino /* SECTINDEX must be valid for associated BFD if ADDR is not zero. */ 905796c8dcSSimon Schubert int sectindex; 915796c8dcSSimon Schubert } other[1]; 925796c8dcSSimon Schubert }; 935796c8dcSSimon Schubert 945796c8dcSSimon Schubert 955796c8dcSSimon Schubert /* A table listing the load segments in a symfile, and which segment 965796c8dcSSimon Schubert each BFD section belongs to. */ 975796c8dcSSimon Schubert struct symfile_segment_data 985796c8dcSSimon Schubert { 995796c8dcSSimon Schubert /* How many segments are present in this file. If there are 1005796c8dcSSimon Schubert two, the text segment is the first one and the data segment 1015796c8dcSSimon Schubert is the second one. */ 1025796c8dcSSimon Schubert int num_segments; 1035796c8dcSSimon Schubert 1045796c8dcSSimon Schubert /* If NUM_SEGMENTS is greater than zero, the original base address 1055796c8dcSSimon Schubert of each segment. */ 1065796c8dcSSimon Schubert CORE_ADDR *segment_bases; 1075796c8dcSSimon Schubert 1085796c8dcSSimon Schubert /* If NUM_SEGMENTS is greater than zero, the memory size of each 1095796c8dcSSimon Schubert segment. */ 1105796c8dcSSimon Schubert CORE_ADDR *segment_sizes; 1115796c8dcSSimon Schubert 1125796c8dcSSimon Schubert /* If NUM_SEGMENTS is greater than zero, this is an array of entries 1135796c8dcSSimon Schubert recording which segment contains each BFD section. 1145796c8dcSSimon Schubert SEGMENT_INFO[I] is S+1 if the I'th BFD section belongs to segment 1155796c8dcSSimon Schubert S, or zero if it is not in any segment. */ 1165796c8dcSSimon Schubert int *segment_info; 1175796c8dcSSimon Schubert }; 1185796c8dcSSimon Schubert 119cf7f2e2dSJohn Marino /* The "quick" symbol functions exist so that symbol readers can 120cf7f2e2dSJohn Marino avoiding an initial read of all the symbols. For example, symbol 121cf7f2e2dSJohn Marino readers might choose to use the "partial symbol table" utilities, 122cf7f2e2dSJohn Marino which is one implementation of the quick symbol functions. 123cf7f2e2dSJohn Marino 124cf7f2e2dSJohn Marino The quick symbol functions are generally opaque: the underlying 125cf7f2e2dSJohn Marino representation is hidden from the caller. 126cf7f2e2dSJohn Marino 127cf7f2e2dSJohn Marino In general, these functions should only look at whatever special 128cf7f2e2dSJohn Marino index the symbol reader creates -- looking through the symbol 129cf7f2e2dSJohn Marino tables themselves is handled by generic code. If a function is 130cf7f2e2dSJohn Marino defined as returning a "symbol table", this means that the function 131cf7f2e2dSJohn Marino should only return a newly-created symbol table; it should not 132cf7f2e2dSJohn Marino examine pre-existing ones. 133cf7f2e2dSJohn Marino 134cf7f2e2dSJohn Marino The exact list of functions here was determined in an ad hoc way 135cf7f2e2dSJohn Marino based on gdb's history. */ 136cf7f2e2dSJohn Marino 137cf7f2e2dSJohn Marino struct quick_symbol_functions 138cf7f2e2dSJohn Marino { 139cf7f2e2dSJohn Marino /* Return true if this objfile has any "partial" symbols 140cf7f2e2dSJohn Marino available. */ 141cf7f2e2dSJohn Marino int (*has_symbols) (struct objfile *objfile); 142cf7f2e2dSJohn Marino 143cf7f2e2dSJohn Marino /* Return the symbol table for the "last" file appearing in 144cf7f2e2dSJohn Marino OBJFILE. */ 145cf7f2e2dSJohn Marino struct symtab *(*find_last_source_symtab) (struct objfile *objfile); 146cf7f2e2dSJohn Marino 147cf7f2e2dSJohn Marino /* Forget all cached full file names for OBJFILE. */ 148cf7f2e2dSJohn Marino void (*forget_cached_source_info) (struct objfile *objfile); 149cf7f2e2dSJohn Marino 150cf7f2e2dSJohn Marino /* Look up the symbol table, in OBJFILE, of a source file named 151cf7f2e2dSJohn Marino NAME. If there is no '/' in the name, a match after a '/' in the 152cf7f2e2dSJohn Marino symbol table's file name will also work. FULL_PATH is the 153cf7f2e2dSJohn Marino absolute file name, and REAL_PATH is the same, run through 154cf7f2e2dSJohn Marino gdb_realpath. 155cf7f2e2dSJohn Marino 156cf7f2e2dSJohn Marino If no such symbol table can be found, returns 0. 157cf7f2e2dSJohn Marino 158cf7f2e2dSJohn Marino Otherwise, sets *RESULT to the symbol table and returns 1. This 159cf7f2e2dSJohn Marino might return 1 and set *RESULT to NULL if the requested file is 160cf7f2e2dSJohn Marino an include file that does not have a symtab of its own. */ 161cf7f2e2dSJohn Marino int (*lookup_symtab) (struct objfile *objfile, 162cf7f2e2dSJohn Marino const char *name, 163cf7f2e2dSJohn Marino const char *full_path, 164cf7f2e2dSJohn Marino const char *real_path, 165cf7f2e2dSJohn Marino struct symtab **result); 166cf7f2e2dSJohn Marino 167cf7f2e2dSJohn Marino /* Check to see if the symbol is defined in a "partial" symbol table 168cf7f2e2dSJohn Marino of OBJFILE. KIND should be either GLOBAL_BLOCK or STATIC_BLOCK, 169cf7f2e2dSJohn Marino depending on whether we want to search global symbols or static 170cf7f2e2dSJohn Marino symbols. NAME is the name of the symbol to look for. DOMAIN 171cf7f2e2dSJohn Marino indicates what sort of symbol to search for. 172cf7f2e2dSJohn Marino 173cf7f2e2dSJohn Marino Returns the newly-expanded symbol table in which the symbol is 174cf7f2e2dSJohn Marino defined, or NULL if no such symbol table exists. */ 175cf7f2e2dSJohn Marino struct symtab *(*lookup_symbol) (struct objfile *objfile, 176cf7f2e2dSJohn Marino int kind, const char *name, 177cf7f2e2dSJohn Marino domain_enum domain); 178cf7f2e2dSJohn Marino 179*c50c785cSJohn Marino /* This is called to expand symbol tables before looking up a 180*c50c785cSJohn Marino symbol. A backend can choose to implement this and then have its 181*c50c785cSJohn Marino `lookup_symbol' hook always return NULL, or the reverse. (It 182*c50c785cSJohn Marino doesn't make sense to implement both.) The arguments are as for 183*c50c785cSJohn Marino `lookup_symbol'. */ 184*c50c785cSJohn Marino void (*pre_expand_symtabs_matching) (struct objfile *objfile, 185*c50c785cSJohn Marino int kind, const char *name, 186*c50c785cSJohn Marino domain_enum domain); 187*c50c785cSJohn Marino 188cf7f2e2dSJohn Marino /* Print statistics about any indices loaded for OBJFILE. The 189cf7f2e2dSJohn Marino statistics should be printed to gdb_stdout. This is used for 190cf7f2e2dSJohn Marino "maint print statistics". */ 191cf7f2e2dSJohn Marino void (*print_stats) (struct objfile *objfile); 192cf7f2e2dSJohn Marino 193cf7f2e2dSJohn Marino /* Dump any indices loaded for OBJFILE. The dump should go to 194cf7f2e2dSJohn Marino gdb_stdout. This is used for "maint print objfiles". */ 195cf7f2e2dSJohn Marino void (*dump) (struct objfile *objfile); 196cf7f2e2dSJohn Marino 197cf7f2e2dSJohn Marino /* This is called by objfile_relocate to relocate any indices loaded 198cf7f2e2dSJohn Marino for OBJFILE. */ 199cf7f2e2dSJohn Marino void (*relocate) (struct objfile *objfile, 200cf7f2e2dSJohn Marino struct section_offsets *new_offsets, 201cf7f2e2dSJohn Marino struct section_offsets *delta); 202cf7f2e2dSJohn Marino 203cf7f2e2dSJohn Marino /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that 204cf7f2e2dSJohn Marino the corresponding symbol tables are loaded. */ 205cf7f2e2dSJohn Marino void (*expand_symtabs_for_function) (struct objfile *objfile, 206cf7f2e2dSJohn Marino const char *func_name); 207cf7f2e2dSJohn Marino 208cf7f2e2dSJohn Marino /* Read all symbol tables associated with OBJFILE. */ 209cf7f2e2dSJohn Marino void (*expand_all_symtabs) (struct objfile *objfile); 210cf7f2e2dSJohn Marino 211cf7f2e2dSJohn Marino /* Read all symbol tables associated with OBJFILE which have the 212*c50c785cSJohn Marino file name FILENAME. 213*c50c785cSJohn Marino This is for the purposes of examining code only, e.g., expand_line_sal. 214*c50c785cSJohn Marino The routine may ignore debug info that is known to not be useful with 215*c50c785cSJohn Marino code, e.g., DW_TAG_type_unit for dwarf debug info. */ 216cf7f2e2dSJohn Marino void (*expand_symtabs_with_filename) (struct objfile *objfile, 217cf7f2e2dSJohn Marino const char *filename); 218cf7f2e2dSJohn Marino 219cf7f2e2dSJohn Marino /* Return the file name of the file holding the symbol in OBJFILE 220cf7f2e2dSJohn Marino named NAME. If no such symbol exists in OBJFILE, return NULL. */ 221*c50c785cSJohn Marino const char *(*find_symbol_file) (struct objfile *objfile, const char *name); 222cf7f2e2dSJohn Marino 223*c50c785cSJohn Marino /* Find global or static symbols in all tables that are in NAMESPACE 224*c50c785cSJohn Marino and for which MATCH (symbol name, NAME) == 0, passing each to 225*c50c785cSJohn Marino CALLBACK, reading in partial symbol symbol tables as needed. Look 226*c50c785cSJohn Marino through global symbols if GLOBAL and otherwise static symbols. 227*c50c785cSJohn Marino Passes NAME, NAMESPACE, and DATA to CALLBACK with each symbol 228*c50c785cSJohn Marino found. After each block is processed, passes NULL to CALLBACK. 229*c50c785cSJohn Marino MATCH must be weaker than strcmp_iw in the sense that 230*c50c785cSJohn Marino strcmp_iw(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE, if 231*c50c785cSJohn Marino non-null, must be an ordering relation compatible with strcmp_iw 232*c50c785cSJohn Marino in the sense that 233*c50c785cSJohn Marino strcmp(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0 234*c50c785cSJohn Marino and 235*c50c785cSJohn Marino strcmp(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0 236*c50c785cSJohn Marino (allowing strcmp(x,y) < 0 while ORDERED_COMPARE(x, y) == 0). 237*c50c785cSJohn Marino CALLBACK returns 0 to indicate that the scan should continue, or 238*c50c785cSJohn Marino non-zero to indicate that the scan should be terminated. */ 239cf7f2e2dSJohn Marino 240*c50c785cSJohn Marino void (*map_matching_symbols) (const char *name, domain_enum namespace, 241*c50c785cSJohn Marino struct objfile *, int global, 242*c50c785cSJohn Marino int (*callback) (struct block *, 243*c50c785cSJohn Marino struct symbol *, void *), 244*c50c785cSJohn Marino void *data, 245*c50c785cSJohn Marino symbol_compare_ftype *match, 246*c50c785cSJohn Marino symbol_compare_ftype *ordered_compare); 247cf7f2e2dSJohn Marino 248cf7f2e2dSJohn Marino /* Expand all symbol tables in OBJFILE matching some criteria. 249cf7f2e2dSJohn Marino 250cf7f2e2dSJohn Marino FILE_MATCHER is called for each file in OBJFILE. The file name 251cf7f2e2dSJohn Marino and the DATA argument are passed to it. If it returns zero, this 252*c50c785cSJohn Marino file is skipped. If FILE_MATCHER is NULL such file is not skipped. 253cf7f2e2dSJohn Marino 254*c50c785cSJohn Marino Otherwise, if KIND does not match this symbol is skipped. 255*c50c785cSJohn Marino 256*c50c785cSJohn Marino If even KIND matches, then NAME_MATCHER is called for each symbol defined 257*c50c785cSJohn Marino in the file. The symbol's "natural" name and DATA are passed to 258*c50c785cSJohn Marino NAME_MATCHER. 259cf7f2e2dSJohn Marino 260cf7f2e2dSJohn Marino If NAME_MATCHER returns zero, then this symbol is skipped. 261cf7f2e2dSJohn Marino 262*c50c785cSJohn Marino Otherwise, this symbol's symbol table is expanded. 263cf7f2e2dSJohn Marino 264cf7f2e2dSJohn Marino DATA is user data that is passed unmodified to the callback 265cf7f2e2dSJohn Marino functions. */ 266cf7f2e2dSJohn Marino void (*expand_symtabs_matching) (struct objfile *objfile, 267cf7f2e2dSJohn Marino int (*file_matcher) (const char *, void *), 268cf7f2e2dSJohn Marino int (*name_matcher) (const char *, void *), 269cf7f2e2dSJohn Marino domain_enum kind, 270cf7f2e2dSJohn Marino void *data); 271cf7f2e2dSJohn Marino 272cf7f2e2dSJohn Marino /* Return the symbol table from OBJFILE that contains PC and 273cf7f2e2dSJohn Marino SECTION. Return NULL if there is no such symbol table. This 274cf7f2e2dSJohn Marino should return the symbol table that contains a symbol whose 275cf7f2e2dSJohn Marino address exactly matches PC, or, if there is no exact match, the 276cf7f2e2dSJohn Marino symbol table that contains a symbol whose address is closest to 277cf7f2e2dSJohn Marino PC. */ 278cf7f2e2dSJohn Marino struct symtab *(*find_pc_sect_symtab) (struct objfile *objfile, 279cf7f2e2dSJohn Marino struct minimal_symbol *msymbol, 280cf7f2e2dSJohn Marino CORE_ADDR pc, 281cf7f2e2dSJohn Marino struct obj_section *section, 282cf7f2e2dSJohn Marino int warn_if_readin); 283cf7f2e2dSJohn Marino 284*c50c785cSJohn Marino /* Call a callback for every file defined in OBJFILE whose symtab is 285*c50c785cSJohn Marino not already read in. FUN is the callback. It is passed the file's name, 286*c50c785cSJohn Marino the file's full name, and the DATA passed to this function. */ 287cf7f2e2dSJohn Marino void (*map_symbol_filenames) (struct objfile *objfile, 288cf7f2e2dSJohn Marino void (*fun) (const char *, const char *, 289cf7f2e2dSJohn Marino void *), 290cf7f2e2dSJohn Marino void *data); 291cf7f2e2dSJohn Marino }; 292cf7f2e2dSJohn Marino 2935796c8dcSSimon Schubert /* Structure to keep track of symbol reading functions for various 2945796c8dcSSimon Schubert object file types. */ 2955796c8dcSSimon Schubert 2965796c8dcSSimon Schubert struct sym_fns 2975796c8dcSSimon Schubert { 2985796c8dcSSimon Schubert 2995796c8dcSSimon Schubert /* BFD flavour that we handle, or (as a special kludge, see 3005796c8dcSSimon Schubert xcoffread.c, (enum bfd_flavour)-1 for xcoff). */ 3015796c8dcSSimon Schubert 3025796c8dcSSimon Schubert enum bfd_flavour sym_flavour; 3035796c8dcSSimon Schubert 3045796c8dcSSimon Schubert /* Initializes anything that is global to the entire symbol table. 3055796c8dcSSimon Schubert It is called during symbol_file_add, when we begin debugging an 3065796c8dcSSimon Schubert entirely new program. */ 3075796c8dcSSimon Schubert 3085796c8dcSSimon Schubert void (*sym_new_init) (struct objfile *); 3095796c8dcSSimon Schubert 3105796c8dcSSimon Schubert /* Reads any initial information from a symbol file, and initializes 3115796c8dcSSimon Schubert the struct sym_fns SF in preparation for sym_read(). It is 3125796c8dcSSimon Schubert called every time we read a symbol file for any reason. */ 3135796c8dcSSimon Schubert 3145796c8dcSSimon Schubert void (*sym_init) (struct objfile *); 3155796c8dcSSimon Schubert 316cf7f2e2dSJohn Marino /* sym_read (objfile, symfile_flags) Reads a symbol file into a psymtab 3175796c8dcSSimon Schubert (or possibly a symtab). OBJFILE is the objfile struct for the 318cf7f2e2dSJohn Marino file we are reading. SYMFILE_FLAGS are the flags passed to 319cf7f2e2dSJohn Marino symbol_file_add & co. */ 3205796c8dcSSimon Schubert 3215796c8dcSSimon Schubert void (*sym_read) (struct objfile *, int); 3225796c8dcSSimon Schubert 323*c50c785cSJohn Marino /* Read the partial symbols for an objfile. This may be NULL, in which case 324*c50c785cSJohn Marino gdb has to check other ways if this objfile has any symbols. This may 325*c50c785cSJohn Marino only be non-NULL if the objfile actually does have debuginfo available. 326*c50c785cSJohn Marino */ 327*c50c785cSJohn Marino 328*c50c785cSJohn Marino void (*sym_read_psymbols) (struct objfile *); 329*c50c785cSJohn Marino 3305796c8dcSSimon Schubert /* Called when we are finished with an objfile. Should do all 3315796c8dcSSimon Schubert cleanup that is specific to the object file format for the 3325796c8dcSSimon Schubert particular objfile. */ 3335796c8dcSSimon Schubert 3345796c8dcSSimon Schubert void (*sym_finish) (struct objfile *); 3355796c8dcSSimon Schubert 3365796c8dcSSimon Schubert /* This function produces a file-dependent section_offsets 3375796c8dcSSimon Schubert structure, allocated in the objfile's storage, and based on the 3385796c8dcSSimon Schubert parameter. The parameter is currently a CORE_ADDR (FIXME!) for 3395796c8dcSSimon Schubert backward compatibility with the higher levels of GDB. It should 3405796c8dcSSimon Schubert probably be changed to a string, where NULL means the default, 3415796c8dcSSimon Schubert and others are parsed in a file dependent way. */ 3425796c8dcSSimon Schubert 3435796c8dcSSimon Schubert void (*sym_offsets) (struct objfile *, struct section_addr_info *); 3445796c8dcSSimon Schubert 3455796c8dcSSimon Schubert /* This function produces a format-independent description of 3465796c8dcSSimon Schubert the segments of ABFD. Each segment is a unit of the file 3475796c8dcSSimon Schubert which may be relocated independently. */ 3485796c8dcSSimon Schubert 3495796c8dcSSimon Schubert struct symfile_segment_data *(*sym_segments) (bfd *abfd); 3505796c8dcSSimon Schubert 3515796c8dcSSimon Schubert /* This function should read the linetable from the objfile when 3525796c8dcSSimon Schubert the line table cannot be read while processing the debugging 3535796c8dcSSimon Schubert information. */ 354cf7f2e2dSJohn Marino 3555796c8dcSSimon Schubert void (*sym_read_linetable) (void); 3565796c8dcSSimon Schubert 357cf7f2e2dSJohn Marino /* Relocate the contents of a debug section SECTP. The 358cf7f2e2dSJohn Marino contents are stored in BUF if it is non-NULL, or returned in a 359cf7f2e2dSJohn Marino malloc'd buffer otherwise. */ 360cf7f2e2dSJohn Marino 361cf7f2e2dSJohn Marino bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf); 362cf7f2e2dSJohn Marino 363cf7f2e2dSJohn Marino /* The "quick" (aka partial) symbol functions for this symbol 364cf7f2e2dSJohn Marino reader. */ 365cf7f2e2dSJohn Marino const struct quick_symbol_functions *qf; 3665796c8dcSSimon Schubert }; 3675796c8dcSSimon Schubert 368cf7f2e2dSJohn Marino extern struct section_addr_info * 369cf7f2e2dSJohn Marino build_section_addr_info_from_objfile (const struct objfile *objfile); 370cf7f2e2dSJohn Marino 371cf7f2e2dSJohn Marino extern void relative_addr_info_to_section_offsets 372cf7f2e2dSJohn Marino (struct section_offsets *section_offsets, int num_sections, 373cf7f2e2dSJohn Marino struct section_addr_info *addrs); 374cf7f2e2dSJohn Marino 375cf7f2e2dSJohn Marino extern void addr_info_make_relative (struct section_addr_info *addrs, 376cf7f2e2dSJohn Marino bfd *abfd); 377cf7f2e2dSJohn Marino 3785796c8dcSSimon Schubert /* The default version of sym_fns.sym_offsets for readers that don't 3795796c8dcSSimon Schubert do anything special. */ 3805796c8dcSSimon Schubert 3815796c8dcSSimon Schubert extern void default_symfile_offsets (struct objfile *objfile, 3825796c8dcSSimon Schubert struct section_addr_info *); 3835796c8dcSSimon Schubert 3845796c8dcSSimon Schubert /* The default version of sym_fns.sym_segments for readers that don't 3855796c8dcSSimon Schubert do anything special. */ 3865796c8dcSSimon Schubert 3875796c8dcSSimon Schubert extern struct symfile_segment_data *default_symfile_segments (bfd *abfd); 3885796c8dcSSimon Schubert 389cf7f2e2dSJohn Marino /* The default version of sym_fns.sym_relocate for readers that don't 390cf7f2e2dSJohn Marino do anything special. */ 391cf7f2e2dSJohn Marino 392cf7f2e2dSJohn Marino extern bfd_byte *default_symfile_relocate (struct objfile *objfile, 393cf7f2e2dSJohn Marino asection *sectp, bfd_byte *buf); 394cf7f2e2dSJohn Marino 395*c50c785cSJohn Marino extern struct symtab *allocate_symtab (const char *, struct objfile *); 3965796c8dcSSimon Schubert 397*c50c785cSJohn Marino extern void add_symtab_fns (const struct sym_fns *); 3985796c8dcSSimon Schubert 3995796c8dcSSimon Schubert /* This enum encodes bit-flags passed as ADD_FLAGS parameter to 4005796c8dcSSimon Schubert syms_from_objfile, symbol_file_add, etc. */ 4015796c8dcSSimon Schubert 4025796c8dcSSimon Schubert enum symfile_add_flags 4035796c8dcSSimon Schubert { 4045796c8dcSSimon Schubert /* Be chatty about what you are doing. */ 4055796c8dcSSimon Schubert SYMFILE_VERBOSE = 1 << 1, 4065796c8dcSSimon Schubert 4075796c8dcSSimon Schubert /* This is the main symbol file (as opposed to symbol file for dynamically 4085796c8dcSSimon Schubert loaded code). */ 4095796c8dcSSimon Schubert SYMFILE_MAINLINE = 1 << 2, 4105796c8dcSSimon Schubert 4115796c8dcSSimon Schubert /* Do not call breakpoint_re_set when adding this symbol file. */ 412*c50c785cSJohn Marino SYMFILE_DEFER_BP_RESET = 1 << 3, 413*c50c785cSJohn Marino 414*c50c785cSJohn Marino /* Do not immediately read symbols for this file. By default, 415*c50c785cSJohn Marino symbols are read when the objfile is created. */ 416*c50c785cSJohn Marino SYMFILE_NO_READ = 1 << 4 4175796c8dcSSimon Schubert }; 4185796c8dcSSimon Schubert 4195796c8dcSSimon Schubert extern void syms_from_objfile (struct objfile *, 4205796c8dcSSimon Schubert struct section_addr_info *, 4215796c8dcSSimon Schubert struct section_offsets *, int, int); 4225796c8dcSSimon Schubert 4235796c8dcSSimon Schubert extern void new_symfile_objfile (struct objfile *, int); 4245796c8dcSSimon Schubert 4255796c8dcSSimon Schubert extern struct objfile *symbol_file_add (char *, int, 4265796c8dcSSimon Schubert struct section_addr_info *, int); 4275796c8dcSSimon Schubert 4285796c8dcSSimon Schubert extern struct objfile *symbol_file_add_from_bfd (bfd *, int, 4295796c8dcSSimon Schubert struct section_addr_info *, 4305796c8dcSSimon Schubert int); 4315796c8dcSSimon Schubert 432cf7f2e2dSJohn Marino extern void symbol_file_add_separate (bfd *, int, struct objfile *); 433cf7f2e2dSJohn Marino 434cf7f2e2dSJohn Marino extern char *find_separate_debug_file_by_debuglink (struct objfile *); 435cf7f2e2dSJohn Marino 4365796c8dcSSimon Schubert /* Create a new section_addr_info, with room for NUM_SECTIONS. */ 4375796c8dcSSimon Schubert 4385796c8dcSSimon Schubert extern struct section_addr_info *alloc_section_addr_info (size_t 4395796c8dcSSimon Schubert num_sections); 4405796c8dcSSimon Schubert 4415796c8dcSSimon Schubert /* Build (allocate and populate) a section_addr_info struct from an 4425796c8dcSSimon Schubert existing section table. */ 4435796c8dcSSimon Schubert 4445796c8dcSSimon Schubert extern struct section_addr_info 4455796c8dcSSimon Schubert *build_section_addr_info_from_section_table (const struct target_section 4465796c8dcSSimon Schubert *start, 4475796c8dcSSimon Schubert const struct target_section 4485796c8dcSSimon Schubert *end); 4495796c8dcSSimon Schubert 4505796c8dcSSimon Schubert /* Free all memory allocated by 4515796c8dcSSimon Schubert build_section_addr_info_from_section_table. */ 4525796c8dcSSimon Schubert 4535796c8dcSSimon Schubert extern void free_section_addr_info (struct section_addr_info *); 4545796c8dcSSimon Schubert 4555796c8dcSSimon Schubert 4565796c8dcSSimon Schubert /* Make a copy of the string at PTR with SIZE characters in the symbol 4575796c8dcSSimon Schubert obstack (and add a null character at the end in the copy). Returns 4585796c8dcSSimon Schubert the address of the copy. */ 4595796c8dcSSimon Schubert 4605796c8dcSSimon Schubert extern char *obsavestring (const char *, int, struct obstack *); 4615796c8dcSSimon Schubert 462*c50c785cSJohn Marino /* Concatenate NULL terminated variable argument list of `const char 463*c50c785cSJohn Marino *' strings; return the new string. Space is found in the OBSTACKP. 464*c50c785cSJohn Marino Argument list must be terminated by a sentinel expression `(char *) 465*c50c785cSJohn Marino NULL'. */ 4665796c8dcSSimon Schubert 467cf7f2e2dSJohn Marino extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL; 4685796c8dcSSimon Schubert 4695796c8dcSSimon Schubert /* Variables */ 4705796c8dcSSimon Schubert 4715796c8dcSSimon Schubert /* If non-zero, shared library symbols will be added automatically 4725796c8dcSSimon Schubert when the inferior is created, new libraries are loaded, or when 4735796c8dcSSimon Schubert attaching to the inferior. This is almost always what users will 4745796c8dcSSimon Schubert want to have happen; but for very large programs, the startup time 4755796c8dcSSimon Schubert will be excessive, and so if this is a problem, the user can clear 4765796c8dcSSimon Schubert this flag and then add the shared library symbols as needed. Note 4775796c8dcSSimon Schubert that there is a potential for confusion, since if the shared 4785796c8dcSSimon Schubert library symbols are not loaded, commands like "info fun" will *not* 4795796c8dcSSimon Schubert report all the functions that are actually present. */ 4805796c8dcSSimon Schubert 4815796c8dcSSimon Schubert extern int auto_solib_add; 4825796c8dcSSimon Schubert 4835796c8dcSSimon Schubert /* From symfile.c */ 4845796c8dcSSimon Schubert 4855796c8dcSSimon Schubert extern void set_initial_language (void); 4865796c8dcSSimon Schubert 4875796c8dcSSimon Schubert extern void find_lowest_section (bfd *, asection *, void *); 4885796c8dcSSimon Schubert 4895796c8dcSSimon Schubert extern bfd *symfile_bfd_open (char *); 4905796c8dcSSimon Schubert 491cf7f2e2dSJohn Marino extern bfd *bfd_open_maybe_remote (const char *); 492cf7f2e2dSJohn Marino 4935796c8dcSSimon Schubert extern int get_section_index (struct objfile *, char *); 4945796c8dcSSimon Schubert 4955796c8dcSSimon Schubert /* Utility functions for overlay sections: */ 4965796c8dcSSimon Schubert extern enum overlay_debugging_state 4975796c8dcSSimon Schubert { 4985796c8dcSSimon Schubert ovly_off, 4995796c8dcSSimon Schubert ovly_on, 5005796c8dcSSimon Schubert ovly_auto 5015796c8dcSSimon Schubert } overlay_debugging; 5025796c8dcSSimon Schubert extern int overlay_cache_invalid; 5035796c8dcSSimon Schubert 5045796c8dcSSimon Schubert /* Return the "mapped" overlay section containing the PC. */ 5055796c8dcSSimon Schubert extern struct obj_section *find_pc_mapped_section (CORE_ADDR); 5065796c8dcSSimon Schubert 5075796c8dcSSimon Schubert /* Return any overlay section containing the PC (even in its LMA 5085796c8dcSSimon Schubert region). */ 5095796c8dcSSimon Schubert extern struct obj_section *find_pc_overlay (CORE_ADDR); 5105796c8dcSSimon Schubert 5115796c8dcSSimon Schubert /* Return true if the section is an overlay. */ 5125796c8dcSSimon Schubert extern int section_is_overlay (struct obj_section *); 5135796c8dcSSimon Schubert 5145796c8dcSSimon Schubert /* Return true if the overlay section is currently "mapped". */ 5155796c8dcSSimon Schubert extern int section_is_mapped (struct obj_section *); 5165796c8dcSSimon Schubert 5175796c8dcSSimon Schubert /* Return true if pc belongs to section's VMA. */ 5185796c8dcSSimon Schubert extern CORE_ADDR pc_in_mapped_range (CORE_ADDR, struct obj_section *); 5195796c8dcSSimon Schubert 5205796c8dcSSimon Schubert /* Return true if pc belongs to section's LMA. */ 5215796c8dcSSimon Schubert extern CORE_ADDR pc_in_unmapped_range (CORE_ADDR, struct obj_section *); 5225796c8dcSSimon Schubert 5235796c8dcSSimon Schubert /* Map an address from a section's LMA to its VMA. */ 5245796c8dcSSimon Schubert extern CORE_ADDR overlay_mapped_address (CORE_ADDR, struct obj_section *); 5255796c8dcSSimon Schubert 5265796c8dcSSimon Schubert /* Map an address from a section's VMA to its LMA. */ 5275796c8dcSSimon Schubert extern CORE_ADDR overlay_unmapped_address (CORE_ADDR, struct obj_section *); 5285796c8dcSSimon Schubert 5295796c8dcSSimon Schubert /* Convert an address in an overlay section (force into VMA range). */ 5305796c8dcSSimon Schubert extern CORE_ADDR symbol_overlayed_address (CORE_ADDR, struct obj_section *); 5315796c8dcSSimon Schubert 5325796c8dcSSimon Schubert /* Load symbols from a file. */ 5335796c8dcSSimon Schubert extern void symbol_file_add_main (char *args, int from_tty); 5345796c8dcSSimon Schubert 5355796c8dcSSimon Schubert /* Clear GDB symbol tables. */ 5365796c8dcSSimon Schubert extern void symbol_file_clear (int from_tty); 5375796c8dcSSimon Schubert 5385796c8dcSSimon Schubert /* Default overlay update function. */ 5395796c8dcSSimon Schubert extern void simple_overlay_update (struct obj_section *); 5405796c8dcSSimon Schubert 541cf7f2e2dSJohn Marino extern bfd_byte *symfile_relocate_debug_section (struct objfile *, asection *, 542cf7f2e2dSJohn Marino bfd_byte *); 5435796c8dcSSimon Schubert 5445796c8dcSSimon Schubert extern int symfile_map_offsets_to_segments (bfd *, 5455796c8dcSSimon Schubert struct symfile_segment_data *, 5465796c8dcSSimon Schubert struct section_offsets *, 5475796c8dcSSimon Schubert int, const CORE_ADDR *); 5485796c8dcSSimon Schubert struct symfile_segment_data *get_symfile_segment_data (bfd *abfd); 5495796c8dcSSimon Schubert void free_symfile_segment_data (struct symfile_segment_data *data); 5505796c8dcSSimon Schubert 551cf7f2e2dSJohn Marino extern struct cleanup *increment_reading_symtab (void); 552cf7f2e2dSJohn Marino 5535796c8dcSSimon Schubert /* From dwarf2read.c */ 5545796c8dcSSimon Schubert 5555796c8dcSSimon Schubert extern int dwarf2_has_info (struct objfile *); 5565796c8dcSSimon Schubert 557*c50c785cSJohn Marino extern int dwarf2_initialize_objfile (struct objfile *); 558cf7f2e2dSJohn Marino extern void dwarf2_build_psymtabs (struct objfile *); 5595796c8dcSSimon Schubert extern void dwarf2_build_frame_info (struct objfile *); 5605796c8dcSSimon Schubert 5615796c8dcSSimon Schubert void dwarf2_free_objfile (struct objfile *); 5625796c8dcSSimon Schubert 5635796c8dcSSimon Schubert /* From mdebugread.c */ 5645796c8dcSSimon Schubert 5655796c8dcSSimon Schubert /* Hack to force structures to exist before use in parameter list. */ 5665796c8dcSSimon Schubert struct ecoff_debug_hack 5675796c8dcSSimon Schubert { 5685796c8dcSSimon Schubert struct ecoff_debug_swap *a; 5695796c8dcSSimon Schubert struct ecoff_debug_info *b; 5705796c8dcSSimon Schubert }; 5715796c8dcSSimon Schubert 5725796c8dcSSimon Schubert extern void mdebug_build_psymtabs (struct objfile *, 5735796c8dcSSimon Schubert const struct ecoff_debug_swap *, 5745796c8dcSSimon Schubert struct ecoff_debug_info *); 5755796c8dcSSimon Schubert 5765796c8dcSSimon Schubert extern void elfmdebug_build_psymtabs (struct objfile *, 5775796c8dcSSimon Schubert const struct ecoff_debug_swap *, 5785796c8dcSSimon Schubert asection *); 5795796c8dcSSimon Schubert 5805796c8dcSSimon Schubert #endif /* !defined(SYMFILE_H) */ 581