This changes entry_point_address_query to return a std::optional.
Approved-By: Simon Marchi <simon.marchi@efficios.com>
static bool
inside_entry_func (const frame_info_ptr &this_frame)
{
- CORE_ADDR entry_point;
-
- if (!current_program_space->entry_point_address_query (&entry_point))
+ std::optional<CORE_ADDR> entry_point
+ = current_program_space->entry_point_address_query ();
+ if (!entry_point.has_value ())
return false;
- return get_frame_func (this_frame) == entry_point;
+ return get_frame_func (this_frame) == *entry_point;
}
/* Return a structure containing various interesting information about
/* See progspace.h. */
-int
-program_space::entry_point_address_query (CORE_ADDR *entry_p) const
+std::optional<CORE_ADDR>
+program_space::entry_point_address_query () const
{
objfile *objf = symfile_object_file;
if (objf == NULL || !objf->per_bfd->ei.entry_point_p)
- return 0;
+ return {};
int idx = objf->per_bfd->ei.the_bfd_section_index;
- *entry_p = objf->per_bfd->ei.entry_point + objf->section_offsets[idx];
-
- return 1;
+ return objf->per_bfd->ei.entry_point + objf->section_offsets[idx];
}
/* See progspace.h. */
CORE_ADDR
program_space::entry_point_address () const
{
- CORE_ADDR retval;
+ std::optional<CORE_ADDR> retval = entry_point_address_query ();
- if (!entry_point_address_query (&retval))
+ if (!retval.has_value ())
error (_("Entry point address is not known."));
- return retval;
+ return *retval;
}
/* Prints the list of program spaces and their details on UIOUT. If
}
/* 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;
+ return it. Otherwise return an empty optional. */
+ std::optional<CORE_ADDR> entry_point_address_query () const;
/* Get the entry point address in this program space. Call error if
it is not known. */
enable_break (void)
{
asection *interp_sect;
- CORE_ADDR entry_point;
if (current_program_space->symfile_object_file == NULL)
{
return 0;
}
- if (!current_program_space->entry_point_address_query (&entry_point))
+ std::optional<CORE_ADDR> entry_point
+ = current_program_space->entry_point_address_query ();
+ if (!entry_point.has_value ())
{
solib_debug_printf ("Symbol file has no entry point.");
return 0;
return 0;
}
- create_solib_event_breakpoint (current_inferior ()->arch (), entry_point);
+ create_solib_event_breakpoint (current_inferior ()->arch (), *entry_point);
solib_debug_printf ("solib event breakpoint placed at entry point: %s",
- hex_string_custom (entry_point, 8));
+ hex_string_custom (*entry_point, 8));
return 1;
}