+/* Used by MAINTENANCE_INFO_LINE_TABLES to print the information about a
+ single line table. */
+
+static int
+maintenance_print_one_line_table (struct symtab *symtab, void *data)
+{
+ struct linetable *linetable;
+ struct objfile *objfile;
+
+ objfile = symtab->compunit_symtab->objfile;
+ printf_filtered (_("objfile: %s ((struct objfile *) %s)\n"),
+ objfile_name (objfile),
+ host_address_to_string (objfile));
+ printf_filtered (_("compunit_symtab: ((struct compunit_symtab *) %s)\n"),
+ host_address_to_string (symtab->compunit_symtab));
+ printf_filtered (_("symtab: %s ((struct symtab *) %s)\n"),
+ symtab_to_fullname (symtab),
+ host_address_to_string (symtab));
+ linetable = SYMTAB_LINETABLE (symtab);
+ printf_filtered (_("linetable: ((struct linetable *) %s):\n"),
+ host_address_to_string (linetable));
+
+ if (linetable == NULL)
+ printf_filtered (_("No line table.\n"));
+ else if (linetable->nitems <= 0)
+ printf_filtered (_("Line table has no lines.\n"));
+ else
+ {
+ /* Leave space for 6 digits of index and line number. After that the
+ tables will just not format as well. */
+ struct ui_out *uiout = current_uiout;
+ ui_out_emit_table table_emitter (uiout, 4, -1, "line-table");
+ uiout->table_header (6, ui_left, "index", _("INDEX"));
+ uiout->table_header (6, ui_left, "line", _("LINE"));
+ uiout->table_header (18, ui_left, "address", _("ADDRESS"));
+ uiout->table_header (1, ui_left, "is-stmt", _("IS-STMT"));
+ uiout->table_body ();
+
+ for (int i = 0; i < linetable->nitems; ++i)
+ {
+ struct linetable_entry *item;
+
+ item = &linetable->item [i];
+ ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+ uiout->field_signed ("index", i);
+ if (item->line > 0)
+ uiout->field_signed ("line", item->line);
+ else
+ uiout->field_string ("line", _("END"));
+ uiout->field_core_addr ("address", objfile->arch (),
+ item->pc);
+ uiout->field_string ("is-stmt", item->is_stmt ? "Y" : "");
+ uiout->text ("\n");
+ }
+ }
+
+ return 0;
+}
+
+/* Implement the 'maint info line-table' command. */
+
+static void
+maintenance_info_line_tables (const char *regexp, int from_tty)
+{
+ dont_repeat ();
+
+ if (regexp != NULL)
+ re_comp (regexp);
+
+ for (struct program_space *pspace : program_spaces)
+ for (objfile *objfile : pspace->objfiles ())
+ {
+ for (compunit_symtab *cust : objfile->compunits ())
+ {
+ for (symtab *symtab : compunit_filetabs (cust))
+ {
+ QUIT;
+
+ if (regexp == NULL
+ || re_exec (symtab_to_filename_for_display (symtab)))
+ maintenance_print_one_line_table (symtab, NULL);
+ }
+ }
+ }
+}
+
+\f
+