+2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb/bfd-target.c (class target_bfd) <get_section_table>: Make
+ return type const.
+ * gdb/exec.c (struct exec_target) <get_section_table>: Likewise.
+ (section_table_read_available_memory): Make local const.
+ (exec_target::xfer_partial): Make local const.
+ (print_section_info): Make parameter const.
+ * gdb/exec.h (print_section_info): Likewise.
+ * gdb/ppc64-tdep.c (ppc64_convert_from_func_ptr_addr): Make local
+ const.
+ * gdb/record-btrace.c (record_btrace_target::xfer_partial):
+ Likewise.
+ * gdb/remote.c (remote_target::remote_xfer_live_readonly_partial):
+ Likewise.
+ * gdb/s390-tdep.c (s390_load): Likewise.
+ * gdb/solib-dsbt.c (scan_dyntag): Likewise.
+ * gdb/solib-svr4.c (scan_dyntag): Likewise.
+ * gdb/target-debug.h (target_debug_print_target_section_table_p):
+ Rename to...
+ (target_debug_print_const_target_section_table_p): ...this.
+ * gdb/target-delegates.c: Regenerate.
+ * gdb/target.c (target_get_section_table): Make return type const.
+ (target_section_by_addr): Likewise. Also make some locals const.
+ (memory_xfer_partial_1): Make some locals const.
+ * gdb/target.h (struct target_ops) <get_section_table>: Make
+ return type const.
+ (target_section_by_addr): Likewise.
+ (target_get_section_table): Likewise.
+
2021-02-24 Andrew Burgess <andrew.burgess@embecosm.com>
* NEWS: Mention new 'maint info target-sections' command.
ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len) override;
- target_section_table *get_section_table () override;
+ const target_section_table *get_section_table () override;
private:
/* The BFD we're wrapping. */
}
}
-target_section_table *
+const target_section_table *
target_bfd::get_section_table ()
{
return &m_table;
const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len,
ULONGEST *xfered_len) override;
- target_section_table *get_section_table () override;
+ const target_section_table *get_section_table () override;
void files_info () override;
bool has_memory () override;
section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset,
ULONGEST len, ULONGEST *xfered_len)
{
- target_section_table *table = target_get_section_table (&exec_ops);
+ const target_section_table *table = target_get_section_table (&exec_ops);
std::vector<mem_range> available_memory
= section_table_available_memory (offset, len, *table);
return TARGET_XFER_EOF; /* We can't help. */
}
-target_section_table *
+const target_section_table *
exec_target::get_section_table ()
{
return ¤t_program_space->target_sections;
const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
{
- target_section_table *table = get_section_table ();
+ const target_section_table *table = target_get_section_table (this);
if (object == TARGET_OBJECT_MEMORY)
return section_table_xfer_memory_partial (readbuf, writebuf,
\f
void
-print_section_info (target_section_table *t, bfd *abfd)
+print_section_info (const target_section_table *t, bfd *abfd)
{
struct gdbarch *gdbarch = gdbarch_from_bfd (abfd);
/* FIXME: 16 is not wide enough when gdbarch_addr_bit > 64. */
special cased --- it's filename is omitted; if it is the executable
file, its entry point is printed. */
-extern void print_section_info (target_section_table *table,
+extern void print_section_info (const target_section_table *table,
bfd *abfd);
/* Helper function that attempts to open the symbol file at EXEC_FILE_HOST.
struct target_ops *targ)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- struct target_section *s = target_section_by_addr (targ, addr);
+ const struct target_section *s = target_section_by_addr (targ, addr);
/* Check if ADDR points to a function descriptor. */
if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
{
case TARGET_OBJECT_MEMORY:
{
- struct target_section *section;
+ const struct target_section *section;
/* We do not allow writing memory in general. */
if (writebuf != NULL)
int unit_size,
ULONGEST *xfered_len)
{
- struct target_section *secp;
+ const struct target_section *secp;
secp = target_section_by_addr (this, memaddr);
if (secp != NULL
{
ULONGEST memend = memaddr + len;
- target_section_table *table = target_get_section_table (this);
- for (target_section &p : *table)
+ const target_section_table *table = target_get_section_table (this);
+ for (const target_section &p : *table)
{
if (memaddr >= p.addr)
{
we're analyzing the code to unwind past that frame. */
if (pv_is_constant (addr))
{
- struct target_section *secp;
- secp = target_section_by_addr (current_top_target (), addr.k);
+ const struct target_section *secp
+ = target_section_by_addr (current_top_target (), addr.k);
if (secp != NULL
&& (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY))
return pv_constant (read_memory_integer (addr.k, size,
return 0;
bool found = false;
- for (target_section &target_section : current_program_space->target_sections)
+ for (const target_section &target_section
+ : current_program_space->target_sections)
if (sect == target_section.the_bfd_section)
{
dyn_addr = target_section.addr;
return 0;
bool found = false;
- for (target_section &target_section : current_program_space->target_sections)
+ for (const target_section &target_section
+ : current_program_space->target_sections)
if (sect == target_section.the_bfd_section)
{
dyn_addr = target_section.addr;
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_struct_ui_file_p(X) \
target_debug_do_print (host_address_to_string (X))
-#define target_debug_print_target_section_table_p(X) \
+#define target_debug_print_const_target_section_table_p(X) \
target_debug_do_print (host_address_to_string (X))
#define target_debug_print_void_p(X) \
target_debug_do_print (host_address_to_string (X))
void rcmd (const char *arg0, struct ui_file *arg1) override;
char *pid_to_exec_file (int arg0) override;
void log_command (const char *arg0) override;
- target_section_table *get_section_table () override;
+ const target_section_table *get_section_table () override;
thread_control_capabilities get_thread_control_capabilities () override;
bool attach_no_wait () override;
bool can_async_p () override;
void rcmd (const char *arg0, struct ui_file *arg1) override;
char *pid_to_exec_file (int arg0) override;
void log_command (const char *arg0) override;
- target_section_table *get_section_table () override;
+ const target_section_table *get_section_table () override;
thread_control_capabilities get_thread_control_capabilities () override;
bool attach_no_wait () override;
bool can_async_p () override;
fputs_unfiltered (")\n", gdb_stdlog);
}
-target_section_table *
+const target_section_table *
target_ops::get_section_table ()
{
return this->beneath ()->get_section_table ();
}
-target_section_table *
+const target_section_table *
dummy_target::get_section_table ()
{
return NULL;
}
-target_section_table *
+const target_section_table *
debug_target::get_section_table ()
{
- target_section_table * result;
+ const target_section_table * result;
fprintf_unfiltered (gdb_stdlog, "-> %s->get_section_table (...)\n", this->beneath ()->shortname ());
result = this->beneath ()->get_section_table ();
fprintf_unfiltered (gdb_stdlog, "<- %s->get_section_table (", this->beneath ()->shortname ());
fputs_unfiltered (") = ", gdb_stdlog);
- target_debug_print_target_section_table_p (result);
+ target_debug_print_const_target_section_table_p (result);
fputs_unfiltered ("\n", gdb_stdlog);
return result;
}
return gdb::unique_xmalloc_ptr<char> ((char *) buffer.release ());
}
-target_section_table *
+const target_section_table *
target_get_section_table (struct target_ops *target)
{
return target->get_section_table ();
/* Find a section containing ADDR. */
-struct target_section *
+const struct target_section *
target_section_by_addr (struct target_ops *target, CORE_ADDR addr)
{
- target_section_table *table = target_get_section_table (target);
+ const target_section_table *table = target_get_section_table (target);
if (table == NULL)
return NULL;
- for (target_section &secp : *table)
+ for (const target_section &secp : *table)
{
if (addr >= secp.addr && addr < secp.endaddr)
return &secp;
if (pc_in_unmapped_range (memaddr, section))
{
- target_section_table *table = target_get_section_table (ops);
+ const target_section_table *table = target_get_section_table (ops);
const char *section_name = section->the_bfd_section->name;
memaddr = overlay_mapped_address (memaddr, section);
/* Try the executable files, if "trust-readonly-sections" is set. */
if (readbuf != NULL && trust_readonly)
{
- struct target_section *secp;
-
- secp = target_section_by_addr (ops, memaddr);
+ const struct target_section *secp
+ = target_section_by_addr (ops, memaddr);
if (secp != NULL
&& (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY))
{
- target_section_table *table = target_get_section_table (ops);
+ const target_section_table *table = target_get_section_table (ops);
return section_table_xfer_memory_partial (readbuf, writebuf,
memaddr, len, xfered_len,
*table);
TARGET_DEFAULT_RETURN (NULL);
virtual void log_command (const char *)
TARGET_DEFAULT_IGNORE ();
- virtual target_section_table *get_section_table ()
+ virtual const target_section_table *get_section_table ()
TARGET_DEFAULT_RETURN (NULL);
/* Provide default values for all "must have" methods. */
CORE_ADDR offset);
/* Return the "section" containing the specified address. */
-struct target_section *target_section_by_addr (struct target_ops *target,
- CORE_ADDR addr);
+const struct target_section *target_section_by_addr (struct target_ops *target,
+ CORE_ADDR addr);
/* Return the target section table this target (or the targets
beneath) currently manipulate. */
-extern target_section_table *target_get_section_table
+extern const target_section_table *target_get_section_table
(struct target_ops *target);
/* From mem-break.c */