GDB (API)
|
00001 /* Build symbol tables in GDB's internal format. 00002 Copyright (C) 1986-2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #if !defined (BUILDSYM_H) 00020 #define BUILDSYM_H 1 00021 00022 struct objfile; 00023 struct symbol; 00024 struct addrmap; 00025 00026 /* This module provides definitions used for creating and adding to 00027 the symbol table. These routines are called from various symbol- 00028 file-reading routines. 00029 00030 They originated in dbxread.c of gdb-4.2, and were split out to 00031 make xcoffread.c more maintainable by sharing code. 00032 00033 Variables declared in this file can be defined by #define-ing the 00034 name EXTERN to null. It is used to declare variables that are 00035 normally extern, but which get defined in a single module using 00036 this technique. */ 00037 00038 struct block; 00039 struct pending_block; 00040 00041 #ifndef EXTERN 00042 #define EXTERN extern 00043 #endif 00044 00045 #define HASHSIZE 127 /* Size of things hashed via 00046 hashname(). */ 00047 00048 /* Core address of start of text of current source file. This too 00049 comes from the N_SO symbol. For Dwarf it typically comes from the 00050 DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE. */ 00051 00052 EXTERN CORE_ADDR last_source_start_addr; 00053 00054 /* The list of sub-source-files within the current individual 00055 compilation. Each file gets its own symtab with its own linetable 00056 and associated info, but they all share one blockvector. */ 00057 00058 struct subfile 00059 { 00060 struct subfile *next; 00061 char *name; 00062 char *dirname; 00063 struct linetable *line_vector; 00064 int line_vector_length; 00065 enum language language; 00066 const char *producer; 00067 const char *debugformat; 00068 struct symtab *symtab; 00069 }; 00070 00071 EXTERN struct subfile *current_subfile; 00072 00073 /* Global variable which, when set, indicates that we are processing a 00074 .o file compiled with gcc */ 00075 00076 EXTERN unsigned char processing_gcc_compilation; 00077 00078 /* When set, we are processing a .o file compiled by sun acc. This is 00079 misnamed; it refers to all stabs-in-elf implementations which use 00080 N_UNDF the way Sun does, including Solaris gcc. Hopefully all 00081 stabs-in-elf implementations ever invented will choose to be 00082 compatible. */ 00083 00084 EXTERN unsigned char processing_acc_compilation; 00085 00086 /* Count symbols as they are processed, for error messages. */ 00087 00088 EXTERN unsigned int symnum; 00089 00090 /* Record the symbols defined for each context in a list. We don't 00091 create a struct block for the context until we know how long to 00092 make it. */ 00093 00094 #define PENDINGSIZE 100 00095 00096 struct pending 00097 { 00098 struct pending *next; 00099 int nsyms; 00100 struct symbol *symbol[PENDINGSIZE]; 00101 }; 00102 00103 /* Here are the three lists that symbols are put on. */ 00104 00105 /* static at top level, and types */ 00106 00107 EXTERN struct pending *file_symbols; 00108 00109 /* global functions and variables */ 00110 00111 EXTERN struct pending *global_symbols; 00112 00113 /* everything local to lexical context */ 00114 00115 EXTERN struct pending *local_symbols; 00116 00117 /* "using" directives local to lexical context. */ 00118 00119 EXTERN struct using_direct *using_directives; 00120 00121 /* Stack representing unclosed lexical contexts (that will become 00122 blocks, eventually). */ 00123 00124 struct context_stack 00125 { 00126 /* Outer locals at the time we entered */ 00127 00128 struct pending *locals; 00129 00130 /* Pending using directives at the time we entered. */ 00131 00132 struct using_direct *using_directives; 00133 00134 /* Pointer into blocklist as of entry */ 00135 00136 struct pending_block *old_blocks; 00137 00138 /* Name of function, if any, defining context */ 00139 00140 struct symbol *name; 00141 00142 /* PC where this context starts */ 00143 00144 CORE_ADDR start_addr; 00145 00146 /* Temp slot for exception handling. */ 00147 00148 CORE_ADDR end_addr; 00149 00150 /* For error-checking matching push/pop */ 00151 00152 int depth; 00153 00154 }; 00155 00156 EXTERN struct context_stack *context_stack; 00157 00158 /* Index of first unused entry in context stack. */ 00159 00160 EXTERN int context_stack_depth; 00161 00162 /* Currently allocated size of context stack. */ 00163 00164 EXTERN int context_stack_size; 00165 00166 /* Non-zero if the context stack is empty. */ 00167 #define outermost_context_p() (context_stack_depth == 0) 00168 00169 /* Nonzero if within a function (so symbols should be local, if 00170 nothing says specifically). */ 00171 00172 EXTERN int within_function; 00173 00174 00175 00176 #define next_symbol_text(objfile) (*next_symbol_text_func)(objfile) 00177 00178 /* Function to invoke get the next symbol. Return the symbol name. */ 00179 00180 EXTERN char *(*next_symbol_text_func) (struct objfile *); 00181 00182 extern void add_symbol_to_list (struct symbol *symbol, 00183 struct pending **listhead); 00184 00185 extern struct symbol *find_symbol_in_list (struct pending *list, 00186 char *name, int length); 00187 00188 extern struct block *finish_block (struct symbol *symbol, 00189 struct pending **listhead, 00190 struct pending_block *old_blocks, 00191 CORE_ADDR start, CORE_ADDR end, 00192 struct objfile *objfile); 00193 00194 extern void record_block_range (struct block *, 00195 CORE_ADDR start, CORE_ADDR end_inclusive); 00196 00197 extern void really_free_pendings (void *dummy); 00198 00199 extern void start_subfile (const char *name, const char *dirname); 00200 00201 extern void patch_subfile_names (struct subfile *subfile, char *name); 00202 00203 extern void push_subfile (void); 00204 00205 extern char *pop_subfile (void); 00206 00207 extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr, 00208 struct objfile *objfile, 00209 int expandable, 00210 int required); 00211 00212 extern struct symtab *end_symtab_from_static_block (struct block *static_block, 00213 struct objfile *objfile, 00214 int section, 00215 int expandable); 00216 00217 extern struct symtab *end_symtab (CORE_ADDR end_addr, 00218 struct objfile *objfile, int section); 00219 00220 extern struct symtab *end_expandable_symtab (CORE_ADDR end_addr, 00221 struct objfile *objfile, 00222 int section); 00223 00224 extern void augment_type_symtab (struct objfile *objfile, 00225 struct symtab *primary_symtab); 00226 00227 /* Defined in stabsread.c. */ 00228 00229 extern void scan_file_globals (struct objfile *objfile); 00230 00231 extern void buildsym_new_init (void); 00232 00233 extern void buildsym_init (void); 00234 00235 extern struct context_stack *push_context (int desc, CORE_ADDR valu); 00236 00237 extern struct context_stack *pop_context (void); 00238 00239 extern void record_line (struct subfile *subfile, int line, CORE_ADDR pc); 00240 00241 extern void start_symtab (const char *name, const char *dirname, 00242 CORE_ADDR start_addr); 00243 00244 extern void restart_symtab (CORE_ADDR start_addr); 00245 00246 extern int hashname (const char *name); 00247 00248 extern void free_pending_blocks (void); 00249 00250 /* Record the name of the debug format in the current pending symbol 00251 table. FORMAT must be a string with a lifetime at least as long as 00252 the symtab's objfile. */ 00253 00254 extern void record_debugformat (const char *format); 00255 00256 /* Record the name of the debuginfo producer (usually the compiler) in 00257 the current pending symbol table. PRODUCER must be a string with a 00258 lifetime at least as long as the symtab's objfile. */ 00259 00260 extern void record_producer (const char *producer); 00261 00262 extern void merge_symbol_lists (struct pending **srclist, 00263 struct pending **targetlist); 00264 00265 /* Set the name of the last source file. NAME is copied by this 00266 function. */ 00267 00268 extern void set_last_source_file (const char *name); 00269 00270 /* Fetch the name of the last source file. */ 00271 00272 extern const char *get_last_source_file (void); 00273 00274 /* Return the macro table. */ 00275 00276 extern struct macro_table *get_macro_table (struct objfile *objfile, 00277 const char *comp_dir); 00278 00279 #undef EXTERN 00280 00281 #endif /* defined (BUILDSYM_H) */