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