]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/symmisc.c
2.41 Release sources
[thirdparty/binutils-gdb.git] / gdb / symmisc.c
index 097dc2dd3556b54685bd9b4c9e5b92af05d94c0a..a65552aa2d22f744896c86f732a292b5a6a0340b 100644 (file)
@@ -1,6 +1,6 @@
 /* Do various things to symbol tables (other than lookup), for GDB.
 
-   Copyright (C) 1986-2022 Free Software Foundation, Inc.
+   Copyright (C) 1986-2023 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -116,7 +116,7 @@ dump_objfile (struct objfile *objfile)
   gdb_printf ("\nObject file %s:  ", objfile_name (objfile));
   gdb_printf ("Objfile at %s, bfd at %s, %d minsyms\n\n",
              host_address_to_string (objfile),
-             host_address_to_string (objfile->obfd),
+             host_address_to_string (objfile->obfd.get ()),
              objfile->per_bfd->minimal_symbol_count);
 
   objfile->dump ();
@@ -201,7 +201,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
 
       /* Use the relocated address as shown in the symbol here -- do
         not try to respect copy relocations.  */
-      CORE_ADDR addr = (msymbol->value_raw_address ()
+      CORE_ADDR addr = (CORE_ADDR (msymbol->unrelocated_address ())
                        + objfile->section_offsets[msymbol->section_index ()]);
       gdb_puts (paddress (gdbarch, addr), outfile);
       gdb_printf (outfile, " %s", msymbol->linkage_name ());
@@ -212,7 +212,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile)
                        bfd_section_name (section->the_bfd_section));
          else
            gdb_printf (outfile, " spurious section %ld",
-                       (long) (section - objfile->sections));
+                       (long) (section - objfile->sections_start));
        }
       if (msymbol->demangled_name () != NULL)
        {
@@ -236,13 +236,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
 {
   struct objfile *objfile = symtab->compunit ()->objfile ();
   struct gdbarch *gdbarch = objfile->arch ();
-  int i;
-  struct mdict_iterator miter;
-  int len;
-  struct linetable *l;
-  const struct blockvector *bv;
-  struct symbol *sym;
-  const struct block *b;
+  const struct linetable *l;
   int depth;
 
   gdb_printf (outfile, "\nSymtab for file %s at %s\n",
@@ -263,11 +257,11 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
   if (l)
     {
       gdb_printf (outfile, "\nLine table:\n\n");
-      len = l->nitems;
-      for (i = 0; i < len; i++)
+      int len = l->nitems;
+      for (int i = 0; i < len; i++)
        {
          gdb_printf (outfile, " line %d at ", l->item[i].line);
-         gdb_puts (paddress (gdbarch, l->item[i].pc), outfile);
+         gdb_puts (paddress (gdbarch, l->item[i].pc (objfile)), outfile);
          if (l->item[i].is_stmt)
            gdb_printf (outfile, "\t(stmt)");
          gdb_printf (outfile, "\n");
@@ -278,41 +272,40 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
   if (is_main_symtab_of_compunit_symtab (symtab))
     {
       gdb_printf (outfile, "\nBlockvector:\n\n");
-      bv = symtab->compunit ()->blockvector ();
-      len = BLOCKVECTOR_NBLOCKS (bv);
-      for (i = 0; i < len; i++)
+      const blockvector *bv = symtab->compunit ()->blockvector ();
+      for (int i = 0; i < bv->num_blocks (); i++)
        {
-         b = BLOCKVECTOR_BLOCK (bv, i);
+         const block *b = bv->block (i);
          depth = block_depth (b) * 2;
          gdb_printf (outfile, "%*sblock #%03d, object at %s",
                      depth, "", i,
                      host_address_to_string (b));
-         if (BLOCK_SUPERBLOCK (b))
+         if (b->superblock ())
            gdb_printf (outfile, " under %s",
-                       host_address_to_string (BLOCK_SUPERBLOCK (b)));
+                       host_address_to_string (b->superblock ()));
          /* drow/2002-07-10: We could save the total symbols count
             even if we're using a hashtable, but nothing else but this message
             wants it.  */
-         gdb_printf (outfile, ", %d syms/buckets in ",
-                     mdict_size (BLOCK_MULTIDICT (b)));
+         gdb_printf (outfile, ", %d symbols in ",
+                     mdict_size (b->multidict ()));
          gdb_puts (paddress (gdbarch, b->start ()), outfile);
          gdb_printf (outfile, "..");
          gdb_puts (paddress (gdbarch, b->end ()), outfile);
-         if (BLOCK_FUNCTION (b))
+         if (b->function ())
            {
              gdb_printf (outfile, ", function %s",
-                         BLOCK_FUNCTION (b)->linkage_name ());
-             if (BLOCK_FUNCTION (b)->demangled_name () != NULL)
+                         b->function ()->linkage_name ());
+             if (b->function ()->demangled_name () != NULL)
                {
                  gdb_printf (outfile, ", %s",
-                             BLOCK_FUNCTION (b)->demangled_name ());
+                             b->function ()->demangled_name ());
                }
            }
          gdb_printf (outfile, "\n");
          /* Now print each symbol in this block (in no particular order, if
             we're using a hashtable).  Note that we only want this
             block, not any blocks from included symtabs.  */
-         ALL_DICT_SYMBOLS (BLOCK_MULTIDICT (b), miter, sym)
+         for (struct symbol *sym : b->multidict_symbols ())
            {
              try
                {
@@ -351,7 +344,7 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
          gdb_printf (outfile, "Compunit user: %s\n", addr);
        }
       if (cust->includes != nullptr)
-       for (i = 0; ; ++i)
+       for (int i = 0; ; ++i)
          {
            struct compunit_symtab *include = cust->includes[i];
            if (include == nullptr)
@@ -370,8 +363,7 @@ dump_symtab (struct symtab *symtab, struct ui_file *outfile)
      because certain routines used during dump_symtab() use the current
      language to print an image of the symbol.  We'll restore it later.
      But use only real languages, not placeholders.  */
-  if (symtab->language () != language_unknown
-      && symtab->language () != language_auto)
+  if (symtab->language () != language_unknown)
     {
       scoped_restore_current_language save_lang;
       set_language (symtab->language ());
@@ -572,8 +564,8 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
            struct type *type = check_typedef (symbol->type ());
 
            gdb_printf (outfile, "const %s hex bytes:",
-                       pulongest (TYPE_LENGTH (type)));
-           for (i = 0; i < TYPE_LENGTH (type); i++)
+                       pulongest (type->length ()));
+           for (i = 0; i < type->length (); i++)
              gdb_printf (outfile, " %02x",
                          (unsigned) symbol->value_bytes ()[i]);
          }
@@ -939,7 +931,7 @@ block_depth (const struct block *block)
 {
   int i = 0;
 
-  while ((block = BLOCK_SUPERBLOCK (block)) != NULL)
+  while ((block = block->superblock ()) != NULL)
     {
       i++;
     }
@@ -953,7 +945,7 @@ block_depth (const struct block *block)
 static int
 maintenance_print_one_line_table (struct symtab *symtab, void *data)
 {
-  struct linetable *linetable;
+  const struct linetable *linetable;
   struct objfile *objfile;
 
   objfile = symtab->compunit ()->objfile ();
@@ -981,17 +973,18 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
       /* 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, 5, -1, "line-table");
+      ui_out_emit_table table_emitter (uiout, 6, -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 (18, ui_left, "rel-address", _("REL-ADDRESS"));
+      uiout->table_header (18, ui_left, "unrel-address", _("UNREL-ADDRESS"));
       uiout->table_header (7, ui_left, "is-stmt", _("IS-STMT"));
       uiout->table_header (12, ui_left, "prologue-end", _("PROLOGUE-END"));
       uiout->table_body ();
 
       for (int i = 0; i < linetable->nitems; ++i)
        {
-         struct linetable_entry *item;
+         const linetable_entry *item;
 
          item = &linetable->item [i];
          ui_out_emit_tuple tuple_emitter (uiout, nullptr);
@@ -1000,8 +993,10 @@ maintenance_print_one_line_table (struct symtab *symtab, void *data)
            uiout->field_signed ("line", item->line);
          else
            uiout->field_string ("line", _("END"));
-         uiout->field_core_addr ("address", objfile->arch (),
-                                 item->pc);
+         uiout->field_core_addr ("rel-address", objfile->arch (),
+                                 item->pc (objfile));
+         uiout->field_core_addr ("unrel-address", objfile->arch (),
+                                 CORE_ADDR (item->unrelocated_pc ()));
          uiout->field_string ("is-stmt", item->is_stmt ? "Y" : "");
          uiout->field_string ("prologue-end", item->prologue_end ? "Y" : "");
          uiout->text ("\n");