summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-08-20 15:04:50 +0000
committerTom Tromey <tromey@redhat.com>2013-08-20 15:04:50 +0000
commitc68c091dc292c9df749bfdbc9f9e455c4768dfcf (patch)
tree71f7c10748b5d23a83427463901e4222ac8c5ba6
parentd2d590480e6b5fe0f4eb65b98faf337290a4ba8e (diff)
downloadgdb-c68c091dc292c9df749bfdbc9f9e455c4768dfcf.tar.gz
move gdbarch object from objfile to per-BFD
This moves the "gdbarch" field from the objfile into the BFD. This field's value is derived from the BFD and is immutable over the lifetime of the BFD. This makes it a reasonable candidate for pushing into the per-BFD object. This is part of the long-term objfile splitting project. In the long run I think this patch will make it simpler to moves types from the objfile to the per-BFD object; but the patch makes sense as a minor cleanup by itself. Built and regtested on x86-64 Fedora 18. * cp-namespace.c (cp_lookup_symbol_imports_or_template): Use get_objfile_arch. * elfread.c (elf_rel_plt_read, elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Use get_objfile_arch. * jit.c (jit_object_close_impl): Update. * jv-lang.c (get_dynamics_objfile): Update. * linespec.c (add_minsym): Use get_dynamics_objfile. * objfiles.c (get_objfile_bfd_data): Initialize 'gdbarch' field. (allocate_objfile): Don't initialize 'gdbarch' field. (get_objfile_arch): Update. * objfiles.h (struct objfile_per_bfd_storage) <gdbarch>: New field, moved from... (struct objfile) <gdbarch>: ... here. Remove. * stap-probe.c (stap_can_evaluate_probe_arguments): Use get_objfile_arch. * symfile.c (init_entry_point_info): Use get_objfile_arch.
-rw-r--r--gdb/ChangeLog19
-rw-r--r--gdb/cp-namespace.c3
-rw-r--r--gdb/elfread.c6
-rw-r--r--gdb/jit.c2
-rw-r--r--gdb/jv-lang.c2
-rw-r--r--gdb/linespec.c2
-rw-r--r--gdb/objfiles.c8
-rw-r--r--gdb/objfiles.h14
-rw-r--r--gdb/stap-probe.c2
-rw-r--r--gdb/symfile.c4
10 files changed, 41 insertions, 21 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f22a1b4ad47..d11e2263f5b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,22 @@
+2013-08-20 Tom Tromey <tromey@redhat.com>
+
+ * cp-namespace.c (cp_lookup_symbol_imports_or_template): Use
+ get_objfile_arch.
+ * elfread.c (elf_rel_plt_read, elf_gnu_ifunc_record_cache)
+ (elf_gnu_ifunc_resolve_by_got): Use get_objfile_arch.
+ * jit.c (jit_object_close_impl): Update.
+ * jv-lang.c (get_dynamics_objfile): Update.
+ * linespec.c (add_minsym): Use get_dynamics_objfile.
+ * objfiles.c (get_objfile_bfd_data): Initialize 'gdbarch' field.
+ (allocate_objfile): Don't initialize 'gdbarch' field.
+ (get_objfile_arch): Update.
+ * objfiles.h (struct objfile_per_bfd_storage) <gdbarch>: New field,
+ moved from...
+ (struct objfile) <gdbarch>: ... here. Remove.
+ * stap-probe.c (stap_can_evaluate_probe_arguments): Use
+ get_objfile_arch.
+ * symfile.c (init_entry_point_info): Use get_objfile_arch.
+
2013-08-20 Alan Modra <amodra@gmail.com>
* doublest.c (convert_floatformat_to_doublest): Use fmt->split_half
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 755aeef89d9..36134c0b00b 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -473,7 +473,8 @@ cp_lookup_symbol_imports_or_template (const char *scope,
char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function));
struct cleanup *cleanups = make_cleanup (xfree, name_copy);
const struct language_defn *lang = language_def (language_cplus);
- struct gdbarch *arch = SYMBOL_SYMTAB (function)->objfile->gdbarch;
+ struct gdbarch *arch
+ = get_objfile_arch (SYMBOL_SYMTAB (function)->objfile);
const struct block *parent = BLOCK_SUPERBLOCK (block);
while (1)
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 1aa10d1e384..d16287aeb9f 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -636,7 +636,7 @@ elf_rel_plt_read (struct objfile *objfile, asymbol **dyn_symbol_table)
char *string_buffer = NULL;
size_t string_buffer_size = 0;
struct cleanup *back_to;
- struct gdbarch *gdbarch = objfile->gdbarch;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
size_t ptr_size = TYPE_LENGTH (ptr_type);
@@ -797,7 +797,7 @@ elf_gnu_ifunc_record_cache (const char *name, CORE_ADDR addr)
if (*slot != NULL)
{
struct elf_gnu_ifunc_cache *entry_found_p = *slot;
- struct gdbarch *gdbarch = objfile->gdbarch;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
if (entry_found_p->addr != addr)
{
@@ -877,7 +877,7 @@ elf_gnu_ifunc_resolve_by_got (const char *name, CORE_ADDR *addr_p)
ALL_PSPACE_OBJFILES (current_program_space, objfile)
{
bfd *obfd = objfile->obfd;
- struct gdbarch *gdbarch = objfile->gdbarch;
+ struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
size_t ptr_size = TYPE_LENGTH (ptr_type);
CORE_ADDR pointer_address, addr;
diff --git a/gdb/jit.c b/gdb/jit.c
index 6fc8524f54f..c565b6b7aa9 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -786,7 +786,7 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
priv_data = cb->priv_data;
objfile = allocate_objfile (NULL, 0);
- objfile->gdbarch = target_gdbarch ();
+ objfile->per_bfd->gdbarch = target_gdbarch ();
terminate_minimal_symbol_table (objfile);
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index 1ef12962918..bba94f28798 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -119,7 +119,7 @@ get_dynamics_objfile (struct gdbarch *gdbarch)
/* Mark it as shared so that it is cleared when the inferior is
re-run. */
dynamics_objfile = allocate_objfile (NULL, OBJF_SHARED);
- dynamics_objfile->gdbarch = gdbarch;
+ dynamics_objfile->per_bfd->gdbarch = gdbarch;
data = XCNEW (struct jv_per_objfile_data);
set_objfile_data (dynamics_objfile, jv_dynamics_objfile_data_key, data);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 45d7817c978..b1a80634dc7 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3511,7 +3511,7 @@ add_minsym (struct minimal_symbol *minsym, void *d)
{
/* Make sure this minsym is not a function descriptor
before we decide to discard it. */
- struct gdbarch *gdbarch = info->objfile->gdbarch;
+ struct gdbarch *gdbarch = get_objfile_arch (info->objfile);
CORE_ADDR addr = gdbarch_convert_from_func_ptr_addr
(gdbarch, SYMBOL_VALUE_ADDRESS (minsym),
&current_target);
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 759159c35af..2b8cf4e2962 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -143,6 +143,9 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd)
{
storage = bfd_zalloc (abfd, sizeof (struct objfile_per_bfd_storage));
set_bfd_data (abfd, objfiles_bfd_data, storage);
+
+ /* Look up the gdbarch associated with the BFD. */
+ storage->gdbarch = gdbarch_from_bfd (abfd);
}
else
storage = OBSTACK_ZALLOC (&objfile->objfile_obstack,
@@ -282,9 +285,6 @@ allocate_objfile (bfd *abfd, int flags)
gdb_bfd_ref (abfd);
if (abfd != NULL)
{
- /* Look up the gdbarch associated with the BFD. */
- objfile->gdbarch = gdbarch_from_bfd (abfd);
-
objfile->name = bfd_get_filename (abfd);
objfile->mtime = bfd_get_mtime (abfd);
@@ -335,7 +335,7 @@ allocate_objfile (bfd *abfd, int flags)
struct gdbarch *
get_objfile_arch (struct objfile *objfile)
{
- return objfile->gdbarch;
+ return objfile->per_bfd->gdbarch;
}
/* If there is a valid and known entry point, function fills *ENTRY_P with it
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 84167e03f3a..5b762e466b9 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -178,6 +178,13 @@ struct objfile_per_bfd_storage
/* Byte cache for macros. */
struct bcache *macro_cache;
+
+ /* The gdbarch associated with the BFD. Note that this gdbarch is
+ determined solely from BFD information, without looking at target
+ information. The gdbarch determined from a running target may
+ differ from this e.g. with respect to register types and names. */
+
+ struct gdbarch *gdbarch;
};
/* Master structure for keeping track of each file from which
@@ -248,13 +255,6 @@ struct objfile
struct objfile_per_bfd_storage *per_bfd;
- /* The gdbarch associated with the BFD. Note that this gdbarch is
- determined solely from BFD information, without looking at target
- information. The gdbarch determined from a running target may
- differ from this e.g. with respect to register types and names. */
-
- struct gdbarch *gdbarch;
-
/* The modification timestamp of the object file, as of the last time
we read its symbols. */
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index cbbdf391130..200111c5ee6 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1086,7 +1086,7 @@ static int
stap_can_evaluate_probe_arguments (struct probe *probe_generic)
{
struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
- struct gdbarch *gdbarch = stap_probe->p.objfile->gdbarch;
+ struct gdbarch *gdbarch = get_objfile_arch (stap_probe->p.objfile);
/* For SystemTap probes, we have to guarantee that the method
stap_is_single_operand is defined on gdbarch. If it is not, then it
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 3dd550927f7..d1e024f1e71 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -884,14 +884,14 @@ init_entry_point_info (struct objfile *objfile)
/* Make certain that the address points at real code, and not a
function descriptor. */
entry_point
- = gdbarch_convert_from_func_ptr_addr (objfile->gdbarch,
+ = gdbarch_convert_from_func_ptr_addr (get_objfile_arch (objfile),
entry_point,
&current_target);
/* Remove any ISA markers, so that this matches entries in the
symbol table. */
objfile->ei.entry_point
- = gdbarch_addr_bits_remove (objfile->gdbarch, entry_point);
+ = gdbarch_addr_bits_remove (get_objfile_arch (objfile), entry_point);
}
}