Introduce partial_symbol::address
authorTom Tromey <tom@tromey.com>
Thu, 3 May 2018 22:36:18 +0000 (16:36 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 26 Jul 2018 15:18:30 +0000 (09:18 -0600)
This introduces a partial_symbol::address method.  This method takes
an objfile argument.  This is necessary so that we can later relocate
a partial symbol at its point of use.  It also adds an accessor to
compute the unrelocated value; and a method to be used for setting the
field.

Note that the new method doesn't actually perform any relocation yet.
That will come in a subsequent patch.  However, the comments are
written to reflect the intended, rather than the temporary, semantics.

gdb/ChangeLog
2018-07-26  Tom Tromey  <tromey@redhat.com>

* psympriv.h (struct partial_symbol) <unrelocated_address,
address, set_address>: New methods.
* psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol)
(fixup_psymbol_section, relocate_psymtabs): Update.
(print_partial_symbols): Add 'objfile' parameter.  Update.
(dump_psymtab, add_psymbol_to_bcache, psym_fill_psymbol_map):
Update.

gdb/ChangeLog
gdb/psympriv.h
gdb/psymtab.c

index c6df5ebec7cd903f6f4a2acd3fd91e80d13ba4dc..8c6471b9a9e39e040634f5be3132e127b04e973f 100644 (file)
@@ -1,3 +1,13 @@
+2018-07-26  Tom Tromey  <tromey@redhat.com>
+
+       * psympriv.h (struct partial_symbol) <unrelocated_address,
+       address, set_address>: New methods.
+       * psymtab.c (find_pc_sect_psymtab_closer, find_pc_sect_psymbol)
+       (fixup_psymbol_section, relocate_psymtabs): Update.
+       (print_partial_symbols): Add 'objfile' parameter.  Update.
+       (dump_psymtab, add_psymbol_to_bcache, psym_fill_psymbol_map):
+       Update.
+
 2018-07-26  Tom Tromey  <tom@tromey.com>
 
        * dwarf-index-write.c (write_psymbols, debug_names::insert)
index f3cb0a6ba15beedbc34c07107ddc44db4625a9d7..be574bf8b7442331c79235b68789450c2cf9dbc1 100644 (file)
@@ -44,6 +44,26 @@ struct partial_symbol : public general_symbol_info
     return nullptr;
   }
 
+  /* Return the unrelocated address of this partial symbol.  */
+  CORE_ADDR unrelocated_address () const
+  {
+    return value.address;
+  }
+
+  /* Return the address of this partial symbol, relocated according to
+     the offsets provided in OBJFILE.  */
+  CORE_ADDR address (const struct objfile *objfile) const
+  {
+    return value.address;
+  }
+
+  /* Set the address of this partial symbol.  The address must be
+     unrelocated.  */
+  void set_address (CORE_ADDR addr)
+  {
+    value.address = addr;
+  }
+
   /* Name space code.  */
 
   ENUM_BITFIELD(domain_enum_tag) domain : SYMBOL_DOMAIN_BITS;
index 9a06d68f91edc89f3438fd1883b8f743d7afe559..f144fa339655dab764754ec3acf86d3dab366bc4 100644 (file)
@@ -267,7 +267,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
             object's symbol table.  */
          p = find_pc_sect_psymbol (objfile, tpst, pc, section);
          if (p != NULL
-             && (p->value.address == BMSYMBOL_VALUE_ADDRESS (msymbol)))
+             && (p->address (objfile) == BMSYMBOL_VALUE_ADDRESS (msymbol)))
            return tpst;
 
          /* Also accept the textlow value of a psymtab as a
@@ -275,7 +275,7 @@ find_pc_sect_psymtab_closer (struct objfile *objfile,
             symbol tables with line information but no debug
             symbols (e.g. those produced by an assembler).  */
          if (p != NULL)
-           this_addr = p->value.address;
+           this_addr = p->address (objfile);
          else
            this_addr = tpst->textlow;
 
@@ -333,7 +333,8 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
                 object's symbol table.  */
              p = find_pc_sect_psymbol (objfile, pst, pc, section);
              if (p == NULL
-                 || (p->value.address != BMSYMBOL_VALUE_ADDRESS (msymbol)))
+                 || (p->address (objfile)
+                     != BMSYMBOL_VALUE_ADDRESS (msymbol)))
                goto next;
            }
 
