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