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