@@ -425,10 +426,10 @@ find_pc_sect_psymbol (struct objfile *objfile,
 
       if (p->domain == VAR_DOMAIN
          && p->aclass == LOC_BLOCK
-         && pc >= p->value.address
-         && (p->value.address > best_pc
+         && pc >= p->address (objfile)
+         && (p->address (objfile) > best_pc
              || (psymtab->textlow == 0
-                 && best_pc == 0 && p->value.address == 0)))
+                 && best_pc == 0 && p->address (objfile) == 0)))
        {
          if (section != NULL)  /* Match on a specific section.  */
            {
@@ -437,7 +438,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
                                          section))
                continue;
            }
-         best_pc = p->value.address;
+         best_pc = p->address (objfile);
          best = p;
        }
     }
@@ -448,10 +449,10 @@ find_pc_sect_psymbol (struct objfile *objfile,
 
       if (p->domain == VAR_DOMAIN
          && p->aclass == LOC_BLOCK
-         && pc >= p->value.address
-         && (p->value.address > best_pc
+         && pc >= p->address (objfile)
+         && (p->address (objfile) > best_pc
              || (psymtab->textlow == 0
-                 && best_pc == 0 && p->value.address == 0)))
+                 && best_pc == 0 && p->address (objfile) == 0)))
        {
          if (section != NULL)  /* Match on a specific section.  */
            {
@@ -460,7 +461,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
                                          section))
                continue;
            }
-         best_pc = p->value.address;
+         best_pc = p->address (objfile);
          best = p;
        }
     }
@@ -486,7 +487,7 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
     case LOC_STATIC:
     case LOC_LABEL:
     case LOC_BLOCK:
-      addr = psym->value.address;
+      addr = psym->address (objfile);
       break;
     default:
       /* Nothing else will be listed in the minsyms -- no use looking
@@ -813,13 +814,15 @@ psym_relocate (struct objfile *objfile,
     {
       fixup_psymbol_section (psym, objfile);
       if (psym->section >= 0)
-       psym->value.address += ANOFFSET (delta, psym->section);
+       psym->set_address (psym->unrelocated_address ()
+                          + ANOFFSET (delta, psym->section));
     }
   for (partial_symbol *psym : objfile->static_psymbols)
     {
       fixup_psymbol_section (psym, objfile);
       if (psym->section >= 0)
-       psym->value.address += ANOFFSET (delta, psym->section);
+       psym->set_address (psym->unrelocated_address ()
+                          + ANOFFSET (delta, psym->section));
     }
 
   objfile->psymbol_map.clear ();
@@ -883,7 +886,7 @@ psym_forget_cached_source_info (struct objfile *objfile)
 }
 
 static void
-print_partial_symbols (struct gdbarch *gdbarch,
+print_partial_symbols (struct gdbarch *gdbarch, struct objfile *objfile,
                       struct partial_symbol **p, int count, const char *what,
                       struct ui_file *outfile)
 {
@@ -967,7 +970,7 @@ print_partial_symbols (struct gdbarch *gdbarch,
          break;
        }
       fputs_filtered (", ", outfile);
-      fputs_filtered (paddress (gdbarch, (*p)->value.address), outfile);
+      fputs_filtered (paddress (gdbarch, (*p)->unrelocated_address ()), outfile);
       fprintf_filtered (outfile, "\n");
       p++;
     }
@@ -1032,13 +1035,13 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
     }
   if (psymtab->n_global_syms > 0)
     {
-      print_partial_symbols (gdbarch,
+      print_partial_symbols (gdbarch, objfile,
                             &objfile->global_psymbols[psymtab->globals_offset],
                             psymtab->n_global_syms, "Global", outfile);
     }
   if (psymtab->n_static_syms > 0)
     {
-      print_partial_symbols (gdbarch,
+      print_partial_symbols (gdbarch, objfile,
                             &objfile->static_psymbols[psymtab->statics_offset],
                             psymtab->n_static_syms, "Static", outfile);
     }
@@ -1475,7 +1478,7 @@ psym_fill_psymbol_map (struct objfile *objfile,
 
       if (psym->aclass == LOC_STATIC)
        {
-         CORE_ADDR addr = psym->value.address;
+         CORE_ADDR addr = psym->address (objfile);
          if (seen_addrs->find (addr) == seen_addrs->end ())
            {
              seen_addrs->insert (addr);
@@ -1718,7 +1721,7 @@ add_psymbol_to_bcache (const char *name, int namelength, int copy_name,
 {
   struct partial_symbol psymbol;
 
-  psymbol.value.address = coreaddr;
+  psymbol.set_address (coreaddr);
   psymbol.section = -1;
   psymbol.domain = domain;
   psymbol.aclass = theclass;
This page took 0.035602 seconds and 4 git commands to generate.