]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Do various things to symbol tables (other than lookup), for GDB. |
b6ba6518 KB |
2 | Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, |
3 | 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. | |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
c906108c | 11 | |
c5aa993b JM |
12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
c906108c | 16 | |
c5aa993b JM |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
c906108c SS |
21 | |
22 | #include "defs.h" | |
23 | #include "symtab.h" | |
24 | #include "gdbtypes.h" | |
25 | #include "bfd.h" | |
26 | #include "symfile.h" | |
27 | #include "objfiles.h" | |
28 | #include "breakpoint.h" | |
29 | #include "command.h" | |
30 | #include "obstack.h" | |
31 | #include "language.h" | |
32 | #include "bcache.h" | |
33 | ||
34 | #include "gdb_string.h" | |
35 | ||
36 | #ifndef DEV_TTY | |
37 | #define DEV_TTY "/dev/tty" | |
38 | #endif | |
39 | ||
40 | /* Unfortunately for debugging, stderr is usually a macro. This is painful | |
41 | when calling functions that take FILE *'s from the debugger. | |
42 | So we make a variable which has the same value and which is accessible when | |
43 | debugging GDB with itself. Because stdin et al need not be constants, | |
44 | we initialize them in the _initialize_symmisc function at the bottom | |
45 | of the file. */ | |
46 | FILE *std_in; | |
47 | FILE *std_out; | |
48 | FILE *std_err; | |
49 | ||
50 | /* Prototypes for local functions */ | |
51 | ||
d9fcf2fb JM |
52 | static void dump_symtab (struct objfile *, struct symtab *, |
53 | struct ui_file *); | |
c906108c | 54 | |
d9fcf2fb JM |
55 | static void dump_psymtab (struct objfile *, struct partial_symtab *, |
56 | struct ui_file *); | |
c906108c | 57 | |
d9fcf2fb | 58 | static void dump_msymbols (struct objfile *, struct ui_file *); |
c906108c | 59 | |
a14ed312 | 60 | static void dump_objfile (struct objfile *); |
c906108c | 61 | |
a14ed312 | 62 | static int block_depth (struct block *); |
c906108c | 63 | |
d9fcf2fb JM |
64 | static void print_partial_symbols (struct partial_symbol **, int, |
65 | char *, struct ui_file *); | |
c906108c | 66 | |
a14ed312 | 67 | static void free_symtab_block (struct objfile *, struct block *); |
c906108c | 68 | |
a14ed312 | 69 | void _initialize_symmisc (void); |
c906108c | 70 | |
c5aa993b JM |
71 | struct print_symbol_args |
72 | { | |
73 | struct symbol *symbol; | |
74 | int depth; | |
d9fcf2fb | 75 | struct ui_file *outfile; |
c5aa993b | 76 | }; |
c906108c | 77 | |
a14ed312 | 78 | static int print_symbol (PTR); |
c906108c | 79 | |
a14ed312 | 80 | static void free_symtab_block (struct objfile *, struct block *); |
c906108c | 81 | \f |
c5aa993b | 82 | |
c906108c SS |
83 | /* Free a struct block <- B and all the symbols defined in that block. */ |
84 | ||
85 | static void | |
fba45db2 | 86 | free_symtab_block (struct objfile *objfile, struct block *b) |
c906108c SS |
87 | { |
88 | register int i, n; | |
89 | n = BLOCK_NSYMS (b); | |
90 | for (i = 0; i < n; i++) | |
91 | { | |
aac7f4ea AC |
92 | xmfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i))); |
93 | xmfree (objfile->md, (PTR) BLOCK_SYM (b, i)); | |
c906108c | 94 | } |
aac7f4ea | 95 | xmfree (objfile->md, (PTR) b); |
c906108c SS |
96 | } |
97 | ||
98 | /* Free all the storage associated with the struct symtab <- S. | |
99 | Note that some symtabs have contents malloc'ed structure by structure, | |
100 | while some have contents that all live inside one big block of memory, | |
101 | and some share the contents of another symbol table and so you should | |
102 | not free the contents on their behalf (except sometimes the linetable, | |
103 | which maybe per symtab even when the rest is not). | |
104 | It is s->free_code that says which alternative to use. */ | |
105 | ||
106 | void | |
fba45db2 | 107 | free_symtab (register struct symtab *s) |
c906108c SS |
108 | { |
109 | register int i, n; | |
110 | register struct blockvector *bv; | |
111 | ||
112 | switch (s->free_code) | |
113 | { | |
114 | case free_nothing: | |
115 | /* All the contents are part of a big block of memory (an obstack), | |
c5aa993b JM |
116 | and some other symtab is in charge of freeing that block. |
117 | Therefore, do nothing. */ | |
c906108c SS |
118 | break; |
119 | ||
120 | case free_contents: | |
121 | /* Here all the contents were malloc'ed structure by structure | |
c5aa993b | 122 | and must be freed that way. */ |
c906108c SS |
123 | /* First free the blocks (and their symbols. */ |
124 | bv = BLOCKVECTOR (s); | |
125 | n = BLOCKVECTOR_NBLOCKS (bv); | |
126 | for (i = 0; i < n; i++) | |
c5aa993b | 127 | free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i)); |
c906108c | 128 | /* Free the blockvector itself. */ |
aac7f4ea | 129 | xmfree (s->objfile->md, (PTR) bv); |
c906108c | 130 | /* Also free the linetable. */ |
c5aa993b | 131 | |
c906108c SS |
132 | case free_linetable: |
133 | /* Everything will be freed either by our `free_ptr' | |
c5aa993b JM |
134 | or by some other symtab, except for our linetable. |
135 | Free that now. */ | |
c906108c | 136 | if (LINETABLE (s)) |
aac7f4ea | 137 | xmfree (s->objfile->md, (PTR) LINETABLE (s)); |
c906108c SS |
138 | break; |
139 | } | |
140 | ||
141 | /* If there is a single block of memory to free, free it. */ | |
c5aa993b | 142 | if (s->free_ptr != NULL) |
aac7f4ea | 143 | xmfree (s->objfile->md, s->free_ptr); |
c906108c SS |
144 | |
145 | /* Free source-related stuff */ | |
c5aa993b | 146 | if (s->line_charpos != NULL) |
aac7f4ea | 147 | xmfree (s->objfile->md, (PTR) s->line_charpos); |
c5aa993b | 148 | if (s->fullname != NULL) |
aac7f4ea | 149 | xmfree (s->objfile->md, s->fullname); |
c5aa993b | 150 | if (s->debugformat != NULL) |
aac7f4ea AC |
151 | xmfree (s->objfile->md, s->debugformat); |
152 | xmfree (s->objfile->md, (PTR) s); | |
c906108c SS |
153 | } |
154 | ||
c906108c | 155 | void |
fba45db2 | 156 | print_symbol_bcache_statistics (void) |
c906108c SS |
157 | { |
158 | struct objfile *objfile; | |
159 | ||
160 | immediate_quit++; | |
161 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
162 | { |
163 | printf_filtered ("Byte cache statistics for '%s':\n", objfile->name); | |
164 | print_bcache_statistics (&objfile->psymbol_cache, "partial symbol cache"); | |
165 | } | |
c906108c SS |
166 | immediate_quit--; |
167 | } | |
168 | ||
169 | void | |
fba45db2 | 170 | print_objfile_statistics (void) |
c906108c SS |
171 | { |
172 | struct objfile *objfile; | |
173 | ||
174 | immediate_quit++; | |
175 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
176 | { |
177 | printf_filtered ("Statistics for '%s':\n", objfile->name); | |
178 | if (OBJSTAT (objfile, n_stabs) > 0) | |
179 | printf_filtered (" Number of \"stab\" symbols read: %d\n", | |
180 | OBJSTAT (objfile, n_stabs)); | |
181 | if (OBJSTAT (objfile, n_minsyms) > 0) | |
182 | printf_filtered (" Number of \"minimal\" symbols read: %d\n", | |
183 | OBJSTAT (objfile, n_minsyms)); | |
184 | if (OBJSTAT (objfile, n_psyms) > 0) | |
185 | printf_filtered (" Number of \"partial\" symbols read: %d\n", | |
186 | OBJSTAT (objfile, n_psyms)); | |
187 | if (OBJSTAT (objfile, n_syms) > 0) | |
188 | printf_filtered (" Number of \"full\" symbols read: %d\n", | |
189 | OBJSTAT (objfile, n_syms)); | |
190 | if (OBJSTAT (objfile, n_types) > 0) | |
191 | printf_filtered (" Number of \"types\" defined: %d\n", | |
192 | OBJSTAT (objfile, n_types)); | |
193 | if (OBJSTAT (objfile, sz_strtab) > 0) | |
194 | printf_filtered (" Space used by a.out string tables: %d\n", | |
195 | OBJSTAT (objfile, sz_strtab)); | |
196 | printf_filtered (" Total memory used for psymbol obstack: %d\n", | |
197 | obstack_memory_used (&objfile->psymbol_obstack)); | |
198 | printf_filtered (" Total memory used for psymbol cache: %d\n", | |
199 | obstack_memory_used (&objfile->psymbol_cache.cache)); | |
99d9066e JB |
200 | printf_filtered (" Total memory used for macro cache: %d\n", |
201 | obstack_memory_used (&objfile->macro_cache.cache)); | |
c5aa993b JM |
202 | printf_filtered (" Total memory used for symbol obstack: %d\n", |
203 | obstack_memory_used (&objfile->symbol_obstack)); | |
204 | printf_filtered (" Total memory used for type obstack: %d\n", | |
205 | obstack_memory_used (&objfile->type_obstack)); | |
206 | } | |
c906108c SS |
207 | immediate_quit--; |
208 | } | |
209 | ||
c5aa993b | 210 | static void |
fba45db2 | 211 | dump_objfile (struct objfile *objfile) |
c906108c SS |
212 | { |
213 | struct symtab *symtab; | |
214 | struct partial_symtab *psymtab; | |
215 | ||
c5aa993b | 216 | printf_filtered ("\nObject file %s: ", objfile->name); |
c906108c | 217 | printf_filtered ("Objfile at "); |
d4f3574e | 218 | gdb_print_host_address (objfile, gdb_stdout); |
c906108c | 219 | printf_filtered (", bfd at "); |
d4f3574e | 220 | gdb_print_host_address (objfile->obfd, gdb_stdout); |
c906108c SS |
221 | printf_filtered (", %d minsyms\n\n", |
222 | objfile->minimal_symbol_count); | |
223 | ||
c5aa993b | 224 | if (objfile->psymtabs) |
c906108c SS |
225 | { |
226 | printf_filtered ("Psymtabs:\n"); | |
c5aa993b | 227 | for (psymtab = objfile->psymtabs; |
c906108c | 228 | psymtab != NULL; |
c5aa993b | 229 | psymtab = psymtab->next) |
c906108c SS |
230 | { |
231 | printf_filtered ("%s at ", | |
c5aa993b | 232 | psymtab->filename); |
d4f3574e | 233 | gdb_print_host_address (psymtab, gdb_stdout); |
c906108c | 234 | printf_filtered (", "); |
c5aa993b | 235 | if (psymtab->objfile != objfile) |
c906108c SS |
236 | { |
237 | printf_filtered ("NOT ON CHAIN! "); | |
238 | } | |
239 | wrap_here (" "); | |
240 | } | |
241 | printf_filtered ("\n\n"); | |
242 | } | |
243 | ||
c5aa993b | 244 | if (objfile->symtabs) |
c906108c SS |
245 | { |
246 | printf_filtered ("Symtabs:\n"); | |
c5aa993b | 247 | for (symtab = objfile->symtabs; |
c906108c SS |
248 | symtab != NULL; |
249 | symtab = symtab->next) | |
250 | { | |
c5aa993b | 251 | printf_filtered ("%s at ", symtab->filename); |
d4f3574e | 252 | gdb_print_host_address (symtab, gdb_stdout); |
c906108c | 253 | printf_filtered (", "); |
c5aa993b | 254 | if (symtab->objfile != objfile) |
c906108c SS |
255 | { |
256 | printf_filtered ("NOT ON CHAIN! "); | |
257 | } | |
258 | wrap_here (" "); | |
259 | } | |
260 | printf_filtered ("\n\n"); | |
261 | } | |
262 | } | |
263 | ||
264 | /* Print minimal symbols from this objfile. */ | |
c5aa993b JM |
265 | |
266 | static void | |
fba45db2 | 267 | dump_msymbols (struct objfile *objfile, struct ui_file *outfile) |
c906108c SS |
268 | { |
269 | struct minimal_symbol *msymbol; | |
270 | int index; | |
271 | char ms_type; | |
c5aa993b JM |
272 | |
273 | fprintf_filtered (outfile, "\nObject file %s:\n\n", objfile->name); | |
274 | if (objfile->minimal_symbol_count == 0) | |
c906108c SS |
275 | { |
276 | fprintf_filtered (outfile, "No minimal symbols found.\n"); | |
277 | return; | |
278 | } | |
c5aa993b | 279 | for (index = 0, msymbol = objfile->msymbols; |
c906108c SS |
280 | SYMBOL_NAME (msymbol) != NULL; msymbol++, index++) |
281 | { | |
c5aa993b | 282 | switch (msymbol->type) |
c906108c | 283 | { |
c5aa993b JM |
284 | case mst_unknown: |
285 | ms_type = 'u'; | |
286 | break; | |
287 | case mst_text: | |
288 | ms_type = 'T'; | |
289 | break; | |
290 | case mst_solib_trampoline: | |
291 | ms_type = 'S'; | |
292 | break; | |
293 | case mst_data: | |
294 | ms_type = 'D'; | |
295 | break; | |
296 | case mst_bss: | |
297 | ms_type = 'B'; | |
298 | break; | |
299 | case mst_abs: | |
300 | ms_type = 'A'; | |
301 | break; | |
302 | case mst_file_text: | |
303 | ms_type = 't'; | |
304 | break; | |
305 | case mst_file_data: | |
306 | ms_type = 'd'; | |
307 | break; | |
308 | case mst_file_bss: | |
309 | ms_type = 'b'; | |
310 | break; | |
311 | default: | |
312 | ms_type = '?'; | |
313 | break; | |
c906108c SS |
314 | } |
315 | fprintf_filtered (outfile, "[%2d] %c ", index, ms_type); | |
316 | print_address_numeric (SYMBOL_VALUE_ADDRESS (msymbol), 1, outfile); | |
317 | fprintf_filtered (outfile, " %s", SYMBOL_NAME (msymbol)); | |
318 | if (SYMBOL_BFD_SECTION (msymbol)) | |
319 | fprintf_filtered (outfile, " section %s", | |
320 | bfd_section_name (objfile->obfd, | |
321 | SYMBOL_BFD_SECTION (msymbol))); | |
322 | if (SYMBOL_DEMANGLED_NAME (msymbol) != NULL) | |
323 | { | |
324 | fprintf_filtered (outfile, " %s", SYMBOL_DEMANGLED_NAME (msymbol)); | |
325 | } | |
326 | #ifdef SOFUN_ADDRESS_MAYBE_MISSING | |
327 | if (msymbol->filename) | |
328 | fprintf_filtered (outfile, " %s", msymbol->filename); | |
329 | #endif | |
330 | fputs_filtered ("\n", outfile); | |
331 | } | |
c5aa993b | 332 | if (objfile->minimal_symbol_count != index) |
c906108c SS |
333 | { |
334 | warning ("internal error: minimal symbol count %d != %d", | |
c5aa993b | 335 | objfile->minimal_symbol_count, index); |
c906108c SS |
336 | } |
337 | fprintf_filtered (outfile, "\n"); | |
338 | } | |
339 | ||
340 | static void | |
fba45db2 KB |
341 | dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab, |
342 | struct ui_file *outfile) | |
c906108c SS |
343 | { |
344 | int i; | |
345 | ||
346 | fprintf_filtered (outfile, "\nPartial symtab for source file %s ", | |
c5aa993b | 347 | psymtab->filename); |
c906108c | 348 | fprintf_filtered (outfile, "(object "); |
d4f3574e | 349 | gdb_print_host_address (psymtab, outfile); |
c906108c SS |
350 | fprintf_filtered (outfile, ")\n\n"); |
351 | fprintf_unfiltered (outfile, " Read from object file %s (", | |
c5aa993b | 352 | objfile->name); |
d4f3574e | 353 | gdb_print_host_address (objfile, outfile); |
c906108c SS |
354 | fprintf_unfiltered (outfile, ")\n"); |
355 | ||
c5aa993b | 356 | if (psymtab->readin) |
c906108c SS |
357 | { |
358 | fprintf_filtered (outfile, | |
c5aa993b | 359 | " Full symtab was read (at "); |
d4f3574e | 360 | gdb_print_host_address (psymtab->symtab, outfile); |
c906108c | 361 | fprintf_filtered (outfile, " by function at "); |
d4f3574e | 362 | gdb_print_host_address ((PTR) psymtab->read_symtab, outfile); |
c906108c SS |
363 | fprintf_filtered (outfile, ")\n"); |
364 | } | |
365 | ||
366 | fprintf_filtered (outfile, " Relocate symbols by "); | |
367 | for (i = 0; i < psymtab->objfile->num_sections; ++i) | |
368 | { | |
369 | if (i != 0) | |
370 | fprintf_filtered (outfile, ", "); | |
371 | wrap_here (" "); | |
372 | print_address_numeric (ANOFFSET (psymtab->section_offsets, i), | |
373 | 1, | |
374 | outfile); | |
375 | } | |
376 | fprintf_filtered (outfile, "\n"); | |
377 | ||
378 | fprintf_filtered (outfile, " Symbols cover text addresses "); | |
379 | print_address_numeric (psymtab->textlow, 1, outfile); | |
380 | fprintf_filtered (outfile, "-"); | |
381 | print_address_numeric (psymtab->texthigh, 1, outfile); | |
382 | fprintf_filtered (outfile, "\n"); | |
383 | fprintf_filtered (outfile, " Depends on %d other partial symtabs.\n", | |
c5aa993b JM |
384 | psymtab->number_of_dependencies); |
385 | for (i = 0; i < psymtab->number_of_dependencies; i++) | |
c906108c SS |
386 | { |
387 | fprintf_filtered (outfile, " %d ", i); | |
d4f3574e | 388 | gdb_print_host_address (psymtab->dependencies[i], outfile); |
c906108c | 389 | fprintf_filtered (outfile, " %s\n", |
c5aa993b | 390 | psymtab->dependencies[i]->filename); |
c906108c | 391 | } |
c5aa993b | 392 | if (psymtab->n_global_syms > 0) |
c906108c | 393 | { |
c5aa993b JM |
394 | print_partial_symbols (objfile->global_psymbols.list |
395 | + psymtab->globals_offset, | |
396 | psymtab->n_global_syms, "Global", outfile); | |
c906108c | 397 | } |
c5aa993b | 398 | if (psymtab->n_static_syms > 0) |
c906108c | 399 | { |
c5aa993b JM |
400 | print_partial_symbols (objfile->static_psymbols.list |
401 | + psymtab->statics_offset, | |
402 | psymtab->n_static_syms, "Static", outfile); | |
c906108c SS |
403 | } |
404 | fprintf_filtered (outfile, "\n"); | |
405 | } | |
406 | ||
c5aa993b | 407 | static void |
fba45db2 KB |
408 | dump_symtab (struct objfile *objfile, struct symtab *symtab, |
409 | struct ui_file *outfile) | |
c906108c SS |
410 | { |
411 | register int i, j; | |
412 | int len, blen; | |
413 | register struct linetable *l; | |
414 | struct blockvector *bv; | |
e88c90f2 | 415 | struct symbol *sym; |
c906108c SS |
416 | register struct block *b; |
417 | int depth; | |
418 | ||
419 | fprintf_filtered (outfile, "\nSymtab for file %s\n", symtab->filename); | |
420 | if (symtab->dirname) | |
421 | fprintf_filtered (outfile, "Compilation directory is %s\n", | |
422 | symtab->dirname); | |
423 | fprintf_filtered (outfile, "Read from object file %s (", objfile->name); | |
d4f3574e | 424 | gdb_print_host_address (objfile, outfile); |
c906108c SS |
425 | fprintf_filtered (outfile, ")\n"); |
426 | fprintf_filtered (outfile, "Language: %s\n", language_str (symtab->language)); | |
427 | ||
428 | /* First print the line table. */ | |
429 | l = LINETABLE (symtab); | |
430 | if (l) | |
431 | { | |
432 | fprintf_filtered (outfile, "\nLine table:\n\n"); | |
433 | len = l->nitems; | |
434 | for (i = 0; i < len; i++) | |
435 | { | |
436 | fprintf_filtered (outfile, " line %d at ", l->item[i].line); | |
437 | print_address_numeric (l->item[i].pc, 1, outfile); | |
438 | fprintf_filtered (outfile, "\n"); | |
439 | } | |
440 | } | |
441 | /* Now print the block info, but only for primary symtabs since we will | |
442 | print lots of duplicate info otherwise. */ | |
c5aa993b | 443 | if (symtab->primary) |
c906108c SS |
444 | { |
445 | fprintf_filtered (outfile, "\nBlockvector:\n\n"); | |
446 | bv = BLOCKVECTOR (symtab); | |
447 | len = BLOCKVECTOR_NBLOCKS (bv); | |
448 | for (i = 0; i < len; i++) | |
449 | { | |
450 | b = BLOCKVECTOR_BLOCK (bv, i); | |
451 | depth = block_depth (b) * 2; | |
452 | print_spaces (depth, outfile); | |
453 | fprintf_filtered (outfile, "block #%03d, object at ", i); | |
d4f3574e | 454 | gdb_print_host_address (b, outfile); |
c906108c SS |
455 | if (BLOCK_SUPERBLOCK (b)) |
456 | { | |
457 | fprintf_filtered (outfile, " under "); | |
d4f3574e | 458 | gdb_print_host_address (BLOCK_SUPERBLOCK (b), outfile); |
c906108c SS |
459 | } |
460 | blen = BLOCK_NSYMS (b); | |
461 | fprintf_filtered (outfile, ", %d syms in ", blen); | |
462 | print_address_numeric (BLOCK_START (b), 1, outfile); | |
463 | fprintf_filtered (outfile, ".."); | |
464 | print_address_numeric (BLOCK_END (b), 1, outfile); | |
465 | if (BLOCK_FUNCTION (b)) | |
466 | { | |
467 | fprintf_filtered (outfile, ", function %s", SYMBOL_NAME (BLOCK_FUNCTION (b))); | |
468 | if (SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b)) != NULL) | |
469 | { | |
470 | fprintf_filtered (outfile, ", %s", | |
c5aa993b | 471 | SYMBOL_DEMANGLED_NAME (BLOCK_FUNCTION (b))); |
c906108c SS |
472 | } |
473 | } | |
c5aa993b JM |
474 | if (BLOCK_GCC_COMPILED (b)) |
475 | fprintf_filtered (outfile, ", compiled with gcc%d", BLOCK_GCC_COMPILED (b)); | |
c906108c | 476 | fprintf_filtered (outfile, "\n"); |
e88c90f2 DJ |
477 | /* Now print each symbol in this block. */ |
478 | /* FIXMED: Sort? */ | |
479 | ALL_BLOCK_SYMBOLS (b, j, sym) | |
c906108c SS |
480 | { |
481 | struct print_symbol_args s; | |
e88c90f2 | 482 | s.symbol = sym; |
c906108c SS |
483 | s.depth = depth + 1; |
484 | s.outfile = outfile; | |
485 | catch_errors (print_symbol, &s, "Error printing symbol:\n", | |
486 | RETURN_MASK_ALL); | |
487 | } | |
488 | } | |
489 | fprintf_filtered (outfile, "\n"); | |
490 | } | |
491 | else | |
492 | { | |
493 | fprintf_filtered (outfile, "\nBlockvector same as previous symtab\n\n"); | |
494 | } | |
495 | } | |
496 | ||
497 | void | |
fba45db2 | 498 | maintenance_print_symbols (char *args, int from_tty) |
c906108c SS |
499 | { |
500 | char **argv; | |
d9fcf2fb | 501 | struct ui_file *outfile; |
c906108c SS |
502 | struct cleanup *cleanups; |
503 | char *symname = NULL; | |
504 | char *filename = DEV_TTY; | |
505 | struct objfile *objfile; | |
506 | struct symtab *s; | |
507 | ||
508 | dont_repeat (); | |
509 | ||
510 | if (args == NULL) | |
511 | { | |
512 | error ("\ | |
513 | Arguments missing: an output file name and an optional symbol file name"); | |
514 | } | |
515 | else if ((argv = buildargv (args)) == NULL) | |
516 | { | |
517 | nomem (0); | |
518 | } | |
7a292a7a | 519 | cleanups = make_cleanup_freeargv (argv); |
c906108c SS |
520 | |
521 | if (argv[0] != NULL) | |
522 | { | |
523 | filename = argv[0]; | |
524 | /* If a second arg is supplied, it is a source file name to match on */ | |
525 | if (argv[1] != NULL) | |
526 | { | |
527 | symname = argv[1]; | |
528 | } | |
529 | } | |
530 | ||
531 | filename = tilde_expand (filename); | |
b8c9b27d | 532 | make_cleanup (xfree, filename); |
c5aa993b | 533 | |
c906108c SS |
534 | outfile = gdb_fopen (filename, FOPEN_WT); |
535 | if (outfile == 0) | |
536 | perror_with_name (filename); | |
d9fcf2fb | 537 | make_cleanup_ui_file_delete (outfile); |
c906108c SS |
538 | |
539 | immediate_quit++; | |
540 | ALL_SYMTABS (objfile, s) | |
c5aa993b JM |
541 | if (symname == NULL || (STREQ (symname, s->filename))) |
542 | dump_symtab (objfile, s, outfile); | |
c906108c SS |
543 | immediate_quit--; |
544 | do_cleanups (cleanups); | |
545 | } | |
546 | ||
547 | /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how | |
548 | far to indent. ARGS is really a struct print_symbol_args *, but is | |
549 | declared as char * to get it past catch_errors. Returns 0 for error, | |
550 | 1 for success. */ | |
551 | ||
552 | static int | |
fba45db2 | 553 | print_symbol (PTR args) |
c906108c | 554 | { |
c5aa993b JM |
555 | struct symbol *symbol = ((struct print_symbol_args *) args)->symbol; |
556 | int depth = ((struct print_symbol_args *) args)->depth; | |
d9fcf2fb | 557 | struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile; |
c906108c SS |
558 | |
559 | print_spaces (depth, outfile); | |
560 | if (SYMBOL_NAMESPACE (symbol) == LABEL_NAMESPACE) | |
561 | { | |
562 | fprintf_filtered (outfile, "label %s at ", SYMBOL_SOURCE_NAME (symbol)); | |
563 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); | |
564 | if (SYMBOL_BFD_SECTION (symbol)) | |
565 | fprintf_filtered (outfile, " section %s\n", | |
c5aa993b JM |
566 | bfd_section_name (SYMBOL_BFD_SECTION (symbol)->owner, |
567 | SYMBOL_BFD_SECTION (symbol))); | |
c906108c SS |
568 | else |
569 | fprintf_filtered (outfile, "\n"); | |
570 | return 1; | |
571 | } | |
572 | if (SYMBOL_NAMESPACE (symbol) == STRUCT_NAMESPACE) | |
573 | { | |
574 | if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol))) | |
575 | { | |
576 | LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth); | |
577 | } | |
578 | else | |
579 | { | |
580 | fprintf_filtered (outfile, "%s %s = ", | |
c5aa993b JM |
581 | (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_ENUM |
582 | ? "enum" | |
583 | : (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT | |
584 | ? "struct" : "union")), | |
585 | SYMBOL_NAME (symbol)); | |
c906108c SS |
586 | LA_PRINT_TYPE (SYMBOL_TYPE (symbol), "", outfile, 1, depth); |
587 | } | |
588 | fprintf_filtered (outfile, ";\n"); | |
589 | } | |
590 | else | |
591 | { | |
592 | if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF) | |
593 | fprintf_filtered (outfile, "typedef "); | |
594 | if (SYMBOL_TYPE (symbol)) | |
595 | { | |
596 | /* Print details of types, except for enums where it's clutter. */ | |
597 | LA_PRINT_TYPE (SYMBOL_TYPE (symbol), SYMBOL_SOURCE_NAME (symbol), | |
598 | outfile, | |
599 | TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM, | |
600 | depth); | |
601 | fprintf_filtered (outfile, "; "); | |
602 | } | |
603 | else | |
604 | fprintf_filtered (outfile, "%s ", SYMBOL_SOURCE_NAME (symbol)); | |
605 | ||
606 | switch (SYMBOL_CLASS (symbol)) | |
607 | { | |
608 | case LOC_CONST: | |
609 | fprintf_filtered (outfile, "const %ld (0x%lx)", | |
610 | SYMBOL_VALUE (symbol), | |
611 | SYMBOL_VALUE (symbol)); | |
612 | break; | |
613 | ||
614 | case LOC_CONST_BYTES: | |
615 | { | |
616 | unsigned i; | |
617 | struct type *type = check_typedef (SYMBOL_TYPE (symbol)); | |
618 | fprintf_filtered (outfile, "const %u hex bytes:", | |
619 | TYPE_LENGTH (type)); | |
620 | for (i = 0; i < TYPE_LENGTH (type); i++) | |
621 | fprintf_filtered (outfile, " %02x", | |
c5aa993b | 622 | (unsigned) SYMBOL_VALUE_BYTES (symbol)[i]); |
c906108c SS |
623 | } |
624 | break; | |
625 | ||
626 | case LOC_STATIC: | |
627 | fprintf_filtered (outfile, "static at "); | |
c5aa993b | 628 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); |
c906108c SS |
629 | if (SYMBOL_BFD_SECTION (symbol)) |
630 | fprintf_filtered (outfile, " section %s", | |
631 | bfd_section_name | |
632 | (SYMBOL_BFD_SECTION (symbol)->owner, | |
633 | SYMBOL_BFD_SECTION (symbol))); | |
634 | break; | |
635 | ||
636 | case LOC_INDIRECT: | |
637 | fprintf_filtered (outfile, "extern global at *("); | |
c5aa993b | 638 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); |
c906108c SS |
639 | fprintf_filtered (outfile, "),"); |
640 | break; | |
641 | ||
642 | case LOC_REGISTER: | |
643 | fprintf_filtered (outfile, "register %ld", SYMBOL_VALUE (symbol)); | |
644 | break; | |
645 | ||
646 | case LOC_ARG: | |
647 | fprintf_filtered (outfile, "arg at offset 0x%lx", | |
648 | SYMBOL_VALUE (symbol)); | |
649 | break; | |
650 | ||
651 | case LOC_LOCAL_ARG: | |
652 | fprintf_filtered (outfile, "arg at offset 0x%lx from fp", | |
c5aa993b | 653 | SYMBOL_VALUE (symbol)); |
c906108c SS |
654 | break; |
655 | ||
656 | case LOC_REF_ARG: | |
657 | fprintf_filtered (outfile, "reference arg at 0x%lx", SYMBOL_VALUE (symbol)); | |
658 | break; | |
659 | ||
660 | case LOC_REGPARM: | |
661 | fprintf_filtered (outfile, "parameter register %ld", SYMBOL_VALUE (symbol)); | |
662 | break; | |
663 | ||
664 | case LOC_REGPARM_ADDR: | |
665 | fprintf_filtered (outfile, "address parameter register %ld", SYMBOL_VALUE (symbol)); | |
666 | break; | |
667 | ||
668 | case LOC_LOCAL: | |
669 | fprintf_filtered (outfile, "local at offset 0x%lx", | |
670 | SYMBOL_VALUE (symbol)); | |
671 | break; | |
672 | ||
673 | case LOC_BASEREG: | |
674 | fprintf_filtered (outfile, "local at 0x%lx from register %d", | |
c5aa993b | 675 | SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); |
c906108c SS |
676 | break; |
677 | ||
678 | case LOC_BASEREG_ARG: | |
679 | fprintf_filtered (outfile, "arg at 0x%lx from register %d", | |
c5aa993b | 680 | SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); |
c906108c SS |
681 | break; |
682 | ||
683 | case LOC_TYPEDEF: | |
684 | break; | |
685 | ||
686 | case LOC_LABEL: | |
687 | fprintf_filtered (outfile, "label at "); | |
688 | print_address_numeric (SYMBOL_VALUE_ADDRESS (symbol), 1, outfile); | |
689 | if (SYMBOL_BFD_SECTION (symbol)) | |
690 | fprintf_filtered (outfile, " section %s", | |
691 | bfd_section_name | |
692 | (SYMBOL_BFD_SECTION (symbol)->owner, | |
693 | SYMBOL_BFD_SECTION (symbol))); | |
694 | break; | |
695 | ||
696 | case LOC_BLOCK: | |
697 | fprintf_filtered (outfile, "block object "); | |
d4f3574e | 698 | gdb_print_host_address (SYMBOL_BLOCK_VALUE (symbol), outfile); |
c906108c SS |
699 | fprintf_filtered (outfile, ", "); |
700 | print_address_numeric (BLOCK_START (SYMBOL_BLOCK_VALUE (symbol)), | |
701 | 1, | |
702 | outfile); | |
703 | fprintf_filtered (outfile, ".."); | |
704 | print_address_numeric (BLOCK_END (SYMBOL_BLOCK_VALUE (symbol)), | |
705 | 1, | |
706 | outfile); | |
707 | if (SYMBOL_BFD_SECTION (symbol)) | |
708 | fprintf_filtered (outfile, " section %s", | |
709 | bfd_section_name | |
710 | (SYMBOL_BFD_SECTION (symbol)->owner, | |
711 | SYMBOL_BFD_SECTION (symbol))); | |
712 | break; | |
713 | ||
714 | case LOC_UNRESOLVED: | |
715 | fprintf_filtered (outfile, "unresolved"); | |
716 | break; | |
717 | ||
718 | case LOC_OPTIMIZED_OUT: | |
719 | fprintf_filtered (outfile, "optimized out"); | |
720 | break; | |
721 | ||
c5aa993b | 722 | default: |
c906108c SS |
723 | fprintf_filtered (outfile, "botched symbol class %x", |
724 | SYMBOL_CLASS (symbol)); | |
725 | break; | |
726 | } | |
727 | } | |
728 | fprintf_filtered (outfile, "\n"); | |
729 | return 1; | |
730 | } | |
731 | ||
732 | void | |
fba45db2 | 733 | maintenance_print_psymbols (char *args, int from_tty) |
c906108c SS |
734 | { |
735 | char **argv; | |
d9fcf2fb | 736 | struct ui_file *outfile; |
c906108c SS |
737 | struct cleanup *cleanups; |
738 | char *symname = NULL; | |
739 | char *filename = DEV_TTY; | |
740 | struct objfile *objfile; | |
741 | struct partial_symtab *ps; | |
742 | ||
743 | dont_repeat (); | |
744 | ||
745 | if (args == NULL) | |
746 | { | |
747 | error ("print-psymbols takes an output file name and optional symbol file name"); | |
748 | } | |
749 | else if ((argv = buildargv (args)) == NULL) | |
750 | { | |
751 | nomem (0); | |
752 | } | |
7a292a7a | 753 | cleanups = make_cleanup_freeargv (argv); |
c906108c SS |
754 | |
755 | if (argv[0] != NULL) | |
756 | { | |
757 | filename = argv[0]; | |
758 | /* If a second arg is supplied, it is a source file name to match on */ | |
759 | if (argv[1] != NULL) | |
760 | { | |
761 | symname = argv[1]; | |
762 | } | |
763 | } | |
764 | ||
765 | filename = tilde_expand (filename); | |
b8c9b27d | 766 | make_cleanup (xfree, filename); |
c5aa993b | 767 | |
c906108c SS |
768 | outfile = gdb_fopen (filename, FOPEN_WT); |
769 | if (outfile == 0) | |
770 | perror_with_name (filename); | |
d9fcf2fb | 771 | make_cleanup_ui_file_delete (outfile); |
c906108c SS |
772 | |
773 | immediate_quit++; | |
774 | ALL_PSYMTABS (objfile, ps) | |
c5aa993b JM |
775 | if (symname == NULL || (STREQ (symname, ps->filename))) |
776 | dump_psymtab (objfile, ps, outfile); | |
c906108c SS |
777 | immediate_quit--; |
778 | do_cleanups (cleanups); | |
779 | } | |
780 | ||
781 | static void | |
fba45db2 KB |
782 | print_partial_symbols (struct partial_symbol **p, int count, char *what, |
783 | struct ui_file *outfile) | |
c906108c SS |
784 | { |
785 | fprintf_filtered (outfile, " %s partial symbols:\n", what); | |
786 | while (count-- > 0) | |
787 | { | |
c5aa993b | 788 | fprintf_filtered (outfile, " `%s'", SYMBOL_NAME (*p)); |
c906108c SS |
789 | if (SYMBOL_DEMANGLED_NAME (*p) != NULL) |
790 | { | |
791 | fprintf_filtered (outfile, " `%s'", SYMBOL_DEMANGLED_NAME (*p)); | |
792 | } | |
793 | fputs_filtered (", ", outfile); | |
794 | switch (SYMBOL_NAMESPACE (*p)) | |
795 | { | |
796 | case UNDEF_NAMESPACE: | |
797 | fputs_filtered ("undefined namespace, ", outfile); | |
798 | break; | |
799 | case VAR_NAMESPACE: | |
800 | /* This is the usual thing -- don't print it */ | |
801 | break; | |
802 | case STRUCT_NAMESPACE: | |
803 | fputs_filtered ("struct namespace, ", outfile); | |
804 | break; | |
805 | case LABEL_NAMESPACE: | |
806 | fputs_filtered ("label namespace, ", outfile); | |
807 | break; | |
808 | default: | |
809 | fputs_filtered ("<invalid namespace>, ", outfile); | |
810 | break; | |
811 | } | |
812 | switch (SYMBOL_CLASS (*p)) | |
813 | { | |
814 | case LOC_UNDEF: | |
815 | fputs_filtered ("undefined", outfile); | |
816 | break; | |
817 | case LOC_CONST: | |
818 | fputs_filtered ("constant int", outfile); | |
819 | break; | |
820 | case LOC_STATIC: | |
821 | fputs_filtered ("static", outfile); | |
822 | break; | |
823 | case LOC_INDIRECT: | |
824 | fputs_filtered ("extern global", outfile); | |
825 | break; | |
826 | case LOC_REGISTER: | |
827 | fputs_filtered ("register", outfile); | |
828 | break; | |
829 | case LOC_ARG: | |
830 | fputs_filtered ("pass by value", outfile); | |
831 | break; | |
832 | case LOC_REF_ARG: | |
833 | fputs_filtered ("pass by reference", outfile); | |
834 | break; | |
835 | case LOC_REGPARM: | |
836 | fputs_filtered ("register parameter", outfile); | |
837 | break; | |
838 | case LOC_REGPARM_ADDR: | |
839 | fputs_filtered ("register address parameter", outfile); | |
840 | break; | |
841 | case LOC_LOCAL: | |
842 | fputs_filtered ("stack parameter", outfile); | |
843 | break; | |
844 | case LOC_TYPEDEF: | |
845 | fputs_filtered ("type", outfile); | |
846 | break; | |
847 | case LOC_LABEL: | |
848 | fputs_filtered ("label", outfile); | |
849 | break; | |
850 | case LOC_BLOCK: | |
851 | fputs_filtered ("function", outfile); | |
852 | break; | |
853 | case LOC_CONST_BYTES: | |
854 | fputs_filtered ("constant bytes", outfile); | |
855 | break; | |
856 | case LOC_LOCAL_ARG: | |
857 | fputs_filtered ("shuffled arg", outfile); | |
858 | break; | |
859 | case LOC_UNRESOLVED: | |
860 | fputs_filtered ("unresolved", outfile); | |
861 | break; | |
862 | case LOC_OPTIMIZED_OUT: | |
863 | fputs_filtered ("optimized out", outfile); | |
864 | break; | |
865 | default: | |
866 | fputs_filtered ("<invalid location>", outfile); | |
867 | break; | |
868 | } | |
869 | fputs_filtered (", ", outfile); | |
870 | print_address_numeric (SYMBOL_VALUE_ADDRESS (*p), 1, outfile); | |
871 | fprintf_filtered (outfile, "\n"); | |
872 | p++; | |
873 | } | |
874 | } | |
875 | ||
876 | void | |
fba45db2 | 877 | maintenance_print_msymbols (char *args, int from_tty) |
c906108c SS |
878 | { |
879 | char **argv; | |
d9fcf2fb | 880 | struct ui_file *outfile; |
c906108c SS |
881 | struct cleanup *cleanups; |
882 | char *filename = DEV_TTY; | |
883 | char *symname = NULL; | |
884 | struct objfile *objfile; | |
885 | ||
886 | dont_repeat (); | |
887 | ||
888 | if (args == NULL) | |
889 | { | |
890 | error ("print-msymbols takes an output file name and optional symbol file name"); | |
891 | } | |
892 | else if ((argv = buildargv (args)) == NULL) | |
893 | { | |
894 | nomem (0); | |
895 | } | |
7a292a7a | 896 | cleanups = make_cleanup_freeargv (argv); |
c906108c SS |
897 | |
898 | if (argv[0] != NULL) | |
899 | { | |
900 | filename = argv[0]; | |
901 | /* If a second arg is supplied, it is a source file name to match on */ | |
902 | if (argv[1] != NULL) | |
903 | { | |
904 | symname = argv[1]; | |
905 | } | |
906 | } | |
907 | ||
908 | filename = tilde_expand (filename); | |
b8c9b27d | 909 | make_cleanup (xfree, filename); |
c5aa993b | 910 | |
c906108c SS |
911 | outfile = gdb_fopen (filename, FOPEN_WT); |
912 | if (outfile == 0) | |
913 | perror_with_name (filename); | |
d9fcf2fb | 914 | make_cleanup_ui_file_delete (outfile); |
c906108c SS |
915 | |
916 | immediate_quit++; | |
917 | ALL_OBJFILES (objfile) | |
c5aa993b JM |
918 | if (symname == NULL || (STREQ (symname, objfile->name))) |
919 | dump_msymbols (objfile, outfile); | |
c906108c SS |
920 | immediate_quit--; |
921 | fprintf_filtered (outfile, "\n\n"); | |
922 | do_cleanups (cleanups); | |
923 | } | |
924 | ||
925 | void | |
fba45db2 | 926 | maintenance_print_objfiles (char *ignore, int from_tty) |
c906108c SS |
927 | { |
928 | struct objfile *objfile; | |
929 | ||
930 | dont_repeat (); | |
931 | ||
932 | immediate_quit++; | |
933 | ALL_OBJFILES (objfile) | |
934 | dump_objfile (objfile); | |
935 | immediate_quit--; | |
936 | } | |
937 | ||
938 | /* Check consistency of psymtabs and symtabs. */ | |
939 | ||
940 | void | |
fba45db2 | 941 | maintenance_check_symtabs (char *ignore, int from_tty) |
c906108c SS |
942 | { |
943 | register struct symbol *sym; | |
944 | register struct partial_symbol **psym; | |
945 | register struct symtab *s = NULL; | |
946 | register struct partial_symtab *ps; | |
947 | struct blockvector *bv; | |
948 | register struct objfile *objfile; | |
949 | register struct block *b; | |
950 | int length; | |
951 | ||
952 | ALL_PSYMTABS (objfile, ps) | |
c5aa993b JM |
953 | { |
954 | s = PSYMTAB_TO_SYMTAB (ps); | |
955 | if (s == NULL) | |
956 | continue; | |
957 | bv = BLOCKVECTOR (s); | |
958 | b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK); | |
959 | psym = ps->objfile->static_psymbols.list + ps->statics_offset; | |
960 | length = ps->n_static_syms; | |
961 | while (length--) | |
962 | { | |
963 | sym = lookup_block_symbol (b, SYMBOL_NAME (*psym), | |
3121eff0 | 964 | NULL, SYMBOL_NAMESPACE (*psym)); |
c5aa993b JM |
965 | if (!sym) |
966 | { | |
967 | printf_filtered ("Static symbol `"); | |
968 | puts_filtered (SYMBOL_NAME (*psym)); | |
969 | printf_filtered ("' only found in "); | |
970 | puts_filtered (ps->filename); | |
971 | printf_filtered (" psymtab\n"); | |
972 | } | |
973 | psym++; | |
974 | } | |
975 | b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK); | |
976 | psym = ps->objfile->global_psymbols.list + ps->globals_offset; | |
977 | length = ps->n_global_syms; | |
978 | while (length--) | |
979 | { | |
980 | sym = lookup_block_symbol (b, SYMBOL_NAME (*psym), | |
3121eff0 | 981 | NULL, SYMBOL_NAMESPACE (*psym)); |
c5aa993b JM |
982 | if (!sym) |
983 | { | |
984 | printf_filtered ("Global symbol `"); | |
985 | puts_filtered (SYMBOL_NAME (*psym)); | |
986 | printf_filtered ("' only found in "); | |
987 | puts_filtered (ps->filename); | |
988 | printf_filtered (" psymtab\n"); | |
989 | } | |
990 | psym++; | |
991 | } | |
992 | if (ps->texthigh < ps->textlow) | |
993 | { | |
994 | printf_filtered ("Psymtab "); | |
995 | puts_filtered (ps->filename); | |
996 | printf_filtered (" covers bad range "); | |
997 | print_address_numeric (ps->textlow, 1, gdb_stdout); | |
998 | printf_filtered (" - "); | |
999 | print_address_numeric (ps->texthigh, 1, gdb_stdout); | |
1000 | printf_filtered ("\n"); | |
c906108c | 1001 | continue; |
c5aa993b JM |
1002 | } |
1003 | if (ps->texthigh == 0) | |
1004 | continue; | |
1005 | if (ps->textlow < BLOCK_START (b) || ps->texthigh > BLOCK_END (b)) | |
1006 | { | |
1007 | printf_filtered ("Psymtab "); | |
1008 | puts_filtered (ps->filename); | |
1009 | printf_filtered (" covers "); | |
1010 | print_address_numeric (ps->textlow, 1, gdb_stdout); | |
1011 | printf_filtered (" - "); | |
1012 | print_address_numeric (ps->texthigh, 1, gdb_stdout); | |
1013 | printf_filtered (" but symtab covers only "); | |
1014 | print_address_numeric (BLOCK_START (b), 1, gdb_stdout); | |
1015 | printf_filtered (" - "); | |
1016 | print_address_numeric (BLOCK_END (b), 1, gdb_stdout); | |
1017 | printf_filtered ("\n"); | |
1018 | } | |
1019 | } | |
c906108c | 1020 | } |
c906108c | 1021 | \f |
c5aa993b | 1022 | |
c906108c SS |
1023 | /* Return the nexting depth of a block within other blocks in its symtab. */ |
1024 | ||
1025 | static int | |
fba45db2 | 1026 | block_depth (struct block *block) |
c906108c SS |
1027 | { |
1028 | register int i = 0; | |
c5aa993b | 1029 | while ((block = BLOCK_SUPERBLOCK (block)) != NULL) |
c906108c SS |
1030 | { |
1031 | i++; | |
1032 | } | |
1033 | return i; | |
1034 | } | |
c906108c | 1035 | \f |
c5aa993b | 1036 | |
c906108c SS |
1037 | /* Increase the space allocated for LISTP, which is probably |
1038 | global_psymbols or static_psymbols. This space will eventually | |
1039 | be freed in free_objfile(). */ | |
1040 | ||
1041 | void | |
fba45db2 KB |
1042 | extend_psymbol_list (register struct psymbol_allocation_list *listp, |
1043 | struct objfile *objfile) | |
c906108c SS |
1044 | { |
1045 | int new_size; | |
1046 | if (listp->size == 0) | |
1047 | { | |
1048 | new_size = 255; | |
1049 | listp->list = (struct partial_symbol **) | |
c5aa993b | 1050 | xmmalloc (objfile->md, new_size * sizeof (struct partial_symbol *)); |
c906108c SS |
1051 | } |
1052 | else | |
1053 | { | |
1054 | new_size = listp->size * 2; | |
1055 | listp->list = (struct partial_symbol **) | |
c5aa993b | 1056 | xmrealloc (objfile->md, (char *) listp->list, |
c906108c SS |
1057 | new_size * sizeof (struct partial_symbol *)); |
1058 | } | |
1059 | /* Next assumes we only went one over. Should be good if | |
1060 | program works correctly */ | |
1061 | listp->next = listp->list + listp->size; | |
1062 | listp->size = new_size; | |
1063 | } | |
1064 | ||
1065 | ||
1066 | /* Do early runtime initializations. */ | |
1067 | void | |
fba45db2 | 1068 | _initialize_symmisc (void) |
c906108c | 1069 | { |
c5aa993b | 1070 | std_in = stdin; |
c906108c SS |
1071 | std_out = stdout; |
1072 | std_err = stderr; | |
1073 | } |