]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Do various things to symbol tables (other than lookup), for GDB. |
af5f3db6 | 2 | |
213516ef | 3 | Copyright (C) 1986-2023 Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b | 5 | This file is part of GDB. |
c906108c | 6 | |
c5aa993b JM |
7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 9 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 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 | 17 | You should have received a copy of the GNU General Public License |
a9762ec7 | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
19 | |
20 | #include "defs.h" | |
21 | #include "symtab.h" | |
22 | #include "gdbtypes.h" | |
23 | #include "bfd.h" | |
0ba1096a | 24 | #include "filenames.h" |
c906108c SS |
25 | #include "symfile.h" |
26 | #include "objfiles.h" | |
27 | #include "breakpoint.h" | |
28 | #include "command.h" | |
bf31fd38 | 29 | #include "gdbsupport/gdb_obstack.h" |
c906108c SS |
30 | #include "language.h" |
31 | #include "bcache.h" | |
fe898f56 | 32 | #include "block.h" |
d322d6d6 | 33 | #include "gdbsupport/gdb_regex.h" |
53ce3c39 | 34 | #include <sys/stat.h> |
de4f826b | 35 | #include "dictionary.h" |
79d43c61 | 36 | #include "typeprint.h" |
80480540 | 37 | #include "gdbcmd.h" |
05cba821 | 38 | #include "source.h" |
e0eac551 | 39 | #include "readline/tilde.h" |
92228a33 | 40 | #include <cli/cli-style.h> |
7904e961 | 41 | #include "gdbsupport/buildargv.h" |
c906108c | 42 | |
c906108c SS |
43 | /* Prototypes for local functions */ |
44 | ||
582942f4 | 45 | static int block_depth (const struct block *); |
c906108c | 46 | |
bf469271 PA |
47 | static void print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, |
48 | int depth, ui_file *outfile); | |
c906108c | 49 | \f |
c906108c | 50 | |
c906108c | 51 | void |
fba45db2 | 52 | print_objfile_statistics (void) |
c906108c | 53 | { |
c4f90d87 | 54 | int i, linetables, blockvectors; |
c906108c | 55 | |
94c93c35 TT |
56 | for (struct program_space *pspace : program_spaces) |
57 | for (objfile *objfile : pspace->objfiles ()) | |
58 | { | |
59 | QUIT; | |
6cb06a8c | 60 | gdb_printf (_("Statistics for '%s':\n"), objfile_name (objfile)); |
94c93c35 | 61 | if (OBJSTAT (objfile, n_stabs) > 0) |
6cb06a8c TT |
62 | gdb_printf (_(" Number of \"stab\" symbols read: %d\n"), |
63 | OBJSTAT (objfile, n_stabs)); | |
94c93c35 | 64 | if (objfile->per_bfd->n_minsyms > 0) |
6cb06a8c TT |
65 | gdb_printf (_(" Number of \"minimal\" symbols read: %d\n"), |
66 | objfile->per_bfd->n_minsyms); | |
94c93c35 | 67 | if (OBJSTAT (objfile, n_syms) > 0) |
6cb06a8c TT |
68 | gdb_printf (_(" Number of \"full\" symbols read: %d\n"), |
69 | OBJSTAT (objfile, n_syms)); | |
94c93c35 | 70 | if (OBJSTAT (objfile, n_types) > 0) |
6cb06a8c TT |
71 | gdb_printf (_(" Number of \"types\" defined: %d\n"), |
72 | OBJSTAT (objfile, n_types)); | |
4829711b | 73 | |
94c93c35 TT |
74 | i = linetables = 0; |
75 | for (compunit_symtab *cu : objfile->compunits ()) | |
76 | { | |
102cc235 | 77 | for (symtab *s : cu->filetabs ()) |
94c93c35 TT |
78 | { |
79 | i++; | |
5b607461 | 80 | if (s->linetable () != NULL) |
94c93c35 TT |
81 | linetables++; |
82 | } | |
83 | } | |
84 | blockvectors = std::distance (objfile->compunits ().begin (), | |
85 | objfile->compunits ().end ()); | |
6cb06a8c TT |
86 | gdb_printf (_(" Number of symbol tables: %d\n"), i); |
87 | gdb_printf (_(" Number of symbol tables with line tables: %d\n"), | |
88 | linetables); | |
89 | gdb_printf (_(" Number of symbol tables with blockvectors: %d\n"), | |
90 | blockvectors); | |
94c93c35 | 91 | |
4829711b TT |
92 | objfile->print_stats (false); |
93 | ||
94c93c35 | 94 | if (OBJSTAT (objfile, sz_strtab) > 0) |
6cb06a8c TT |
95 | gdb_printf (_(" Space used by string tables: %d\n"), |
96 | OBJSTAT (objfile, sz_strtab)); | |
97 | gdb_printf (_(" Total memory used for objfile obstack: %s\n"), | |
98 | pulongest (obstack_memory_used (&objfile | |
99 | ->objfile_obstack))); | |
100 | gdb_printf (_(" Total memory used for BFD obstack: %s\n"), | |
101 | pulongest (obstack_memory_used (&objfile->per_bfd | |
102 | ->storage_obstack))); | |
103 | ||
104 | gdb_printf (_(" Total memory used for string cache: %d\n"), | |
105 | objfile->per_bfd->string_cache.memory_used ()); | |
106 | gdb_printf (_("Byte cache statistics for '%s':\n"), | |
107 | objfile_name (objfile)); | |
4829711b TT |
108 | objfile->per_bfd->string_cache.print_statistics ("string cache"); |
109 | objfile->print_stats (true); | |
94c93c35 | 110 | } |
c906108c SS |
111 | } |
112 | ||
c5aa993b | 113 | static void |
fba45db2 | 114 | dump_objfile (struct objfile *objfile) |
c906108c | 115 | { |
6cb06a8c TT |
116 | gdb_printf ("\nObject file %s: ", objfile_name (objfile)); |
117 | gdb_printf ("Objfile at %s, bfd at %s, %d minsyms\n\n", | |
118 | host_address_to_string (objfile), | |
98badbfd | 119 | host_address_to_string (objfile->obfd.get ()), |
6cb06a8c | 120 | objfile->per_bfd->minimal_symbol_count); |
c906108c | 121 | |
4d080b46 | 122 | objfile->dump (); |
c906108c | 123 | |
43f3e411 | 124 | if (objfile->compunit_symtabs != NULL) |
c906108c | 125 | { |
6cb06a8c | 126 | gdb_printf ("Symtabs:\n"); |
b669c953 | 127 | for (compunit_symtab *cu : objfile->compunits ()) |
c906108c | 128 | { |
102cc235 | 129 | for (symtab *symtab : cu->filetabs ()) |
c906108c | 130 | { |
6cb06a8c TT |
131 | gdb_printf ("%s at %s", |
132 | symtab_to_filename_for_display (symtab), | |
133 | host_address_to_string (symtab)); | |
3c86fae3 | 134 | if (symtab->compunit ()->objfile () != objfile) |
6cb06a8c TT |
135 | gdb_printf (", NOT ON CHAIN!"); |
136 | gdb_printf ("\n"); | |
c906108c | 137 | } |
c906108c | 138 | } |
6cb06a8c | 139 | gdb_printf ("\n\n"); |
c906108c SS |
140 | } |
141 | } | |
142 | ||
143 | /* Print minimal symbols from this objfile. */ | |
c5aa993b JM |
144 | |
145 | static void | |
fba45db2 | 146 | dump_msymbols (struct objfile *objfile, struct ui_file *outfile) |
c906108c | 147 | { |
08feed99 | 148 | struct gdbarch *gdbarch = objfile->arch (); |
c906108c SS |
149 | int index; |
150 | char ms_type; | |
c5aa993b | 151 | |
6cb06a8c | 152 | gdb_printf (outfile, "\nObject file %s:\n\n", objfile_name (objfile)); |
34643a32 | 153 | if (objfile->per_bfd->minimal_symbol_count == 0) |
c906108c | 154 | { |
6cb06a8c | 155 | gdb_printf (outfile, "No minimal symbols found.\n"); |
c906108c SS |
156 | return; |
157 | } | |
3567439c | 158 | index = 0; |
7932255d | 159 | for (minimal_symbol *msymbol : objfile->msymbols ()) |
c906108c | 160 | { |
ebbc3a7d | 161 | struct obj_section *section = msymbol->obj_section (objfile); |
714835d5 | 162 | |
60f62e2b | 163 | switch (msymbol->type ()) |
c906108c | 164 | { |
c5aa993b JM |
165 | case mst_unknown: |
166 | ms_type = 'u'; | |
167 | break; | |
168 | case mst_text: | |
169 | ms_type = 'T'; | |
170 | break; | |
0875794a | 171 | case mst_text_gnu_ifunc: |
f50776aa | 172 | case mst_data_gnu_ifunc: |
0875794a JK |
173 | ms_type = 'i'; |
174 | break; | |
c5aa993b JM |
175 | case mst_solib_trampoline: |
176 | ms_type = 'S'; | |
177 | break; | |
178 | case mst_data: | |
179 | ms_type = 'D'; | |
180 | break; | |
181 | case mst_bss: | |
182 | ms_type = 'B'; | |
183 | break; | |
184 | case mst_abs: | |
185 | ms_type = 'A'; | |
186 | break; | |
187 | case mst_file_text: | |
188 | ms_type = 't'; | |
189 | break; | |
190 | case mst_file_data: | |
191 | ms_type = 'd'; | |
192 | break; | |
193 | case mst_file_bss: | |
194 | ms_type = 'b'; | |
195 | break; | |
196 | default: | |
197 | ms_type = '?'; | |
198 | break; | |
c906108c | 199 | } |
6cb06a8c | 200 | gdb_printf (outfile, "[%2d] %c ", index, ms_type); |
4b610737 TT |
201 | |
202 | /* Use the relocated address as shown in the symbol here -- do | |
203 | not try to respect copy relocations. */ | |
4aeddc50 | 204 | CORE_ADDR addr = (msymbol->value_raw_address () |
a52d653e | 205 | + objfile->section_offsets[msymbol->section_index ()]); |
0426ad51 | 206 | gdb_puts (paddress (gdbarch, addr), outfile); |
6cb06a8c | 207 | gdb_printf (outfile, " %s", msymbol->linkage_name ()); |
714835d5 | 208 | if (section) |
8625fc1b TT |
209 | { |
210 | if (section->the_bfd_section != NULL) | |
6cb06a8c TT |
211 | gdb_printf (outfile, " section %s", |
212 | bfd_section_name (section->the_bfd_section)); | |
8625fc1b | 213 | else |
6cb06a8c TT |
214 | gdb_printf (outfile, " spurious section %ld", |
215 | (long) (section - objfile->sections)); | |
8625fc1b | 216 | } |
c9d95fa3 | 217 | if (msymbol->demangled_name () != NULL) |
c906108c | 218 | { |
6cb06a8c | 219 | gdb_printf (outfile, " %s", msymbol->demangled_name ()); |
c906108c | 220 | } |
c906108c | 221 | if (msymbol->filename) |
6cb06a8c | 222 | gdb_printf (outfile, " %s", msymbol->filename); |
0426ad51 | 223 | gdb_puts ("\n", outfile); |
3567439c | 224 | index++; |
c906108c | 225 | } |
34643a32 | 226 | if (objfile->per_bfd->minimal_symbol_count != index) |
c906108c | 227 | { |
8a3fe4f8 | 228 | warning (_("internal error: minimal symbol count %d != %d"), |
34643a32 | 229 | objfile->per_bfd->minimal_symbol_count, index); |
c906108c | 230 | } |
6cb06a8c | 231 | gdb_printf (outfile, "\n"); |
c906108c SS |
232 | } |
233 | ||
c5aa993b | 234 | static void |
d04c1a59 | 235 | dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) |
c906108c | 236 | { |
3c86fae3 | 237 | struct objfile *objfile = symtab->compunit ()->objfile (); |
08feed99 | 238 | struct gdbarch *gdbarch = objfile->arch (); |
b026f593 | 239 | struct mdict_iterator miter; |
977a0c16 | 240 | const struct linetable *l; |
e88c90f2 | 241 | struct symbol *sym; |
c906108c SS |
242 | int depth; |
243 | ||
6cb06a8c TT |
244 | gdb_printf (outfile, "\nSymtab for file %s at %s\n", |
245 | symtab_to_filename_for_display (symtab), | |
246 | host_address_to_string (symtab)); | |
7b1eff95 | 247 | |
e4730328 | 248 | if (symtab->compunit ()->dirname () != NULL) |
6cb06a8c | 249 | gdb_printf (outfile, "Compilation directory is %s\n", |
e4730328 | 250 | symtab->compunit ()->dirname ()); |
6cb06a8c TT |
251 | gdb_printf (outfile, "Read from object file %s (%s)\n", |
252 | objfile_name (objfile), | |
253 | host_address_to_string (objfile)); | |
254 | gdb_printf (outfile, "Language: %s\n", | |
255 | language_str (symtab->language ())); | |
c906108c SS |
256 | |
257 | /* First print the line table. */ | |
5b607461 | 258 | l = symtab->linetable (); |
c906108c SS |
259 | if (l) |
260 | { | |
6cb06a8c | 261 | gdb_printf (outfile, "\nLine table:\n\n"); |
63d609de SM |
262 | int len = l->nitems; |
263 | for (int i = 0; i < len; i++) | |
c906108c | 264 | { |
6cb06a8c | 265 | gdb_printf (outfile, " line %d at ", l->item[i].line); |
1acc9dca | 266 | gdb_puts (paddress (gdbarch, l->item[i].pc (objfile)), outfile); |
8c95582d | 267 | if (l->item[i].is_stmt) |
6cb06a8c TT |
268 | gdb_printf (outfile, "\t(stmt)"); |
269 | gdb_printf (outfile, "\n"); | |
c906108c SS |
270 | } |
271 | } | |
43f3e411 | 272 | /* Now print the block info, but only for compunit symtabs since we will |
c378eb4e | 273 | print lots of duplicate info otherwise. */ |
7b1eff95 | 274 | if (is_main_symtab_of_compunit_symtab (symtab)) |
c906108c | 275 | { |
6cb06a8c | 276 | gdb_printf (outfile, "\nBlockvector:\n\n"); |
63d609de SM |
277 | const blockvector *bv = symtab->compunit ()->blockvector (); |
278 | for (int i = 0; i < bv->num_blocks (); i++) | |
c906108c | 279 | { |
63d609de | 280 | const block *b = bv->block (i); |
c906108c | 281 | depth = block_depth (b) * 2; |
6cb06a8c TT |
282 | gdb_printf (outfile, "%*sblock #%03d, object at %s", |
283 | depth, "", i, | |
284 | host_address_to_string (b)); | |
f135fe72 | 285 | if (b->superblock ()) |
6cb06a8c | 286 | gdb_printf (outfile, " under %s", |
f135fe72 | 287 | host_address_to_string (b->superblock ())); |
261397f8 DJ |
288 | /* drow/2002-07-10: We could save the total symbols count |
289 | even if we're using a hashtable, but nothing else but this message | |
290 | wants it. */ | |
6cb06a8c | 291 | gdb_printf (outfile, ", %d syms/buckets in ", |
24d74bb5 | 292 | mdict_size (b->multidict ())); |
4b8791e1 | 293 | gdb_puts (paddress (gdbarch, b->start ()), outfile); |
6cb06a8c | 294 | gdb_printf (outfile, ".."); |
4b8791e1 | 295 | gdb_puts (paddress (gdbarch, b->end ()), outfile); |
6c00f721 | 296 | if (b->function ()) |
c906108c | 297 | { |
6cb06a8c | 298 | gdb_printf (outfile, ", function %s", |
6c00f721 SM |
299 | b->function ()->linkage_name ()); |
300 | if (b->function ()->demangled_name () != NULL) | |
c906108c | 301 | { |
6cb06a8c | 302 | gdb_printf (outfile, ", %s", |
6c00f721 | 303 | b->function ()->demangled_name ()); |
c906108c SS |
304 | } |
305 | } | |
6cb06a8c | 306 | gdb_printf (outfile, "\n"); |
261397f8 | 307 | /* Now print each symbol in this block (in no particular order, if |
8157b174 TT |
308 | we're using a hashtable). Note that we only want this |
309 | block, not any blocks from included symtabs. */ | |
24d74bb5 | 310 | ALL_DICT_SYMBOLS (b->multidict (), miter, sym) |
c906108c | 311 | { |
a70b8144 | 312 | try |
bf469271 PA |
313 | { |
314 | print_symbol (gdbarch, sym, depth + 1, outfile); | |
315 | } | |
230d2906 | 316 | catch (const gdb_exception_error &ex) |
bf469271 PA |
317 | { |
318 | exception_fprintf (gdb_stderr, ex, | |
319 | "Error printing symbol:\n"); | |
320 | } | |
c906108c SS |
321 | } |
322 | } | |
6cb06a8c | 323 | gdb_printf (outfile, "\n"); |
c906108c SS |
324 | } |
325 | else | |
326 | { | |
c6159652 | 327 | compunit_symtab *compunit = symtab->compunit (); |
6c739336 | 328 | const char *compunit_filename |
510860f2 | 329 | = symtab_to_filename_for_display (compunit->primary_filetab ()); |
6c739336 | 330 | |
6cb06a8c TT |
331 | gdb_printf (outfile, |
332 | "\nBlockvector same as owning compunit: %s\n\n", | |
333 | compunit_filename); | |
c906108c | 334 | } |
7b1eff95 TV |
335 | |
336 | /* Print info about the user of this compunit_symtab, and the | |
337 | compunit_symtabs included by this one. */ | |
338 | if (is_main_symtab_of_compunit_symtab (symtab)) | |
339 | { | |
c6159652 | 340 | struct compunit_symtab *cust = symtab->compunit (); |
7b1eff95 TV |
341 | |
342 | if (cust->user != nullptr) | |
343 | { | |
344 | const char *addr | |
510860f2 | 345 | = host_address_to_string (cust->user->primary_filetab ()); |
6cb06a8c | 346 | gdb_printf (outfile, "Compunit user: %s\n", addr); |
7b1eff95 TV |
347 | } |
348 | if (cust->includes != nullptr) | |
63d609de | 349 | for (int i = 0; ; ++i) |
7b1eff95 TV |
350 | { |
351 | struct compunit_symtab *include = cust->includes[i]; | |
352 | if (include == nullptr) | |
353 | break; | |
354 | const char *addr | |
510860f2 | 355 | = host_address_to_string (include->primary_filetab ()); |
6cb06a8c | 356 | gdb_printf (outfile, "Compunit include: %s\n", addr); |
7b1eff95 TV |
357 | } |
358 | } | |
c906108c SS |
359 | } |
360 | ||
44b164c5 | 361 | static void |
d04c1a59 | 362 | dump_symtab (struct symtab *symtab, struct ui_file *outfile) |
44b164c5 | 363 | { |
44b164c5 JB |
364 | /* Set the current language to the language of the symtab we're dumping |
365 | because certain routines used during dump_symtab() use the current | |
969107c5 EZ |
366 | language to print an image of the symbol. We'll restore it later. |
367 | But use only real languages, not placeholders. */ | |
1ee2e9f9 SM |
368 | if (symtab->language () != language_unknown |
369 | && symtab->language () != language_auto) | |
969107c5 | 370 | { |
9bb9b2f9 | 371 | scoped_restore_current_language save_lang; |
1ee2e9f9 | 372 | set_language (symtab->language ()); |
d04c1a59 | 373 | dump_symtab_1 (symtab, outfile); |
969107c5 EZ |
374 | } |
375 | else | |
d04c1a59 | 376 | dump_symtab_1 (symtab, outfile); |
44b164c5 JB |
377 | } |
378 | ||
80480540 | 379 | static void |
e99c83e7 | 380 | maintenance_print_symbols (const char *args, int from_tty) |
c906108c | 381 | { |
34c41c68 | 382 | struct ui_file *outfile = gdb_stdout; |
34c41c68 DE |
383 | char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL; |
384 | int i, outfile_idx; | |
c906108c SS |
385 | |
386 | dont_repeat (); | |
387 | ||
773a1edc | 388 | gdb_argv argv (args); |
c906108c | 389 | |
99e8a4f9 | 390 | for (i = 0; argv != NULL && argv[i] != NULL; ++i) |
c906108c | 391 | { |
34c41c68 DE |
392 | if (strcmp (argv[i], "-pc") == 0) |
393 | { | |
394 | if (argv[i + 1] == NULL) | |
395 | error (_("Missing pc value")); | |
396 | address_arg = argv[++i]; | |
397 | } | |
398 | else if (strcmp (argv[i], "-source") == 0) | |
399 | { | |
400 | if (argv[i + 1] == NULL) | |
401 | error (_("Missing source file")); | |
402 | source_arg = argv[++i]; | |
403 | } | |
404 | else if (strcmp (argv[i], "-objfile") == 0) | |
405 | { | |
406 | if (argv[i + 1] == NULL) | |
407 | error (_("Missing objfile name")); | |
408 | objfile_arg = argv[++i]; | |
409 | } | |
410 | else if (strcmp (argv[i], "--") == 0) | |
411 | { | |
412 | /* End of options. */ | |
413 | ++i; | |
414 | break; | |
415 | } | |
416 | else if (argv[i][0] == '-') | |
c906108c | 417 | { |
34c41c68 DE |
418 | /* Future proofing: Don't allow OUTFILE to begin with "-". */ |
419 | error (_("Unknown option: %s"), argv[i]); | |
c906108c | 420 | } |
34c41c68 DE |
421 | else |
422 | break; | |
c906108c | 423 | } |
34c41c68 | 424 | outfile_idx = i; |
c906108c | 425 | |
34c41c68 DE |
426 | if (address_arg != NULL && source_arg != NULL) |
427 | error (_("Must specify at most one of -pc and -source")); | |
c5aa993b | 428 | |
d7e74731 PA |
429 | stdio_file arg_outfile; |
430 | ||
99e8a4f9 | 431 | if (argv != NULL && argv[outfile_idx] != NULL) |
34c41c68 | 432 | { |
34c41c68 DE |
433 | if (argv[outfile_idx + 1] != NULL) |
434 | error (_("Junk at end of command")); | |
ee0c3293 TT |
435 | gdb::unique_xmalloc_ptr<char> outfile_name |
436 | (tilde_expand (argv[outfile_idx])); | |
437 | if (!arg_outfile.open (outfile_name.get (), FOPEN_WT)) | |
438 | perror_with_name (outfile_name.get ()); | |
d7e74731 | 439 | outfile = &arg_outfile; |
34c41c68 | 440 | } |
c906108c | 441 | |
34c41c68 | 442 | if (address_arg != NULL) |
27618ce4 | 443 | { |
34c41c68 DE |
444 | CORE_ADDR pc = parse_and_eval_address (address_arg); |
445 | struct symtab *s = find_pc_line_symtab (pc); | |
446 | ||
447 | if (s == NULL) | |
448 | error (_("No symtab for address: %s"), address_arg); | |
449 | dump_symtab (s, outfile); | |
27618ce4 | 450 | } |
34c41c68 DE |
451 | else |
452 | { | |
34c41c68 DE |
453 | int found = 0; |
454 | ||
2030c079 | 455 | for (objfile *objfile : current_program_space->objfiles ()) |
34c41c68 DE |
456 | { |
457 | int print_for_objfile = 1; | |
458 | ||
459 | if (objfile_arg != NULL) | |
460 | print_for_objfile | |
461 | = compare_filenames_for_search (objfile_name (objfile), | |
462 | objfile_arg); | |
463 | if (!print_for_objfile) | |
464 | continue; | |
465 | ||
b669c953 | 466 | for (compunit_symtab *cu : objfile->compunits ()) |
34c41c68 | 467 | { |
102cc235 | 468 | for (symtab *s : cu->filetabs ()) |
34c41c68 | 469 | { |
d5da8b3c TT |
470 | int print_for_source = 0; |
471 | ||
472 | QUIT; | |
473 | if (source_arg != NULL) | |
474 | { | |
475 | print_for_source | |
476 | = compare_filenames_for_search | |
477 | (symtab_to_filename_for_display (s), source_arg); | |
478 | found = 1; | |
479 | } | |
480 | if (source_arg == NULL | |
481 | || print_for_source) | |
482 | dump_symtab (s, outfile); | |
34c41c68 | 483 | } |
34c41c68 DE |
484 | } |
485 | } | |
486 | ||
487 | if (source_arg != NULL && !found) | |
488 | error (_("No symtab for source file: %s"), source_arg); | |
489 | } | |
c906108c SS |
490 | } |
491 | ||
bf469271 | 492 | /* Print symbol SYMBOL on OUTFILE. DEPTH says how far to indent. */ |
c906108c | 493 | |
bf469271 PA |
494 | static void |
495 | print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, | |
496 | int depth, ui_file *outfile) | |
c906108c | 497 | { |
1994afbf DE |
498 | struct obj_section *section; |
499 | ||
7b3ecc75 | 500 | if (symbol->is_objfile_owned ()) |
e19b2d94 | 501 | section = symbol->obj_section (symbol->objfile ()); |
1994afbf DE |
502 | else |
503 | section = NULL; | |
c906108c | 504 | |
d0b1020b | 505 | print_spaces (depth, outfile); |
6c9c307c | 506 | if (symbol->domain () == LABEL_DOMAIN) |
c906108c | 507 | { |
6cb06a8c | 508 | gdb_printf (outfile, "label %s at ", symbol->print_name ()); |
4aeddc50 | 509 | gdb_puts (paddress (gdbarch, symbol->value_address ()), |
0426ad51 | 510 | outfile); |
714835d5 | 511 | if (section) |
6cb06a8c TT |
512 | gdb_printf (outfile, " section %s\n", |
513 | bfd_section_name (section->the_bfd_section)); | |
c906108c | 514 | else |
6cb06a8c | 515 | gdb_printf (outfile, "\n"); |
bf469271 | 516 | return; |
c906108c | 517 | } |
bf469271 | 518 | |
6c9c307c | 519 | if (symbol->domain () == STRUCT_DOMAIN) |
c906108c | 520 | { |
5f9c5a63 | 521 | if (symbol->type ()->name ()) |
c906108c | 522 | { |
13eb081a TT |
523 | current_language->print_type (symbol->type (), "", outfile, 1, depth, |
524 | &type_print_raw_options); | |
c906108c SS |
525 | } |
526 | else | |
527 | { | |
6cb06a8c TT |
528 | gdb_printf (outfile, "%s %s = ", |
529 | (symbol->type ()->code () == TYPE_CODE_ENUM | |
530 | ? "enum" | |
531 | : (symbol->type ()->code () == TYPE_CODE_STRUCT | |
532 | ? "struct" : "union")), | |
533 | symbol->linkage_name ()); | |
13eb081a TT |
534 | current_language->print_type (symbol->type (), "", outfile, 1, depth, |
535 | &type_print_raw_options); | |
c906108c | 536 | } |
6cb06a8c | 537 | gdb_printf (outfile, ";\n"); |
c906108c SS |
538 | } |
539 | else | |
540 | { | |
66d7f48f | 541 | if (symbol->aclass () == LOC_TYPEDEF) |
6cb06a8c | 542 | gdb_printf (outfile, "typedef "); |
5f9c5a63 | 543 | if (symbol->type ()) |
c906108c SS |
544 | { |
545 | /* Print details of types, except for enums where it's clutter. */ | |
13eb081a TT |
546 | current_language->print_type (symbol->type (), symbol->print_name (), |
547 | outfile, | |
548 | symbol->type ()->code () != TYPE_CODE_ENUM, | |
549 | depth, | |
550 | &type_print_raw_options); | |
6cb06a8c | 551 | gdb_printf (outfile, "; "); |
c906108c SS |
552 | } |
553 | else | |
6cb06a8c | 554 | gdb_printf (outfile, "%s ", symbol->print_name ()); |
c906108c | 555 | |
66d7f48f | 556 | switch (symbol->aclass ()) |
c906108c SS |
557 | { |
558 | case LOC_CONST: | |
6cb06a8c | 559 | gdb_printf (outfile, "const %s (%s)", |
4aeddc50 SM |
560 | plongest (symbol->value_longest ()), |
561 | hex_string (symbol->value_longest ())); | |
c906108c SS |
562 | break; |
563 | ||
564 | case LOC_CONST_BYTES: | |
565 | { | |
566 | unsigned i; | |
5f9c5a63 | 567 | struct type *type = check_typedef (symbol->type ()); |
433759f7 | 568 | |
6cb06a8c | 569 | gdb_printf (outfile, "const %s hex bytes:", |
df86565b SM |
570 | pulongest (type->length ())); |
571 | for (i = 0; i < type->length (); i++) | |
6cb06a8c | 572 | gdb_printf (outfile, " %02x", |
4aeddc50 | 573 | (unsigned) symbol->value_bytes ()[i]); |
c906108c SS |
574 | } |
575 | break; | |
576 | ||
577 | case LOC_STATIC: | |
6cb06a8c | 578 | gdb_printf (outfile, "static at "); |
4aeddc50 | 579 | gdb_puts (paddress (gdbarch, symbol->value_address ()), outfile); |
714835d5 | 580 | if (section) |
6cb06a8c TT |
581 | gdb_printf (outfile, " section %s", |
582 | bfd_section_name (section->the_bfd_section)); | |
c906108c SS |
583 | break; |
584 | ||
c906108c | 585 | case LOC_REGISTER: |
d9743061 | 586 | if (symbol->is_argument ()) |
6cb06a8c | 587 | gdb_printf (outfile, "parameter register %s", |
4aeddc50 | 588 | plongest (symbol->value_longest ())); |
2a2d4dc3 | 589 | else |
6cb06a8c | 590 | gdb_printf (outfile, "register %s", |
4aeddc50 | 591 | plongest (symbol->value_longest ())); |
c906108c SS |
592 | break; |
593 | ||
594 | case LOC_ARG: | |
6cb06a8c | 595 | gdb_printf (outfile, "arg at offset %s", |
4aeddc50 | 596 | hex_string (symbol->value_longest ())); |
c906108c SS |
597 | break; |
598 | ||
c906108c | 599 | case LOC_REF_ARG: |
6cb06a8c | 600 | gdb_printf (outfile, "reference arg at %s", |
4aeddc50 | 601 | hex_string (symbol->value_longest ())); |
c906108c SS |
602 | break; |
603 | ||
c906108c | 604 | case LOC_REGPARM_ADDR: |
6cb06a8c | 605 | gdb_printf (outfile, "address parameter register %s", |
4aeddc50 | 606 | plongest (symbol->value_longest ())); |
c906108c SS |
607 | break; |
608 | ||
609 | case LOC_LOCAL: | |
6cb06a8c | 610 | gdb_printf (outfile, "local at offset %s", |
4aeddc50 | 611 | hex_string (symbol->value_longest ())); |
c906108c SS |
612 | break; |
613 | ||
c906108c SS |
614 | case LOC_TYPEDEF: |
615 | break; | |
616 | ||
617 | case LOC_LABEL: | |
6cb06a8c | 618 | gdb_printf (outfile, "label at "); |
4aeddc50 | 619 | gdb_puts (paddress (gdbarch, symbol->value_address ()), outfile); |
714835d5 | 620 | if (section) |
6cb06a8c TT |
621 | gdb_printf (outfile, " section %s", |
622 | bfd_section_name (section->the_bfd_section)); | |
c906108c SS |
623 | break; |
624 | ||
625 | case LOC_BLOCK: | |
6cb06a8c | 626 | gdb_printf |
64b7cc50 | 627 | (outfile, "block object %s, %s..%s", |
4aeddc50 | 628 | host_address_to_string (symbol->value_block ()), |
4b8791e1 SM |
629 | paddress (gdbarch, symbol->value_block()->start ()), |
630 | paddress (gdbarch, symbol->value_block()->end ())); | |
714835d5 | 631 | if (section) |
6cb06a8c TT |
632 | gdb_printf (outfile, " section %s", |
633 | bfd_section_name (section->the_bfd_section)); | |
c906108c SS |
634 | break; |
635 | ||
4c2df51b | 636 | case LOC_COMPUTED: |
6cb06a8c | 637 | gdb_printf (outfile, "computed at runtime"); |
4c2df51b DJ |
638 | break; |
639 | ||
c906108c | 640 | case LOC_UNRESOLVED: |
6cb06a8c | 641 | gdb_printf (outfile, "unresolved"); |
c906108c SS |
642 | break; |
643 | ||
644 | case LOC_OPTIMIZED_OUT: | |
6cb06a8c | 645 | gdb_printf (outfile, "optimized out"); |
c906108c SS |
646 | break; |
647 | ||
c5aa993b | 648 | default: |
6cb06a8c TT |
649 | gdb_printf (outfile, "botched symbol class %x", |
650 | symbol->aclass ()); | |
c906108c SS |
651 | break; |
652 | } | |
653 | } | |
6cb06a8c | 654 | gdb_printf (outfile, "\n"); |
c906108c SS |
655 | } |
656 | ||
80480540 | 657 | static void |
e99c83e7 | 658 | maintenance_print_msymbols (const char *args, int from_tty) |
c906108c | 659 | { |
34c41c68 | 660 | struct ui_file *outfile = gdb_stdout; |
34c41c68 | 661 | char *objfile_arg = NULL; |
34c41c68 | 662 | int i, outfile_idx; |
07318b29 | 663 | |
c906108c SS |
664 | dont_repeat (); |
665 | ||
773a1edc | 666 | gdb_argv argv (args); |
c906108c | 667 | |
99e8a4f9 | 668 | for (i = 0; argv != NULL && argv[i] != NULL; ++i) |
c906108c | 669 | { |
34c41c68 | 670 | if (strcmp (argv[i], "-objfile") == 0) |
c906108c | 671 | { |
34c41c68 DE |
672 | if (argv[i + 1] == NULL) |
673 | error (_("Missing objfile name")); | |
674 | objfile_arg = argv[++i]; | |
675 | } | |
676 | else if (strcmp (argv[i], "--") == 0) | |
677 | { | |
678 | /* End of options. */ | |
679 | ++i; | |
680 | break; | |
c906108c | 681 | } |
34c41c68 DE |
682 | else if (argv[i][0] == '-') |
683 | { | |
684 | /* Future proofing: Don't allow OUTFILE to begin with "-". */ | |
685 | error (_("Unknown option: %s"), argv[i]); | |
686 | } | |
687 | else | |
688 | break; | |
c906108c | 689 | } |
34c41c68 | 690 | outfile_idx = i; |
c906108c | 691 | |
d7e74731 PA |
692 | stdio_file arg_outfile; |
693 | ||
99e8a4f9 | 694 | if (argv != NULL && argv[outfile_idx] != NULL) |
34c41c68 | 695 | { |
34c41c68 DE |
696 | if (argv[outfile_idx + 1] != NULL) |
697 | error (_("Junk at end of command")); | |
ee0c3293 TT |
698 | gdb::unique_xmalloc_ptr<char> outfile_name |
699 | (tilde_expand (argv[outfile_idx])); | |
700 | if (!arg_outfile.open (outfile_name.get (), FOPEN_WT)) | |
701 | perror_with_name (outfile_name.get ()); | |
d7e74731 | 702 | outfile = &arg_outfile; |
34c41c68 | 703 | } |
c5aa993b | 704 | |
2030c079 | 705 | for (objfile *objfile : current_program_space->objfiles ()) |
aed57c53 TT |
706 | { |
707 | QUIT; | |
708 | if (objfile_arg == NULL | |
709 | || compare_filenames_for_search (objfile_name (objfile), objfile_arg)) | |
710 | dump_msymbols (objfile, outfile); | |
711 | } | |
c906108c SS |
712 | } |
713 | ||
80480540 | 714 | static void |
e99c83e7 | 715 | maintenance_print_objfiles (const char *regexp, int from_tty) |
c906108c | 716 | { |
c906108c SS |
717 | dont_repeat (); |
718 | ||
52e260a3 DE |
719 | if (regexp) |
720 | re_comp (regexp); | |
721 | ||
94c93c35 | 722 | for (struct program_space *pspace : program_spaces) |
2030c079 | 723 | for (objfile *objfile : pspace->objfiles ()) |
27618ce4 TT |
724 | { |
725 | QUIT; | |
52e260a3 | 726 | if (! regexp |
4262abfb | 727 | || re_exec (objfile_name (objfile))) |
52e260a3 | 728 | dump_objfile (objfile); |
27618ce4 | 729 | } |
c906108c SS |
730 | } |
731 | ||
5e7b2f39 | 732 | /* List all the symbol tables whose names match REGEXP (optional). */ |
b5ebcee6 | 733 | |
80480540 | 734 | static void |
e99c83e7 | 735 | maintenance_info_symtabs (const char *regexp, int from_tty) |
44ea7b70 | 736 | { |
db68bbae DE |
737 | dont_repeat (); |
738 | ||
44ea7b70 JB |
739 | if (regexp) |
740 | re_comp (regexp); | |
741 | ||
94c93c35 | 742 | for (struct program_space *pspace : program_spaces) |
2030c079 | 743 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 744 | { |
99d89cde TT |
745 | /* We don't want to print anything for this objfile until we |
746 | actually find a symtab whose name matches. */ | |
747 | int printed_objfile_start = 0; | |
43f3e411 | 748 | |
b669c953 | 749 | for (compunit_symtab *cust : objfile->compunits ()) |
99d89cde TT |
750 | { |
751 | int printed_compunit_symtab_start = 0; | |
752 | ||
102cc235 | 753 | for (symtab *symtab : cust->filetabs ()) |
99d89cde TT |
754 | { |
755 | QUIT; | |
756 | ||
757 | if (! regexp | |
758 | || re_exec (symtab_to_filename_for_display (symtab))) | |
759 | { | |
760 | if (! printed_objfile_start) | |
761 | { | |
6cb06a8c | 762 | gdb_printf ("{ objfile %s ", objfile_name (objfile)); |
1285ce86 | 763 | gdb_stdout->wrap_here (2); |
6cb06a8c TT |
764 | gdb_printf ("((struct objfile *) %s)\n", |
765 | host_address_to_string (objfile)); | |
99d89cde TT |
766 | printed_objfile_start = 1; |
767 | } | |
768 | if (! printed_compunit_symtab_start) | |
769 | { | |
6cb06a8c TT |
770 | gdb_printf (" { ((struct compunit_symtab *) %s)\n", |
771 | host_address_to_string (cust)); | |
772 | gdb_printf (" debugformat %s\n", | |
773 | cust->debugformat ()); | |
774 | gdb_printf (" producer %s\n", | |
775 | (cust->producer () != nullptr | |
776 | ? cust->producer () : "(null)")); | |
af7047e8 | 777 | gdb_printf (" name %s\n", cust->name); |
6cb06a8c TT |
778 | gdb_printf (" dirname %s\n", |
779 | (cust->dirname () != NULL | |
780 | ? cust->dirname () : "(null)")); | |
781 | gdb_printf (" blockvector" | |
782 | " ((struct blockvector *) %s)\n", | |
783 | host_address_to_string | |
784 | (cust->blockvector ())); | |
785 | gdb_printf (" user" | |
786 | " ((struct compunit_symtab *) %s)\n", | |
787 | cust->user != nullptr | |
788 | ? host_address_to_string (cust->user) | |
789 | : "(null)"); | |
7b1eff95 TV |
790 | if (cust->includes != nullptr) |
791 | { | |
6cb06a8c | 792 | gdb_printf (" ( includes\n"); |
7b1eff95 TV |
793 | for (int i = 0; ; ++i) |
794 | { | |
795 | struct compunit_symtab *include | |
796 | = cust->includes[i]; | |
797 | if (include == nullptr) | |
798 | break; | |
799 | const char *addr | |
800 | = host_address_to_string (include); | |
6cb06a8c TT |
801 | gdb_printf (" (%s %s)\n", |
802 | "(struct compunit_symtab *)", | |
803 | addr); | |
7b1eff95 | 804 | } |
6cb06a8c | 805 | gdb_printf (" )\n"); |
7b1eff95 | 806 | } |
99d89cde TT |
807 | printed_compunit_symtab_start = 1; |
808 | } | |
809 | ||
6cb06a8c TT |
810 | gdb_printf ("\t{ symtab %s ", |
811 | symtab_to_filename_for_display (symtab)); | |
1285ce86 | 812 | gdb_stdout->wrap_here (4); |
6cb06a8c TT |
813 | gdb_printf ("((struct symtab *) %s)\n", |
814 | host_address_to_string (symtab)); | |
815 | gdb_printf ("\t fullname %s\n", | |
816 | symtab->fullname != NULL | |
817 | ? symtab->fullname | |
818 | : "(null)"); | |
819 | gdb_printf ("\t " | |
820 | "linetable ((struct linetable *) %s)\n", | |
821 | host_address_to_string | |
822 | (symtab->linetable ())); | |
823 | gdb_printf ("\t}\n"); | |
99d89cde TT |
824 | } |
825 | } | |
826 | ||
827 | if (printed_compunit_symtab_start) | |
6cb06a8c | 828 | gdb_printf (" }\n"); |
99d89cde | 829 | } |
44ea7b70 | 830 | |
99d89cde | 831 | if (printed_objfile_start) |
6cb06a8c | 832 | gdb_printf ("}\n"); |
99d89cde | 833 | } |
44ea7b70 | 834 | } |
7d0c9981 DE |
835 | |
836 | /* Check consistency of symtabs. | |
837 | An example of what this checks for is NULL blockvectors. | |
838 | They can happen if there's a bug during debug info reading. | |
839 | GDB assumes they are always non-NULL. | |
840 | ||
841 | Note: This does not check for psymtab vs symtab consistency. | |
842 | Use "maint check-psymtabs" for that. */ | |
843 | ||
844 | static void | |
e99c83e7 | 845 | maintenance_check_symtabs (const char *ignore, int from_tty) |
7d0c9981 | 846 | { |
94c93c35 | 847 | for (struct program_space *pspace : program_spaces) |
2030c079 | 848 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 849 | { |
99d89cde TT |
850 | /* We don't want to print anything for this objfile until we |
851 | actually find something worth printing. */ | |
852 | int printed_objfile_start = 0; | |
7d0c9981 | 853 | |
b669c953 | 854 | for (compunit_symtab *cust : objfile->compunits ()) |
99d89cde TT |
855 | { |
856 | int found_something = 0; | |
0b17a4f7 | 857 | struct symtab *symtab = cust->primary_filetab (); |
99d89cde TT |
858 | |
859 | QUIT; | |
860 | ||
af39c5c8 | 861 | if (cust->blockvector () == NULL) |
99d89cde TT |
862 | found_something = 1; |
863 | /* Add more checks here. */ | |
864 | ||
865 | if (found_something) | |
866 | { | |
867 | if (! printed_objfile_start) | |
868 | { | |
6cb06a8c | 869 | gdb_printf ("{ objfile %s ", objfile_name (objfile)); |
1285ce86 | 870 | gdb_stdout->wrap_here (2); |
6cb06a8c TT |
871 | gdb_printf ("((struct objfile *) %s)\n", |
872 | host_address_to_string (objfile)); | |
99d89cde TT |
873 | printed_objfile_start = 1; |
874 | } | |
6cb06a8c TT |
875 | gdb_printf (" { symtab %s\n", |
876 | symtab_to_filename_for_display (symtab)); | |
af39c5c8 | 877 | if (cust->blockvector () == NULL) |
6cb06a8c TT |
878 | gdb_printf (" NULL blockvector\n"); |
879 | gdb_printf (" }\n"); | |
99d89cde TT |
880 | } |
881 | } | |
7d0c9981 | 882 | |
99d89cde | 883 | if (printed_objfile_start) |
6cb06a8c | 884 | gdb_printf ("}\n"); |
99d89cde | 885 | } |
7d0c9981 DE |
886 | } |
887 | ||
7d0c9981 DE |
888 | /* Expand all symbol tables whose name matches an optional regexp. */ |
889 | ||
890 | static void | |
e99c83e7 | 891 | maintenance_expand_symtabs (const char *args, int from_tty) |
7d0c9981 | 892 | { |
7d0c9981 DE |
893 | char *regexp = NULL; |
894 | ||
895 | /* We use buildargv here so that we handle spaces in the regexp | |
896 | in a way that allows adding more arguments later. */ | |
773a1edc | 897 | gdb_argv argv (args); |
7d0c9981 DE |
898 | |
899 | if (argv != NULL) | |
900 | { | |
901 | if (argv[0] != NULL) | |
902 | { | |
903 | regexp = argv[0]; | |
904 | if (argv[1] != NULL) | |
905 | error (_("Extra arguments after regexp.")); | |
906 | } | |
907 | } | |
908 | ||
909 | if (regexp) | |
910 | re_comp (regexp); | |
911 | ||
94c93c35 | 912 | for (struct program_space *pspace : program_spaces) |
2030c079 | 913 | for (objfile *objfile : pspace->objfiles ()) |
4d080b46 TT |
914 | objfile->expand_symtabs_matching |
915 | ([&] (const char *filename, bool basenames) | |
916 | { | |
917 | /* KISS: Only apply the regexp to the complete file name. */ | |
918 | return (!basenames | |
919 | && (regexp == NULL || re_exec (filename))); | |
920 | }, | |
921 | NULL, | |
922 | NULL, | |
923 | NULL, | |
03a8ea51 | 924 | SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, |
3bfa51a7 | 925 | UNDEF_DOMAIN, |
4d080b46 | 926 | ALL_DOMAIN); |
7d0c9981 | 927 | } |
c906108c | 928 | \f |
c5aa993b | 929 | |
c906108c SS |
930 | /* Return the nexting depth of a block within other blocks in its symtab. */ |
931 | ||
932 | static int | |
582942f4 | 933 | block_depth (const struct block *block) |
c906108c | 934 | { |
52f0bd74 | 935 | int i = 0; |
433759f7 | 936 | |
f135fe72 | 937 | while ((block = block->superblock ()) != NULL) |
c906108c SS |
938 | { |
939 | i++; | |
940 | } | |
941 | return i; | |
942 | } | |
c906108c | 943 | \f |
c5aa993b | 944 | |
f2403c39 AB |
945 | /* Used by MAINTENANCE_INFO_LINE_TABLES to print the information about a |
946 | single line table. */ | |
947 | ||
948 | static int | |
949 | maintenance_print_one_line_table (struct symtab *symtab, void *data) | |
950 | { | |
977a0c16 | 951 | const struct linetable *linetable; |
f2403c39 AB |
952 | struct objfile *objfile; |
953 | ||
c6159652 | 954 | objfile = symtab->compunit ()->objfile (); |
6cb06a8c TT |
955 | gdb_printf (_("objfile: %ps ((struct objfile *) %s)\n"), |
956 | styled_string (file_name_style.style (), | |
957 | objfile_name (objfile)), | |
958 | host_address_to_string (objfile)); | |
959 | gdb_printf (_("compunit_symtab: %s ((struct compunit_symtab *) %s)\n"), | |
960 | symtab->compunit ()->name, | |
961 | host_address_to_string (symtab->compunit ())); | |
962 | gdb_printf (_("symtab: %ps ((struct symtab *) %s)\n"), | |
963 | styled_string (file_name_style.style (), | |
964 | symtab_to_fullname (symtab)), | |
965 | host_address_to_string (symtab)); | |
5b607461 | 966 | linetable = symtab->linetable (); |
6cb06a8c TT |
967 | gdb_printf (_("linetable: ((struct linetable *) %s):\n"), |
968 | host_address_to_string (linetable)); | |
f2403c39 AB |
969 | |
970 | if (linetable == NULL) | |
6cb06a8c | 971 | gdb_printf (_("No line table.\n")); |
f2403c39 | 972 | else if (linetable->nitems <= 0) |
6cb06a8c | 973 | gdb_printf (_("Line table has no lines.\n")); |
f2403c39 AB |
974 | else |
975 | { | |
f2403c39 AB |
976 | /* Leave space for 6 digits of index and line number. After that the |
977 | tables will just not format as well. */ | |
1773be9e | 978 | struct ui_out *uiout = current_uiout; |
cc96ae7f | 979 | ui_out_emit_table table_emitter (uiout, 5, -1, "line-table"); |
1773be9e TT |
980 | uiout->table_header (6, ui_left, "index", _("INDEX")); |
981 | uiout->table_header (6, ui_left, "line", _("LINE")); | |
982 | uiout->table_header (18, ui_left, "address", _("ADDRESS")); | |
cc96ae7f LS |
983 | uiout->table_header (7, ui_left, "is-stmt", _("IS-STMT")); |
984 | uiout->table_header (12, ui_left, "prologue-end", _("PROLOGUE-END")); | |
1773be9e TT |
985 | uiout->table_body (); |
986 | ||
987 | for (int i = 0; i < linetable->nitems; ++i) | |
f2403c39 | 988 | { |
977a0c16 | 989 | const linetable_entry *item; |
f2403c39 AB |
990 | |
991 | item = &linetable->item [i]; | |
1773be9e TT |
992 | ui_out_emit_tuple tuple_emitter (uiout, nullptr); |
993 | uiout->field_signed ("index", i); | |
94a72be7 | 994 | if (item->line > 0) |
1773be9e | 995 | uiout->field_signed ("line", item->line); |
94a72be7 | 996 | else |
1773be9e | 997 | uiout->field_string ("line", _("END")); |
08feed99 | 998 | uiout->field_core_addr ("address", objfile->arch (), |
48e0f38c | 999 | CORE_ADDR (item->raw_pc ())); |
1773be9e | 1000 | uiout->field_string ("is-stmt", item->is_stmt ? "Y" : ""); |
cc96ae7f | 1001 | uiout->field_string ("prologue-end", item->prologue_end ? "Y" : ""); |
1773be9e | 1002 | uiout->text ("\n"); |
f2403c39 AB |
1003 | } |
1004 | } | |
1005 | ||
1006 | return 0; | |
1007 | } | |
1008 | ||
1009 | /* Implement the 'maint info line-table' command. */ | |
1010 | ||
1011 | static void | |
e99c83e7 | 1012 | maintenance_info_line_tables (const char *regexp, int from_tty) |
f2403c39 | 1013 | { |
f2403c39 AB |
1014 | dont_repeat (); |
1015 | ||
1016 | if (regexp != NULL) | |
1017 | re_comp (regexp); | |
1018 | ||
94c93c35 | 1019 | for (struct program_space *pspace : program_spaces) |
2030c079 | 1020 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 1021 | { |
b669c953 | 1022 | for (compunit_symtab *cust : objfile->compunits ()) |
99d89cde | 1023 | { |
102cc235 | 1024 | for (symtab *symtab : cust->filetabs ()) |
99d89cde TT |
1025 | { |
1026 | QUIT; | |
1027 | ||
1028 | if (regexp == NULL | |
1029 | || re_exec (symtab_to_filename_for_display (symtab))) | |
92228a33 SM |
1030 | { |
1031 | maintenance_print_one_line_table (symtab, NULL); | |
6cb06a8c | 1032 | gdb_printf ("\n"); |
92228a33 | 1033 | } |
99d89cde TT |
1034 | } |
1035 | } | |
1036 | } | |
f2403c39 AB |
1037 | } |
1038 | ||
1039 | \f | |
1040 | ||
c378eb4e | 1041 | /* Do early runtime initializations. */ |
b5ebcee6 | 1042 | |
6c265988 | 1043 | void _initialize_symmisc (); |
c906108c | 1044 | void |
6c265988 | 1045 | _initialize_symmisc () |
c906108c | 1046 | { |
80480540 YQ |
1047 | add_cmd ("symbols", class_maintenance, maintenance_print_symbols, _("\ |
1048 | Print dump of current symbol definitions.\n\ | |
48c5e7e2 TT |
1049 | Usage: mt print symbols [-pc ADDRESS] [--] [OUTFILE]\n\ |
1050 | mt print symbols [-objfile OBJFILE] [-source SOURCE] [--] [OUTFILE]\n\ | |
34c41c68 DE |
1051 | Entries in the full symbol table are dumped to file OUTFILE,\n\ |
1052 | or the terminal if OUTFILE is unspecified.\n\ | |
1053 | If ADDRESS is provided, dump only the file for that address.\n\ | |
1054 | If SOURCE is provided, dump only that file's symbols.\n\ | |
1055 | If OBJFILE is provided, dump only that file's minimal symbols."), | |
80480540 YQ |
1056 | &maintenanceprintlist); |
1057 | ||
1058 | add_cmd ("msymbols", class_maintenance, maintenance_print_msymbols, _("\ | |
1059 | Print dump of current minimal symbol definitions.\n\ | |
48c5e7e2 | 1060 | Usage: mt print msymbols [-objfile OBJFILE] [--] [OUTFILE]\n\ |
34c41c68 DE |
1061 | Entries in the minimal symbol table are dumped to file OUTFILE,\n\ |
1062 | or the terminal if OUTFILE is unspecified.\n\ | |
1063 | If OBJFILE is provided, dump only that file's minimal symbols."), | |
80480540 YQ |
1064 | &maintenanceprintlist); |
1065 | ||
1066 | add_cmd ("objfiles", class_maintenance, maintenance_print_objfiles, | |
52e260a3 DE |
1067 | _("Print dump of current object file definitions.\n\ |
1068 | With an argument REGEXP, list the object files with matching names."), | |
80480540 YQ |
1069 | &maintenanceprintlist); |
1070 | ||
1071 | add_cmd ("symtabs", class_maintenance, maintenance_info_symtabs, _("\ | |
1072 | List the full symbol tables for all object files.\n\ | |
1073 | This does not include information about individual symbols, blocks, or\n\ | |
1074 | linetables --- just the symbol table structures themselves.\n\ | |
db68bbae | 1075 | With an argument REGEXP, list the symbol tables with matching names."), |
80480540 | 1076 | &maintenanceinfolist); |
7d0c9981 | 1077 | |
f2403c39 AB |
1078 | add_cmd ("line-table", class_maintenance, maintenance_info_line_tables, _("\ |
1079 | List the contents of all line tables, from all symbol tables.\n\ | |
1080 | With an argument REGEXP, list just the line tables for the symbol\n\ | |
1081 | tables with matching names."), | |
1082 | &maintenanceinfolist); | |
1083 | ||
7d0c9981 DE |
1084 | add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs, |
1085 | _("\ | |
1086 | Check consistency of currently expanded symtabs."), | |
1087 | &maintenancelist); | |
1088 | ||
1089 | add_cmd ("expand-symtabs", class_maintenance, maintenance_expand_symtabs, | |
1090 | _("Expand symbol tables.\n\ | |
1091 | With an argument REGEXP, only expand the symbol tables with matching names."), | |
1092 | &maintenancelist); | |
c906108c | 1093 | } |