From: Tom Tromey <tromey@redhat.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@redhat.com>
Subject: [PATCH 3/3] move the entry point info into the per-bfd object
Date: Mon, 06 Jan 2014 20:30:00 -0000 [thread overview]
Message-ID: <1389040247-2620-4-git-send-email-tromey@redhat.com> (raw)
In-Reply-To: <1389040247-2620-1-git-send-email-tromey@redhat.com>
This moves the entry point information into the per-BFD object and
arranges not to recompute it when it has already been computed.
2014-01-06 Tom Tromey <tromey@redhat.com>
* symfile.c (init_entry_point_info): Use new "initialized" field.
Update.
* objfiles.h (struct entry_point) <initialized>: New field.
(struct objfile_per_bfd_storage) <ei>: New field, moved from...
(struct objfile) <ei>: ...here. Remove.
* objfiles.c (entry_point_address_query): Update.
---
gdb/ChangeLog | 9 +++++++++
gdb/objfiles.c | 6 +++---
gdb/objfiles.h | 13 ++++++++-----
gdb/symfile.c | 24 ++++++++++++++----------
4 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 2604ae4..c2238d1 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -364,12 +364,12 @@ get_objfile_arch (struct objfile *objfile)
int
entry_point_address_query (CORE_ADDR *entry_p)
{
- if (symfile_objfile == NULL || !symfile_objfile->ei.entry_point_p)
+ if (symfile_objfile == NULL || !symfile_objfile->per_bfd->ei.entry_point_p)
return 0;
- *entry_p = (symfile_objfile->ei.entry_point
+ *entry_p = (symfile_objfile->per_bfd->ei.entry_point
+ ANOFFSET (symfile_objfile->section_offsets,
- symfile_objfile->ei.the_bfd_section_index));
+ symfile_objfile->per_bfd->ei.the_bfd_section_index));
return 1;
}
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 620d7e8..d448c9e 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -109,6 +109,9 @@ struct entry_info
/* Set to 1 iff ENTRY_POINT contains a valid value. */
unsigned entry_point_p : 1;
+
+ /* Set to 1 iff this object was initialized. */
+ unsigned initialized : 1;
};
/* Sections in an objfile. The section offsets are stored in the
@@ -195,6 +198,11 @@ struct objfile_per_bfd_storage
name, and the second is the demangled name or just a zero byte
if the name doesn't demangle. */
struct htab *demangled_names_hash;
+
+ /* The per-objfile information about the entry point, the scope (file/func)
+ containing the entry point, and the scope of the user's main() func. */
+
+ struct entry_info ei;
};
/* Master structure for keeping track of each file from which
@@ -318,11 +326,6 @@ struct objfile
const struct sym_fns *sf;
- /* The per-objfile information about the entry point, the scope (file/func)
- containing the entry point, and the scope of the user's main() func. */
-
- struct entry_info ei;
-
/* Per objfile data-pointers required by other GDB modules. */
REGISTRY_FIELDS;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index a0ff9db..2a49379 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -868,6 +868,10 @@ read_symbols (struct objfile *objfile, int add_flags)
static void
init_entry_point_info (struct objfile *objfile)
{
+ if (objfile->per_bfd->ei.initialized)
+ return;
+ objfile->per_bfd->ei.initialized = 1;
+
/* Save startup file's range of PC addresses to help blockframe.c
decide where the bottom of the stack is. */
@@ -875,8 +879,8 @@ init_entry_point_info (struct objfile *objfile)
{
/* Executable file -- record its entry point so we'll recognize
the startup file because it contains the entry point. */
- objfile->ei.entry_point = bfd_get_start_address (objfile->obfd);
- objfile->ei.entry_point_p = 1;
+ objfile->per_bfd->ei.entry_point = bfd_get_start_address (objfile->obfd);
+ objfile->per_bfd->ei.entry_point_p = 1;
}
else if (bfd_get_file_flags (objfile->obfd) & DYNAMIC
&& bfd_get_start_address (objfile->obfd) != 0)
@@ -884,19 +888,19 @@ init_entry_point_info (struct objfile *objfile)
/* Some shared libraries may have entry points set and be
runnable. There's no clear way to indicate this, so just check
for values other than zero. */
- objfile->ei.entry_point = bfd_get_start_address (objfile->obfd);
- objfile->ei.entry_point_p = 1;
+ objfile->per_bfd->ei.entry_point = bfd_get_start_address (objfile->obfd);
+ objfile->per_bfd->ei.entry_point_p = 1;
}
else
{
/* Examination of non-executable.o files. Short-circuit this stuff. */
- objfile->ei.entry_point_p = 0;
+ objfile->per_bfd->ei.entry_point_p = 0;
}
- if (objfile->ei.entry_point_p)
+ if (objfile->per_bfd->ei.entry_point_p)
{
struct obj_section *osect;
- CORE_ADDR entry_point = objfile->ei.entry_point;
+ CORE_ADDR entry_point = objfile->per_bfd->ei.entry_point;
/* Make certain that the address points at real code, and not a
function descriptor. */
@@ -907,7 +911,7 @@ init_entry_point_info (struct objfile *objfile)
/* Remove any ISA markers, so that this matches entries in the
symbol table. */
- objfile->ei.entry_point
+ objfile->per_bfd->ei.entry_point
= gdbarch_addr_bits_remove (get_objfile_arch (objfile), entry_point);
ALL_OBJFILE_OSECTIONS (objfile, osect)
@@ -918,14 +922,14 @@ init_entry_point_info (struct objfile *objfile)
&& entry_point < (bfd_get_section_vma (objfile->obfd, sect)
+ bfd_get_section_size (sect)))
{
- objfile->ei.the_bfd_section_index
+ objfile->per_bfd->ei.the_bfd_section_index
= gdb_bfd_section_index (objfile->obfd, sect);
break;
}
}
if (osect == NULL)
- objfile->ei.the_bfd_section_index = SECT_OFF_TEXT (objfile);
+ objfile->per_bfd->ei.the_bfd_section_index = SECT_OFF_TEXT (objfile);
}
}
--
1.8.1.4
next prev parent reply other threads:[~2014-01-06 20:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-06 20:30 [PATCH 0/3] move entry point info to the per-BFD object Tom Tromey
2014-01-06 20:30 ` [PATCH 2/3] relocate the entry point addess when used Tom Tromey
2014-01-08 13:22 ` Pedro Alves
2014-01-13 20:46 ` Tom Tromey
2014-01-15 11:42 ` Pedro Alves
2014-01-15 17:59 ` Tom Tromey
2014-01-15 18:02 ` Pedro Alves
2014-01-06 20:30 ` [PATCH 1/3] change solib-frv to use entry_point_address_query Tom Tromey
2014-01-08 13:23 ` Pedro Alves
2014-01-06 20:30 ` Tom Tromey [this message]
2014-01-08 13:30 ` [PATCH 3/3] move the entry point info into the per-bfd object Pedro Alves
2014-01-13 20:51 ` Tom Tromey
2014-01-15 18:01 ` [PATCH 0/3] move entry point info to the per-BFD object Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1389040247-2620-4-git-send-email-tromey@redhat.com \
--to=tromey@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).