From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 1/3] Move entry point functions to program_space
Date: Fri, 13 Feb 2026 14:09:41 -0700 [thread overview]
Message-ID: <20260213-random-methods-v1-1-59bdac57c3e1@tromey.com> (raw)
In-Reply-To: <20260213-random-methods-v1-0-59bdac57c3e1@tromey.com>
This changes a couple of entry-point-related functions to be methods
on program_space, and moves them to progspace.c.
---
gdb/arc-tdep.c | 2 +-
gdb/arch-utils.c | 2 +-
gdb/frame.c | 2 +-
gdb/infcall.c | 2 +-
gdb/objfiles.c | 28 ----------------------------
gdb/objfiles.h | 10 ----------
gdb/progspace.c | 28 ++++++++++++++++++++++++++++
gdb/progspace.h | 8 ++++++++
gdb/solib-frv.c | 2 +-
9 files changed, 41 insertions(+), 43 deletions(-)
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 48f83dd57c6..99f002341ee 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -861,7 +861,7 @@ arc_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
struct regcache *regcache)
{
*real_pc = funaddr;
- *bp_addr = entry_point_address (current_program_space);
+ *bp_addr = current_program_space->entry_point_address ();
return sp;
}
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index c3ed8f07dc1..9d3dbfa2d81 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -57,7 +57,7 @@ displaced_step_at_entry_point (struct gdbarch *gdbarch)
CORE_ADDR addr;
int bp_len;
- addr = entry_point_address (current_program_space);
+ addr = current_program_space->entry_point_address ();
/* Inferior calls also use the entry point as a breakpoint location.
We don't want displaced stepping to interfere with those
diff --git a/gdb/frame.c b/gdb/frame.c
index 8cb1d0a5c42..bfc85296942 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2677,7 +2677,7 @@ inside_entry_func (const frame_info_ptr &this_frame)
{
CORE_ADDR entry_point;
- if (!entry_point_address_query (current_program_space, &entry_point))
+ if (!current_program_space->entry_point_address_query (&entry_point))
return false;
return get_frame_func (this_frame) == entry_point;
diff --git a/gdb/infcall.c b/gdb/infcall.c
index dcbae679d07..51636ff5403 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1279,7 +1279,7 @@ call_function_by_hand_dummy (struct value *function,
CORE_ADDR dummy_addr;
real_pc = funaddr;
- dummy_addr = entry_point_address (current_program_space);
+ dummy_addr = current_program_space->entry_point_address ();
/* A call dummy always consists of just a single breakpoint, so
its address is the same as the address of the dummy.
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 14c07371f15..4f5258e971d 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -284,34 +284,6 @@ objfile::objfile (gdb_bfd_ref_ptr bfd_, program_space *pspace,
set_objfile_per_bfd (this);
}
-/* See objfiles.h. */
-
-int
-entry_point_address_query (program_space *pspace, CORE_ADDR *entry_p)
-{
- objfile *objf = pspace->symfile_object_file;
- if (objf == NULL || !objf->per_bfd->ei.entry_point_p)
- return 0;
-
- int idx = objf->per_bfd->ei.the_bfd_section_index;
- *entry_p = objf->per_bfd->ei.entry_point + objf->section_offsets[idx];
-
- return 1;
-}
-
-/* See objfiles.h. */
-
-CORE_ADDR
-entry_point_address (program_space *pspace)
-{
- CORE_ADDR retval;
-
- if (!entry_point_address_query (pspace, &retval))
- error (_("Entry point address is not known."));
-
- return retval;
-}
-
separate_debug_iterator &
separate_debug_iterator::operator++ ()
{
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 59ad70dfffa..371fd223693 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -904,16 +904,6 @@ obj_section::set_offset (CORE_ADDR offset)
/* Declarations for functions defined in objfiles.c */
-/* If there is a valid and known entry point in PSPACE, fill *ENTRY_P with it
- and return non-zero. */
-
-extern int entry_point_address_query (program_space *pspace,
- CORE_ADDR *entry_p);
-
-/* Get the entry point address in PSPACE. Call error if it is not known. */
-
-extern CORE_ADDR entry_point_address (program_space *pspace);
-
extern void build_objfile_section_table (struct objfile *);
extern void free_objfile_separate_debug (struct objfile *);
diff --git a/gdb/progspace.c b/gdb/progspace.c
index f16c222ec80..bfd7ca5bcb9 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -285,6 +285,34 @@ program_space::empty ()
return find_inferior_for_program_space (this) == nullptr;
}
+/* See progspace.h. */
+
+int
+program_space::entry_point_address_query (CORE_ADDR *entry_p) const
+{
+ objfile *objf = symfile_object_file;
+ if (objf == NULL || !objf->per_bfd->ei.entry_point_p)
+ return 0;
+
+ int idx = objf->per_bfd->ei.the_bfd_section_index;
+ *entry_p = objf->per_bfd->ei.entry_point + objf->section_offsets[idx];
+
+ return 1;
+}
+
+/* See progspace.h. */
+
+CORE_ADDR
+program_space::entry_point_address () const
+{
+ CORE_ADDR retval;
+
+ if (!entry_point_address_query (&retval))
+ error (_("Entry point address is not known."));
+
+ return retval;
+}
+
/* Prints the list of program spaces and their details on UIOUT. If
REQUESTED is not -1, it's the ID of the pspace that should be
printed. Otherwise, all spaces are printed. */
diff --git a/gdb/progspace.h b/gdb/progspace.h
index d013920b0f6..68d5ad35413 100644
--- a/gdb/progspace.h
+++ b/gdb/progspace.h
@@ -332,6 +332,14 @@ struct program_space
return m_target_sections;
}
+ /* If there is a valid and known entry point in this program space,
+ fill *ENTRY_P with it and return non-zero. */
+ int entry_point_address_query (CORE_ADDR *entry_p) const;
+
+ /* Get the entry point address in this program space. Call error if
+ it is not known. */
+ CORE_ADDR entry_point_address () const;
+
/* Unique ID number. */
int num = 0;
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 5cf853c4115..4460362a57f 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -697,7 +697,7 @@ enable_break (void)
return 0;
}
- if (!entry_point_address_query (current_program_space, &entry_point))
+ if (!current_program_space->entry_point_address_query (&entry_point))
{
solib_debug_printf ("Symbol file has no entry point.");
return 0;
--
2.49.0
next prev parent reply other threads:[~2026-02-13 21:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-13 21:09 [PATCH 0/3] Change some functions to methods of program_space Tom Tromey
2026-02-13 21:09 ` Tom Tromey [this message]
2026-02-13 21:09 ` [PATCH 2/3] Use std::optional in entry_point_address_query Tom Tromey
2026-02-13 21:09 ` [PATCH 3/3] Change have_*_symbols functions to methods of program_space Tom Tromey
2026-02-14 4:16 ` Simon Marchi
2026-02-14 17:33 ` Tom Tromey
2026-02-14 4:17 ` [PATCH 0/3] Change some " Simon Marchi
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=20260213-random-methods-v1-1-59bdac57c3e1@tromey.com \
--to=tom@tromey.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