]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Do various things to symbol tables (other than lookup), for GDB. |
af5f3db6 | 2 | |
1d506c26 | 3 | Copyright (C) 1986-2024 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 | 19 | |
e5dc0d5d | 20 | #include "event-top.h" |
c906108c SS |
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" |
5b9707eb | 37 | #include "cli/cli-cmds.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. */ | |
93d50cd8 | 204 | CORE_ADDR addr = (CORE_ADDR (msymbol->unrelocated_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 | 214 | gdb_printf (outfile, " spurious section %ld", |
9ed8433a | 215 | (long) (section - objfile->sections_start)); |
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 (); |
977a0c16 | 239 | const struct linetable *l; |
c906108c SS |
240 | int depth; |
241 | ||
6cb06a8c TT |
242 | gdb_printf (outfile, "\nSymtab for file %s at %s\n", |
243 | symtab_to_filename_for_display (symtab), | |
244 | host_address_to_string (symtab)); | |
7b1eff95 | 245 | |
e4730328 | 246 | if (symtab->compunit ()->dirname () != NULL) |
6cb06a8c | 247 | gdb_printf (outfile, "Compilation directory is %s\n", |
e4730328 | 248 | symtab->compunit ()->dirname ()); |
6cb06a8c TT |
249 | gdb_printf (outfile, "Read from object file %s (%s)\n", |
250 | objfile_name (objfile), | |
251 | host_address_to_string (objfile)); | |
252 | gdb_printf (outfile, "Language: %s\n", | |
253 | language_str (symtab->language ())); | |
c906108c SS |
254 | |
255 | /* First print the line table. */ | |
5b607461 | 256 | l = symtab->linetable (); |
c906108c SS |
257 | if (l) |
258 | { | |
6cb06a8c | 259 | gdb_printf (outfile, "\nLine table:\n\n"); |
63d609de SM |
260 | int len = l->nitems; |
261 | for (int i = 0; i < len; i++) | |
c906108c | 262 | { |
6cb06a8c | 263 | gdb_printf (outfile, " line %d at ", l->item[i].line); |
1acc9dca | 264 | gdb_puts (paddress (gdbarch, l->item[i].pc (objfile)), outfile); |
8c95582d | 265 | if (l->item[i].is_stmt) |
6cb06a8c TT |
266 | gdb_printf (outfile, "\t(stmt)"); |
267 | gdb_printf (outfile, "\n"); | |
c906108c SS |
268 | } |
269 | } | |
43f3e411 | 270 | /* Now print the block info, but only for compunit symtabs since we will |
c378eb4e | 271 | print lots of duplicate info otherwise. */ |
7b1eff95 | 272 | if (is_main_symtab_of_compunit_symtab (symtab)) |
c906108c | 273 | { |
6cb06a8c | 274 | gdb_printf (outfile, "\nBlockvector:\n\n"); |
63d609de SM |
275 | const blockvector *bv = symtab->compunit ()->blockvector (); |
276 | for (int i = 0; i < bv->num_blocks (); i++) | |
c906108c | 277 | { |
63d609de | 278 | const block *b = bv->block (i); |
c906108c | 279 | depth = block_depth (b) * 2; |
6cb06a8c TT |
280 | gdb_printf (outfile, "%*sblock #%03d, object at %s", |
281 | depth, "", i, | |
282 | host_address_to_string (b)); | |
f135fe72 | 283 | if (b->superblock ()) |
6cb06a8c | 284 | gdb_printf (outfile, " under %s", |
f135fe72 | 285 | host_address_to_string (b->superblock ())); |
261397f8 DJ |
286 | /* drow/2002-07-10: We could save the total symbols count |
287 | even if we're using a hashtable, but nothing else but this message | |
288 | wants it. */ | |
b8c2de06 | 289 | gdb_printf (outfile, ", %d symbols in ", |
24d74bb5 | 290 | mdict_size (b->multidict ())); |
4b8791e1 | 291 | gdb_puts (paddress (gdbarch, b->start ()), outfile); |
6cb06a8c | 292 | gdb_printf (outfile, ".."); |
4b8791e1 | 293 | gdb_puts (paddress (gdbarch, b->end ()), outfile); |
6c00f721 | 294 | if (b->function ()) |
c906108c | 295 | { |
6cb06a8c | 296 | gdb_printf (outfile, ", function %s", |
6c00f721 SM |
297 | b->function ()->linkage_name ()); |
298 | if (b->function ()->demangled_name () != NULL) | |
c906108c | 299 | { |
6cb06a8c | 300 | gdb_printf (outfile, ", %s", |
6c00f721 | 301 | b->function ()->demangled_name ()); |
c906108c SS |
302 | } |
303 | } | |
6cb06a8c | 304 | gdb_printf (outfile, "\n"); |
261397f8 | 305 | /* Now print each symbol in this block (in no particular order, if |
8157b174 TT |
306 | we're using a hashtable). Note that we only want this |
307 | block, not any blocks from included symtabs. */ | |
8e8d48f9 | 308 | for (struct symbol *sym : b->multidict_symbols ()) |
c906108c | 309 | { |
a70b8144 | 310 | try |
bf469271 PA |
311 | { |
312 | print_symbol (gdbarch, sym, depth + 1, outfile); | |
313 | } | |
230d2906 | 314 | catch (const gdb_exception_error &ex) |
bf469271 PA |
315 | { |
316 | exception_fprintf (gdb_stderr, ex, | |
317 | "Error printing symbol:\n"); | |
318 | } | |
c906108c SS |
319 | } |
320 | } | |
6cb06a8c | 321 | gdb_printf (outfile, "\n"); |
c906108c SS |
322 | } |
323 | else | |
324 | { | |
c6159652 | 325 | compunit_symtab *compunit = symtab->compunit (); |
6c739336 | 326 | const char *compunit_filename |
510860f2 | 327 | = symtab_to_filename_for_display (compunit->primary_filetab ()); |
6c739336 | 328 | |
6cb06a8c TT |
329 | gdb_printf (outfile, |
330 | "\nBlockvector same as owning compunit: %s\n\n", | |
331 | compunit_filename); | |
c906108c | 332 | } |
7b1eff95 TV |
333 | |
334 | /* Print info about the user of this compunit_symtab, and the | |
335 | compunit_symtabs included by this one. */ | |
336 | if (is_main_symtab_of_compunit_symtab (symtab)) | |
337 | { | |
c6159652 | 338 | struct compunit_symtab *cust = symtab->compunit (); |
7b1eff95 TV |
339 | |
340 | if (cust->user != nullptr) | |
341 | { | |
342 | const char *addr | |
510860f2 | 343 | = host_address_to_string (cust->user->primary_filetab ()); |
6cb06a8c | 344 | gdb_printf (outfile, "Compunit user: %s\n", addr); |
7b1eff95 TV |
345 | } |
346 | if (cust->includes != nullptr) | |
63d609de | 347 | for (int i = 0; ; ++i) |
7b1eff95 TV |
348 | { |
349 | struct compunit_symtab *include = cust->includes[i]; | |
350 | if (include == nullptr) | |
351 | break; | |
352 | const char *addr | |
510860f2 | 353 | = host_address_to_string (include->primary_filetab ()); |
6cb06a8c | 354 | gdb_printf (outfile, "Compunit include: %s\n", addr); |
7b1eff95 TV |
355 | } |
356 | } | |
c906108c SS |
357 | } |
358 | ||
44b164c5 | 359 | static void |
d04c1a59 | 360 | dump_symtab (struct symtab *symtab, struct ui_file *outfile) |
44b164c5 | 361 | { |
44b164c5 JB |
362 | /* Set the current language to the language of the symtab we're dumping |
363 | because certain routines used during dump_symtab() use the current | |
969107c5 EZ |
364 | language to print an image of the symbol. We'll restore it later. |
365 | But use only real languages, not placeholders. */ | |
129bce36 | 366 | if (symtab->language () != language_unknown) |
969107c5 | 367 | { |
9bb9b2f9 | 368 | scoped_restore_current_language save_lang; |
1ee2e9f9 | 369 | set_language (symtab->language ()); |
d04c1a59 | 370 | dump_symtab_1 (symtab, outfile); |
969107c5 EZ |
371 | } |
372 | else | |
d04c1a59 | 373 | dump_symtab_1 (symtab, outfile); |
44b164c5 JB |
374 | } |
375 | ||
80480540 | 376 | static void |
e99c83e7 | 377 | maintenance_print_symbols (const char *args, int from_tty) |
c906108c | 378 | { |
34c41c68 | 379 | struct ui_file *outfile = gdb_stdout; |
34c41c68 DE |
380 | char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL; |
381 | int i, outfile_idx; | |
c906108c SS |
382 | |
383 | dont_repeat (); | |
384 | ||
773a1edc | 385 | gdb_argv argv (args); |
c906108c | 386 | |
99e8a4f9 | 387 | for (i = 0; argv != NULL && argv[i] != NULL; ++i) |
c906108c | 388 | { |
34c41c68 DE |
389 | if (strcmp (argv[i], "-pc") == 0) |
390 | { | |
391 | if (argv[i + 1] == NULL) | |
392 | error (_("Missing pc value")); | |
393 | address_arg = argv[++i]; | |
394 | } | |
395 | else if (strcmp (argv[i], "-source") == 0) | |
396 | { | |
397 | if (argv[i + 1] == NULL) | |
398 | error (_("Missing source file")); | |
399 | source_arg = argv[++i]; | |
400 | } | |
401 | else if (strcmp (argv[i], "-objfile") == 0) | |
402 | { | |
403 | if (argv[i + 1] == NULL) | |
404 | error (_("Missing objfile name")); | |
405 | objfile_arg = argv[++i]; | |
406 | } | |
407 | else if (strcmp (argv[i], "--") == 0) | |
408 | { | |
409 | /* End of options. */ | |
410 | ++i; | |
411 | break; | |
412 | } | |
413 | else if (argv[i][0] == '-') | |
c906108c | 414 | { |
34c41c68 DE |
415 | /* Future proofing: Don't allow OUTFILE to begin with "-". */ |
416 | error (_("Unknown option: %s"), argv[i]); | |
c906108c | 417 | } |
34c41c68 DE |
418 | else |
419 | break; | |
c906108c | 420 | } |
34c41c68 | 421 | outfile_idx = i; |
c906108c | 422 | |
34c41c68 DE |
423 | if (address_arg != NULL && source_arg != NULL) |
424 | error (_("Must specify at most one of -pc and -source")); | |
c5aa993b | 425 | |
d7e74731 PA |
426 | stdio_file arg_outfile; |
427 | ||
99e8a4f9 | 428 | if (argv != NULL && argv[outfile_idx] != NULL) |
34c41c68 | 429 | { |
34c41c68 DE |
430 | if (argv[outfile_idx + 1] != NULL) |
431 | error (_("Junk at end of command")); | |
ee0c3293 TT |
432 | gdb::unique_xmalloc_ptr<char> outfile_name |
433 | (tilde_expand (argv[outfile_idx])); | |
434 | if (!arg_outfile.open (outfile_name.get (), FOPEN_WT)) | |
435 | perror_with_name (outfile_name.get ()); | |
d7e74731 | 436 | outfile = &arg_outfile; |
34c41c68 | 437 | } |
c906108c | 438 | |
34c41c68 | 439 | if (address_arg != NULL) |
27618ce4 | 440 | { |
34c41c68 DE |
441 | CORE_ADDR pc = parse_and_eval_address (address_arg); |
442 | struct symtab *s = find_pc_line_symtab (pc); | |
443 | ||
444 | if (s == NULL) | |
445 | error (_("No symtab for address: %s"), address_arg); | |
446 | dump_symtab (s, outfile); | |
27618ce4 | 447 | } |
34c41c68 DE |
448 | else |
449 | { | |
34c41c68 DE |
450 | int found = 0; |
451 | ||
2030c079 | 452 | for (objfile *objfile : current_program_space->objfiles ()) |
34c41c68 DE |
453 | { |
454 | int print_for_objfile = 1; | |
455 | ||
456 | if (objfile_arg != NULL) | |
457 | print_for_objfile | |
458 | = compare_filenames_for_search (objfile_name (objfile), | |
459 | objfile_arg); | |
460 | if (!print_for_objfile) | |
461 | continue; | |
462 | ||
b669c953 | 463 | for (compunit_symtab *cu : objfile->compunits ()) |
34c41c68 | 464 | { |
102cc235 | 465 | for (symtab *s : cu->filetabs ()) |
34c41c68 | 466 | { |
d5da8b3c TT |
467 | int print_for_source = 0; |
468 | ||
469 | QUIT; | |
470 | if (source_arg != NULL) | |
471 | { | |
472 | print_for_source | |
473 | = compare_filenames_for_search | |
474 | (symtab_to_filename_for_display (s), source_arg); | |
475 | found = 1; | |
476 | } | |
477 | if (source_arg == NULL | |
478 | || print_for_source) | |
479 | dump_symtab (s, outfile); | |
34c41c68 | 480 | } |
34c41c68 DE |
481 | } |
482 | } | |
483 | ||
484 | if (source_arg != NULL && !found) | |
485 | error (_("No symtab for source file: %s"), source_arg); | |
486 | } | |
c906108c SS |
487 | } |
488 | ||
bf469271 | 489 | /* Print symbol SYMBOL on OUTFILE. DEPTH says how far to indent. */ |
c906108c | 490 | |
bf469271 PA |
491 | static void |
492 | print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, | |
493 | int depth, ui_file *outfile) | |
c906108c | 494 | { |
1994afbf DE |
495 | struct obj_section *section; |
496 | ||
7b3ecc75 | 497 | if (symbol->is_objfile_owned ()) |
e19b2d94 | 498 | section = symbol->obj_section (symbol->objfile ()); |
1994afbf DE |
499 | else |
500 | section = NULL; | |
c906108c | 501 | |
d0b1020b | 502 | print_spaces (depth, outfile); |
6c9c307c | 503 | if (symbol->domain () == LABEL_DOMAIN) |
c906108c | 504 | { |
6cb06a8c | 505 | gdb_printf (outfile, "label %s at ", symbol->print_name ()); |
4aeddc50 | 506 | gdb_puts (paddress (gdbarch, symbol->value_address ()), |
0426ad51 | 507 | outfile); |
714835d5 | 508 | if (section) |
6cb06a8c TT |
509 | gdb_printf (outfile, " section %s\n", |
510 | bfd_section_name (section->the_bfd_section)); | |
c906108c | 511 | else |
6cb06a8c | 512 | gdb_printf (outfile, "\n"); |
bf469271 | 513 | return; |
c906108c | 514 | } |
bf469271 | 515 | |
6c9c307c | 516 | if (symbol->domain () == STRUCT_DOMAIN) |
c906108c | 517 | { |
5f9c5a63 | 518 | if (symbol->type ()->name ()) |
c906108c | 519 | { |
13eb081a TT |
520 | current_language->print_type (symbol->type (), "", outfile, 1, depth, |
521 | &type_print_raw_options); | |
c906108c SS |
522 | } |
523 | else | |
524 | { | |
6cb06a8c TT |
525 | gdb_printf (outfile, "%s %s = ", |
526 | (symbol->type ()->code () == TYPE_CODE_ENUM | |
527 | ? "enum" | |
528 | : (symbol->type ()->code () == TYPE_CODE_STRUCT | |
529 | ? "struct" : "union")), | |
530 | symbol->linkage_name ()); | |
13eb081a TT |
531 | current_language->print_type (symbol->type (), "", outfile, 1, depth, |
532 | &type_print_raw_options); | |
c906108c | 533 | } |
6cb06a8c | 534 | gdb_printf (outfile, ";\n"); |
c906108c SS |
535 | } |
536 | else | |
537 | { | |
66d7f48f | 538 | if (symbol->aclass () == LOC_TYPEDEF) |
6cb06a8c | 539 | gdb_printf (outfile, "typedef "); |
5f9c5a63 | 540 | if (symbol->type ()) |
c906108c SS |
541 | { |
542 | /* Print details of types, except for enums where it's clutter. */ | |
13eb081a TT |
543 | current_language->print_type (symbol->type (), symbol->print_name (), |
544 | outfile, | |
545 | symbol->type ()->code () != TYPE_CODE_ENUM, | |
546 | depth, | |
547 | &type_print_raw_options); | |
6cb06a8c | 548 | gdb_printf (outfile, "; "); |
c906108c SS |
549 | } |
550 | else | |
6cb06a8c | 551 | gdb_printf (outfile, "%s ", symbol->print_name ()); |
c906108c | 552 | |
66d7f48f | 553 | switch (symbol->aclass ()) |
c906108c SS |
554 | { |
555 | case LOC_CONST: | |
6cb06a8c | 556 | gdb_printf (outfile, "const %s (%s)", |
4aeddc50 SM |
557 | plongest (symbol->value_longest ()), |
558 | hex_string (symbol->value_longest ())); | |
c906108c SS |
559 | break; |
560 | ||
561 | case LOC_CONST_BYTES: | |
562 | { | |
563 | unsigned i; | |
5f9c5a63 | 564 | struct type *type = check_typedef (symbol->type ()); |
433759f7 | 565 | |
6cb06a8c | 566 | gdb_printf (outfile, "const %s hex bytes:", |
df86565b SM |
567 | pulongest (type->length ())); |
568 | for (i = 0; i < type->length (); i++) | |
6cb06a8c | 569 | gdb_printf (outfile, " %02x", |
4aeddc50 | 570 | (unsigned) symbol->value_bytes ()[i]); |
c906108c SS |
571 | } |
572 | break; | |
573 | ||
574 | case LOC_STATIC: | |
6cb06a8c | 575 | gdb_printf (outfile, "static at "); |
4aeddc50 | 576 | gdb_puts (paddress (gdbarch, symbol->value_address ()), outfile); |
714835d5 | 577 | if (section) |
6cb06a8c TT |
578 | gdb_printf (outfile, " section %s", |
579 | bfd_section_name (section->the_bfd_section)); | |
c906108c SS |
580 | break; |
581 | ||
c906108c | 582 | case LOC_REGISTER: |
d9743061 | 583 | if (symbol->is_argument ()) |
6cb06a8c | 584 | gdb_printf (outfile, "parameter register %s", |
4aeddc50 | 585 | plongest (symbol->value_longest ())); |
2a2d4dc3 | 586 | else |
6cb06a8c | 587 | gdb_printf (outfile, "register %s", |
4aeddc50 | 588 | plongest (symbol->value_longest ())); |
c906108c SS |
589 | break; |
590 | ||
591 | case LOC_ARG: | |
6cb06a8c | 592 | gdb_printf (outfile, "arg at offset %s", |
4aeddc50 | 593 | hex_string (symbol->value_longest ())); |
c906108c SS |
594 | break; |
595 | ||
c906108c | 596 | case LOC_REF_ARG: |
6cb06a8c | 597 | gdb_printf (outfile, "reference arg at %s", |
4aeddc50 | 598 | hex_string (symbol->value_longest ())); |
c906108c SS |
599 | break; |
600 | ||
c906108c | 601 | case LOC_REGPARM_ADDR: |
6cb06a8c | 602 | gdb_printf (outfile, "address parameter register %s", |
4aeddc50 | 603 | plongest (symbol->value_longest ())); |
c906108c SS |
604 | break; |
605 | ||
606 | case LOC_LOCAL: | |
6cb06a8c | 607 | gdb_printf (outfile, "local at offset %s", |
4aeddc50 | 608 | hex_string (symbol->value_longest ())); |
c906108c SS |
609 | break; |
610 | ||
c906108c SS |
611 | case LOC_TYPEDEF: |
612 | break; | |
613 | ||
614 | case LOC_LABEL: | |
6cb06a8c | 615 | gdb_printf (outfile, "label at "); |
4aeddc50 | 616 | gdb_puts (paddress (gdbarch, symbol->value_address ()), outfile); |
714835d5 | 617 | if (section) |
6cb06a8c TT |
618 | gdb_printf (outfile, " section %s", |
619 | bfd_section_name (section->the_bfd_section)); | |
c906108c SS |
620 | break; |
621 | ||
622 | case LOC_BLOCK: | |
6cb06a8c | 623 | gdb_printf |
64b7cc50 | 624 | (outfile, "block object %s, %s..%s", |
4aeddc50 | 625 | host_address_to_string (symbol->value_block ()), |
4b8791e1 SM |
626 | paddress (gdbarch, symbol->value_block()->start ()), |
627 | paddress (gdbarch, symbol->value_block()->end ())); | |
714835d5 | 628 | if (section) |
6cb06a8c TT |
629 | gdb_printf (outfile, " section %s", |
630 | bfd_section_name (section->the_bfd_section)); | |
c906108c SS |
631 | break; |
632 | ||
4c2df51b | 633 | case LOC_COMPUTED: |
6cb06a8c | 634 | gdb_printf (outfile, "computed at runtime"); |
4c2df51b DJ |
635 | break; |
636 | ||
c906108c | 637 | case LOC_UNRESOLVED: |
6cb06a8c | 638 | gdb_printf (outfile, "unresolved"); |
c906108c SS |
639 | break; |
640 | ||
641 | case LOC_OPTIMIZED_OUT: | |
6cb06a8c | 642 | gdb_printf (outfile, "optimized out"); |
c906108c SS |
643 | break; |
644 | ||
c5aa993b | 645 | default: |
6cb06a8c TT |
646 | gdb_printf (outfile, "botched symbol class %x", |
647 | symbol->aclass ()); | |
c906108c SS |
648 | break; |
649 | } | |
650 | } | |
6cb06a8c | 651 | gdb_printf (outfile, "\n"); |
c906108c SS |
652 | } |
653 | ||
80480540 | 654 | static void |
e99c83e7 | 655 | maintenance_print_msymbols (const char *args, int from_tty) |
c906108c | 656 | { |
34c41c68 | 657 | struct ui_file *outfile = gdb_stdout; |
34c41c68 | 658 | char *objfile_arg = NULL; |
34c41c68 | 659 | int i, outfile_idx; |
07318b29 | 660 | |
c906108c SS |
661 | dont_repeat (); |
662 | ||
773a1edc | 663 | gdb_argv argv (args); |
c906108c | 664 | |
99e8a4f9 | 665 | for (i = 0; argv != NULL && argv[i] != NULL; ++i) |
c906108c | 666 | { |
34c41c68 | 667 | if (strcmp (argv[i], "-objfile") == 0) |
c906108c | 668 | { |
34c41c68 DE |
669 | if (argv[i + 1] == NULL) |
670 | error (_("Missing objfile name")); | |
671 | objfile_arg = argv[++i]; | |
672 | } | |
673 | else if (strcmp (argv[i], "--") == 0) | |
674 | { | |
675 | /* End of options. */ | |
676 | ++i; | |
677 | break; | |
c906108c | 678 | } |
34c41c68 DE |
679 | else if (argv[i][0] == '-') |
680 | { | |
681 | /* Future proofing: Don't allow OUTFILE to begin with "-". */ | |
682 | error (_("Unknown option: %s"), argv[i]); | |
683 | } | |
684 | else | |
685 | break; | |
c906108c | 686 | } |
34c41c68 | 687 | outfile_idx = i; |
c906108c | 688 | |
d7e74731 PA |
689 | stdio_file arg_outfile; |
690 | ||
99e8a4f9 | 691 | if (argv != NULL && argv[outfile_idx] != NULL) |
34c41c68 | 692 | { |
34c41c68 DE |
693 | if (argv[outfile_idx + 1] != NULL) |
694 | error (_("Junk at end of command")); | |
ee0c3293 TT |
695 | gdb::unique_xmalloc_ptr<char> outfile_name |
696 | (tilde_expand (argv[outfile_idx])); | |
697 | if (!arg_outfile.open (outfile_name.get (), FOPEN_WT)) | |
698 | perror_with_name (outfile_name.get ()); | |
d7e74731 | 699 | outfile = &arg_outfile; |
34c41c68 | 700 | } |
c5aa993b | 701 | |
2030c079 | 702 | for (objfile *objfile : current_program_space->objfiles ()) |
aed57c53 TT |
703 | { |
704 | QUIT; | |
705 | if (objfile_arg == NULL | |
706 | || compare_filenames_for_search (objfile_name (objfile), objfile_arg)) | |
707 | dump_msymbols (objfile, outfile); | |
708 | } | |
c906108c SS |
709 | } |
710 | ||
80480540 | 711 | static void |
e99c83e7 | 712 | maintenance_print_objfiles (const char *regexp, int from_tty) |
c906108c | 713 | { |
c906108c SS |
714 | dont_repeat (); |
715 | ||
52e260a3 DE |
716 | if (regexp) |
717 | re_comp (regexp); | |
718 | ||
94c93c35 | 719 | for (struct program_space *pspace : program_spaces) |
2030c079 | 720 | for (objfile *objfile : pspace->objfiles ()) |
27618ce4 TT |
721 | { |
722 | QUIT; | |
52e260a3 | 723 | if (! regexp |
4262abfb | 724 | || re_exec (objfile_name (objfile))) |
52e260a3 | 725 | dump_objfile (objfile); |
27618ce4 | 726 | } |
c906108c SS |
727 | } |
728 | ||
5e7b2f39 | 729 | /* List all the symbol tables whose names match REGEXP (optional). */ |
b5ebcee6 | 730 | |
80480540 | 731 | static void |
e99c83e7 | 732 | maintenance_info_symtabs (const char *regexp, int from_tty) |
44ea7b70 | 733 | { |
db68bbae DE |
734 | dont_repeat (); |
735 | ||
44ea7b70 JB |
736 | if (regexp) |
737 | re_comp (regexp); | |
738 | ||
94c93c35 | 739 | for (struct program_space *pspace : program_spaces) |
2030c079 | 740 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 741 | { |
99d89cde TT |
742 | /* We don't want to print anything for this objfile until we |
743 | actually find a symtab whose name matches. */ | |
744 | int printed_objfile_start = 0; | |
43f3e411 | 745 | |
b669c953 | 746 | for (compunit_symtab *cust : objfile->compunits ()) |
99d89cde TT |
747 | { |
748 | int printed_compunit_symtab_start = 0; | |
749 | ||
102cc235 | 750 | for (symtab *symtab : cust->filetabs ()) |
99d89cde TT |
751 | { |
752 | QUIT; | |
753 | ||
754 | if (! regexp | |
755 | || re_exec (symtab_to_filename_for_display (symtab))) | |
756 | { | |
757 | if (! printed_objfile_start) | |
758 | { | |
6cb06a8c | 759 | gdb_printf ("{ objfile %s ", objfile_name (objfile)); |
1285ce86 | 760 | gdb_stdout->wrap_here (2); |
6cb06a8c TT |
761 | gdb_printf ("((struct objfile *) %s)\n", |
762 | host_address_to_string (objfile)); | |
99d89cde TT |
763 | printed_objfile_start = 1; |
764 | } | |
765 | if (! printed_compunit_symtab_start) | |
766 | { | |
6cb06a8c TT |
767 | gdb_printf (" { ((struct compunit_symtab *) %s)\n", |
768 | host_address_to_string (cust)); | |
769 | gdb_printf (" debugformat %s\n", | |
770 | cust->debugformat ()); | |
771 | gdb_printf (" producer %s\n", | |
772 | (cust->producer () != nullptr | |
773 | ? cust->producer () : "(null)")); | |
af7047e8 | 774 | gdb_printf (" name %s\n", cust->name); |
6cb06a8c TT |
775 | gdb_printf (" dirname %s\n", |
776 | (cust->dirname () != NULL | |
777 | ? cust->dirname () : "(null)")); | |
778 | gdb_printf (" blockvector" | |
779 | " ((struct blockvector *) %s)\n", | |
780 | host_address_to_string | |
781 | (cust->blockvector ())); | |
782 | gdb_printf (" user" | |
783 | " ((struct compunit_symtab *) %s)\n", | |
784 | cust->user != nullptr | |
785 | ? host_address_to_string (cust->user) | |
786 | : "(null)"); | |
7b1eff95 TV |
787 | if (cust->includes != nullptr) |
788 | { | |
6cb06a8c | 789 | gdb_printf (" ( includes\n"); |
7b1eff95 TV |
790 | for (int i = 0; ; ++i) |
791 | { | |
792 | struct compunit_symtab *include | |
793 | = cust->includes[i]; | |
794 | if (include == nullptr) | |
795 | break; | |
796 | const char *addr | |
797 | = host_address_to_string (include); | |
6cb06a8c TT |
798 | gdb_printf (" (%s %s)\n", |
799 | "(struct compunit_symtab *)", | |
800 | addr); | |
7b1eff95 | 801 | } |
6cb06a8c | 802 | gdb_printf (" )\n"); |
7b1eff95 | 803 | } |
99d89cde TT |
804 | printed_compunit_symtab_start = 1; |
805 | } | |
806 | ||
6cb06a8c TT |
807 | gdb_printf ("\t{ symtab %s ", |
808 | symtab_to_filename_for_display (symtab)); | |
1285ce86 | 809 | gdb_stdout->wrap_here (4); |
6cb06a8c TT |
810 | gdb_printf ("((struct symtab *) %s)\n", |
811 | host_address_to_string (symtab)); | |
812 | gdb_printf ("\t fullname %s\n", | |
813 | symtab->fullname != NULL | |
814 | ? symtab->fullname | |
815 | : "(null)"); | |
816 | gdb_printf ("\t " | |
817 | "linetable ((struct linetable *) %s)\n", | |
818 | host_address_to_string | |
819 | (symtab->linetable ())); | |
820 | gdb_printf ("\t}\n"); | |
99d89cde TT |
821 | } |
822 | } | |
823 | ||
824 | if (printed_compunit_symtab_start) | |
6cb06a8c | 825 | gdb_printf (" }\n"); |
99d89cde | 826 | } |
44ea7b70 | 827 | |
99d89cde | 828 | if (printed_objfile_start) |
6cb06a8c | 829 | gdb_printf ("}\n"); |
99d89cde | 830 | } |
44ea7b70 | 831 | } |
7d0c9981 DE |
832 | |
833 | /* Check consistency of symtabs. | |
834 | An example of what this checks for is NULL blockvectors. | |
835 | They can happen if there's a bug during debug info reading. | |
836 | GDB assumes they are always non-NULL. | |
837 | ||
838 | Note: This does not check for psymtab vs symtab consistency. | |
839 | Use "maint check-psymtabs" for that. */ | |
840 | ||
841 | static void | |
e99c83e7 | 842 | maintenance_check_symtabs (const char *ignore, int from_tty) |
7d0c9981 | 843 | { |
94c93c35 | 844 | for (struct program_space *pspace : program_spaces) |
2030c079 | 845 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 846 | { |
99d89cde TT |
847 | /* We don't want to print anything for this objfile until we |
848 | actually find something worth printing. */ | |
849 | int printed_objfile_start = 0; | |
7d0c9981 | 850 | |
b669c953 | 851 | for (compunit_symtab *cust : objfile->compunits ()) |
99d89cde TT |
852 | { |
853 | int found_something = 0; | |
0b17a4f7 | 854 | struct symtab *symtab = cust->primary_filetab (); |
99d89cde TT |
855 | |
856 | QUIT; | |
857 | ||
af39c5c8 | 858 | if (cust->blockvector () == NULL) |
99d89cde TT |
859 | found_something = 1; |
860 | /* Add more checks here. */ | |
861 | ||
862 | if (found_something) | |
863 | { | |
864 | if (! printed_objfile_start) | |
865 | { | |
6cb06a8c | 866 | gdb_printf ("{ objfile %s ", objfile_name (objfile)); |
1285ce86 | 867 | gdb_stdout->wrap_here (2); |
6cb06a8c TT |
868 | gdb_printf ("((struct objfile *) %s)\n", |
869 | host_address_to_string (objfile)); | |
99d89cde TT |
870 | printed_objfile_start = 1; |
871 | } | |
6cb06a8c TT |
872 | gdb_printf (" { symtab %s\n", |
873 | symtab_to_filename_for_display (symtab)); | |
af39c5c8 | 874 | if (cust->blockvector () == NULL) |
6cb06a8c TT |
875 | gdb_printf (" NULL blockvector\n"); |
876 | gdb_printf (" }\n"); | |
99d89cde TT |
877 | } |
878 | } | |
7d0c9981 | 879 | |
99d89cde | 880 | if (printed_objfile_start) |
6cb06a8c | 881 | gdb_printf ("}\n"); |
99d89cde | 882 | } |
7d0c9981 DE |
883 | } |
884 | ||
7d0c9981 DE |
885 | /* Expand all symbol tables whose name matches an optional regexp. */ |
886 | ||
887 | static void | |
e99c83e7 | 888 | maintenance_expand_symtabs (const char *args, int from_tty) |
7d0c9981 | 889 | { |
7d0c9981 DE |
890 | char *regexp = NULL; |
891 | ||
892 | /* We use buildargv here so that we handle spaces in the regexp | |
893 | in a way that allows adding more arguments later. */ | |
773a1edc | 894 | gdb_argv argv (args); |
7d0c9981 DE |
895 | |
896 | if (argv != NULL) | |
897 | { | |
898 | if (argv[0] != NULL) | |
899 | { | |
900 | regexp = argv[0]; | |
901 | if (argv[1] != NULL) | |
902 | error (_("Extra arguments after regexp.")); | |
903 | } | |
904 | } | |
905 | ||
906 | if (regexp) | |
907 | re_comp (regexp); | |
908 | ||
94c93c35 | 909 | for (struct program_space *pspace : program_spaces) |
2030c079 | 910 | for (objfile *objfile : pspace->objfiles ()) |
4d080b46 TT |
911 | objfile->expand_symtabs_matching |
912 | ([&] (const char *filename, bool basenames) | |
913 | { | |
914 | /* KISS: Only apply the regexp to the complete file name. */ | |
915 | return (!basenames | |
916 | && (regexp == NULL || re_exec (filename))); | |
917 | }, | |
918 | NULL, | |
919 | NULL, | |
920 | NULL, | |
03a8ea51 | 921 | SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK, |
f214edce | 922 | SEARCH_ALL_DOMAINS); |
7d0c9981 | 923 | } |
c906108c | 924 | \f |
c5aa993b | 925 | |
c906108c SS |
926 | /* Return the nexting depth of a block within other blocks in its symtab. */ |
927 | ||
928 | static int | |
582942f4 | 929 | block_depth (const struct block *block) |
c906108c | 930 | { |
52f0bd74 | 931 | int i = 0; |
433759f7 | 932 | |
f135fe72 | 933 | while ((block = block->superblock ()) != NULL) |
c906108c SS |
934 | { |
935 | i++; | |
936 | } | |
937 | return i; | |
938 | } | |
c906108c | 939 | \f |
c5aa993b | 940 | |
f2403c39 AB |
941 | /* Used by MAINTENANCE_INFO_LINE_TABLES to print the information about a |
942 | single line table. */ | |
943 | ||
944 | static int | |
945 | maintenance_print_one_line_table (struct symtab *symtab, void *data) | |
946 | { | |
977a0c16 | 947 | const struct linetable *linetable; |
f2403c39 AB |
948 | struct objfile *objfile; |
949 | ||
c6159652 | 950 | objfile = symtab->compunit ()->objfile (); |
6cb06a8c TT |
951 | gdb_printf (_("objfile: %ps ((struct objfile *) %s)\n"), |
952 | styled_string (file_name_style.style (), | |
953 | objfile_name (objfile)), | |
954 | host_address_to_string (objfile)); | |
955 | gdb_printf (_("compunit_symtab: %s ((struct compunit_symtab *) %s)\n"), | |
956 | symtab->compunit ()->name, | |
957 | host_address_to_string (symtab->compunit ())); | |
958 | gdb_printf (_("symtab: %ps ((struct symtab *) %s)\n"), | |
959 | styled_string (file_name_style.style (), | |
960 | symtab_to_fullname (symtab)), | |
961 | host_address_to_string (symtab)); | |
5b607461 | 962 | linetable = symtab->linetable (); |
6cb06a8c TT |
963 | gdb_printf (_("linetable: ((struct linetable *) %s):\n"), |
964 | host_address_to_string (linetable)); | |
f2403c39 AB |
965 | |
966 | if (linetable == NULL) | |
6cb06a8c | 967 | gdb_printf (_("No line table.\n")); |
f2403c39 | 968 | else if (linetable->nitems <= 0) |
6cb06a8c | 969 | gdb_printf (_("Line table has no lines.\n")); |
f2403c39 AB |
970 | else |
971 | { | |
f2403c39 AB |
972 | /* Leave space for 6 digits of index and line number. After that the |
973 | tables will just not format as well. */ | |
1773be9e | 974 | struct ui_out *uiout = current_uiout; |
528b729b | 975 | ui_out_emit_table table_emitter (uiout, 7, -1, "line-table"); |
1773be9e TT |
976 | uiout->table_header (6, ui_left, "index", _("INDEX")); |
977 | uiout->table_header (6, ui_left, "line", _("LINE")); | |
904d9b02 SM |
978 | uiout->table_header (18, ui_left, "rel-address", _("REL-ADDRESS")); |
979 | uiout->table_header (18, ui_left, "unrel-address", _("UNREL-ADDRESS")); | |
cc96ae7f LS |
980 | uiout->table_header (7, ui_left, "is-stmt", _("IS-STMT")); |
981 | uiout->table_header (12, ui_left, "prologue-end", _("PROLOGUE-END")); | |
528b729b | 982 | uiout->table_header (14, ui_left, "epilogue-begin", _("EPILOGUE-BEGIN")); |
1773be9e TT |
983 | uiout->table_body (); |
984 | ||
985 | for (int i = 0; i < linetable->nitems; ++i) | |
f2403c39 | 986 | { |
977a0c16 | 987 | const linetable_entry *item; |
f2403c39 AB |
988 | |
989 | item = &linetable->item [i]; | |
1773be9e TT |
990 | ui_out_emit_tuple tuple_emitter (uiout, nullptr); |
991 | uiout->field_signed ("index", i); | |
94a72be7 | 992 | if (item->line > 0) |
1773be9e | 993 | uiout->field_signed ("line", item->line); |
94a72be7 | 994 | else |
1773be9e | 995 | uiout->field_string ("line", _("END")); |
904d9b02 SM |
996 | uiout->field_core_addr ("rel-address", objfile->arch (), |
997 | item->pc (objfile)); | |
998 | uiout->field_core_addr ("unrel-address", objfile->arch (), | |
0434c3ef | 999 | CORE_ADDR (item->unrelocated_pc ())); |
1773be9e | 1000 | uiout->field_string ("is-stmt", item->is_stmt ? "Y" : ""); |
cc96ae7f | 1001 | uiout->field_string ("prologue-end", item->prologue_end ? "Y" : ""); |
528b729b | 1002 | uiout->field_string ("epilogue-begin", item->epilogue_begin ? "Y" : ""); |
1773be9e | 1003 | uiout->text ("\n"); |
f2403c39 AB |
1004 | } |
1005 | } | |
1006 | ||
1007 | return 0; | |
1008 | } | |
1009 | ||
1010 | /* Implement the 'maint info line-table' command. */ | |
1011 | ||
1012 | static void | |
e99c83e7 | 1013 | maintenance_info_line_tables (const char *regexp, int from_tty) |
f2403c39 | 1014 | { |
f2403c39 AB |
1015 | dont_repeat (); |
1016 | ||
1017 | if (regexp != NULL) | |
1018 | re_comp (regexp); | |
1019 | ||
94c93c35 | 1020 | for (struct program_space *pspace : program_spaces) |
2030c079 | 1021 | for (objfile *objfile : pspace->objfiles ()) |
99d89cde | 1022 | { |
b669c953 | 1023 | for (compunit_symtab *cust : objfile->compunits ()) |
99d89cde | 1024 | { |
102cc235 | 1025 | for (symtab *symtab : cust->filetabs ()) |
99d89cde TT |
1026 | { |
1027 | QUIT; | |
1028 | ||
1029 | if (regexp == NULL | |
1030 | || re_exec (symtab_to_filename_for_display (symtab))) | |
92228a33 SM |
1031 | { |
1032 | maintenance_print_one_line_table (symtab, NULL); | |
6cb06a8c | 1033 | gdb_printf ("\n"); |
92228a33 | 1034 | } |
99d89cde TT |
1035 | } |
1036 | } | |
1037 | } | |
f2403c39 AB |
1038 | } |
1039 | ||
1040 | \f | |
1041 | ||
c378eb4e | 1042 | /* Do early runtime initializations. */ |
b5ebcee6 | 1043 | |
6c265988 | 1044 | void _initialize_symmisc (); |
c906108c | 1045 | void |
6c265988 | 1046 | _initialize_symmisc () |
c906108c | 1047 | { |
80480540 YQ |
1048 | add_cmd ("symbols", class_maintenance, maintenance_print_symbols, _("\ |
1049 | Print dump of current symbol definitions.\n\ | |
48c5e7e2 TT |
1050 | Usage: mt print symbols [-pc ADDRESS] [--] [OUTFILE]\n\ |
1051 | mt print symbols [-objfile OBJFILE] [-source SOURCE] [--] [OUTFILE]\n\ | |
34c41c68 DE |
1052 | Entries in the full symbol table are dumped to file OUTFILE,\n\ |
1053 | or the terminal if OUTFILE is unspecified.\n\ | |
98011164 | 1054 | If ADDRESS is provided, dump only the symbols for the file with code at that address.\n\ |
34c41c68 | 1055 | If SOURCE is provided, dump only that file's symbols.\n\ |
98011164 | 1056 | If OBJFILE is provided, dump only that object file's symbols."), |
80480540 YQ |
1057 | &maintenanceprintlist); |
1058 | ||
1059 | add_cmd ("msymbols", class_maintenance, maintenance_print_msymbols, _("\ | |
1060 | Print dump of current minimal symbol definitions.\n\ | |
48c5e7e2 | 1061 | Usage: mt print msymbols [-objfile OBJFILE] [--] [OUTFILE]\n\ |
34c41c68 DE |
1062 | Entries in the minimal symbol table are dumped to file OUTFILE,\n\ |
1063 | or the terminal if OUTFILE is unspecified.\n\ | |
1064 | If OBJFILE is provided, dump only that file's minimal symbols."), | |
80480540 YQ |
1065 | &maintenanceprintlist); |
1066 | ||
1067 | add_cmd ("objfiles", class_maintenance, maintenance_print_objfiles, | |
52e260a3 DE |
1068 | _("Print dump of current object file definitions.\n\ |
1069 | With an argument REGEXP, list the object files with matching names."), | |
80480540 YQ |
1070 | &maintenanceprintlist); |
1071 | ||
1072 | add_cmd ("symtabs", class_maintenance, maintenance_info_symtabs, _("\ | |
1073 | List the full symbol tables for all object files.\n\ | |
1074 | This does not include information about individual symbols, blocks, or\n\ | |
1075 | linetables --- just the symbol table structures themselves.\n\ | |
db68bbae | 1076 | With an argument REGEXP, list the symbol tables with matching names."), |
80480540 | 1077 | &maintenanceinfolist); |
7d0c9981 | 1078 | |
f2403c39 AB |
1079 | add_cmd ("line-table", class_maintenance, maintenance_info_line_tables, _("\ |
1080 | List the contents of all line tables, from all symbol tables.\n\ | |
1081 | With an argument REGEXP, list just the line tables for the symbol\n\ | |
1082 | tables with matching names."), | |
1083 | &maintenanceinfolist); | |
1084 | ||
7d0c9981 DE |
1085 | add_cmd ("check-symtabs", class_maintenance, maintenance_check_symtabs, |
1086 | _("\ | |
1087 | Check consistency of currently expanded symtabs."), | |
1088 | &maintenancelist); | |
1089 | ||
1090 | add_cmd ("expand-symtabs", class_maintenance, maintenance_expand_symtabs, | |
1091 | _("Expand symbol tables.\n\ | |
1092 | With an argument REGEXP, only expand the symbol tables with matching names."), | |
1093 | &maintenancelist); | |
c906108c | 1094 | } |