From: Tom Tromey Date: Thu, 12 Feb 2026 23:54:52 +0000 (-0700) Subject: Move entry point functions to program_space X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53bc279c1fc5146dd397b4a3f3c28cb69972c9f9;p=thirdparty%2Fbinutils-gdb.git Move entry point functions to program_space This changes a couple of entry-point-related functions to be methods on program_space, and moves them to progspace.c. Approved-By: Simon Marchi --- 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;