From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 667703858D35 for ; Tue, 10 Oct 2023 20:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 667703858D35 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 11A331E0BB; Tue, 10 Oct 2023 16:46:19 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 17/24] gdb: remove target_section_table typedef Date: Tue, 10 Oct 2023 16:40:12 -0400 Message-ID: <20231010204213.111285-18-simon.marchi@efficios.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231010204213.111285-1-simon.marchi@efficios.com> References: <20231010204213.111285-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3496.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_SOFTFAIL,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Remove this typedef. I think that hiding the real type (std::vector) behind a typedef just hinders readability. Change-Id: I80949da3392f60a2826c56c268e0ec6f503ad79f --- gdb/bfd-target.c | 6 +++--- gdb/corelow.c | 7 +++---- gdb/exec.c | 20 ++++++++++---------- gdb/exec.h | 6 +++--- gdb/maint.c | 2 +- gdb/progspace.h | 6 +++--- gdb/record-full.c | 2 +- gdb/remote.c | 3 ++- gdb/solib.c | 2 +- gdb/solist.h | 2 +- gdb/symfile.c | 2 +- gdb/symfile.h | 2 +- gdb/target-debug.h | 4 ++-- gdb/target-delegates.c | 14 +++++++------- gdb/target-section.h | 4 ---- gdb/target.c | 10 +++++----- gdb/target.h | 6 +++--- 17 files changed, 47 insertions(+), 51 deletions(-) diff --git a/gdb/bfd-target.c b/gdb/bfd-target.c index 9e1b980957c9..2aa2f9638d3f 100644 --- a/gdb/bfd-target.c +++ b/gdb/bfd-target.c @@ -50,7 +50,7 @@ class target_bfd : public target_ops ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) override; - const target_section_table *get_section_table () override; + const std::vector *get_section_table () override; private: /* The BFD we're wrapping. */ @@ -59,7 +59,7 @@ class target_bfd : public target_ops /* The section table build from the ALLOC sections in BFD. Note that we can't rely on extracting the BFD from a random section in the table, since the table can be legitimately empty. */ - target_section_table m_table; + std::vector m_table; }; target_xfer_status @@ -82,7 +82,7 @@ target_bfd::xfer_partial (target_object object, } } -const target_section_table * +const std::vector * target_bfd::get_section_table () { return &m_table; diff --git a/gdb/corelow.c b/gdb/corelow.c index 4da5e4fa5d46..91b442b4426f 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -142,11 +142,11 @@ class core_target final : public process_stratum_target shared library bfds. The core bfd sections are an implementation detail of the core target, just like ptrace is for unix child targets. */ - target_section_table m_core_section_table; + std::vector m_core_section_table; /* File-backed address space mappings: some core files include information about memory mapped files. */ - target_section_table m_core_file_mappings; + std::vector m_core_file_mappings; /* Unavailable mappings. These correspond to pathnames which either weren't found or could not be opened. Knowing these addresses can @@ -197,8 +197,7 @@ core_target::core_target () build_file_mappings (); } -/* Construct the target_section_table for file-backed mappings if - they exist. +/* Construct the table for file-backed mappings if they exist. For each unique path in the note, we'll open a BFD with a bfd target of "binary". This is an unstructured bfd target upon which diff --git a/gdb/exec.c b/gdb/exec.c index 08c205662ea1..0f9f9d076c68 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -479,8 +479,8 @@ exec_file_attach (const char *filename, int from_tty) gdb_bfd_errmsg (bfd_get_error (), matching).c_str ()); } - target_section_table sections - = build_section_table (current_program_space->exec_bfd ()); + std::vector sections + = build_section_table (current_program_space->exec_bfd ()); current_program_space->ebfd_mtime = bfd_get_mtime (current_program_space->exec_bfd ()); @@ -568,10 +568,10 @@ file_command (const char *arg, int from_tty) /* Builds a section table, given args BFD, TABLE. */ -target_section_table +std::vector build_section_table (struct bfd *some_bfd) { - target_section_table table; + std::vector table; for (asection *asect : gdb_bfd_sections (some_bfd)) { @@ -600,7 +600,7 @@ build_section_table (struct bfd *some_bfd) void program_space::add_target_sections (const void *owner, - const target_section_table §ions) + const std::vector §ions) { if (!sections.empty ()) { @@ -745,7 +745,7 @@ exec_read_partial_read_only (gdb_byte *readbuf, ULONGEST offset, static std::vector section_table_available_memory (CORE_ADDR memaddr, ULONGEST len, - const target_section_table §ions) + const std::vector §ions) { std::vector memory; @@ -779,7 +779,7 @@ enum target_xfer_status section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { - const target_section_table *table + const std::vector *table = target_get_section_table (current_inferior ()->top_target ()); std::vector available_memory = section_table_available_memory (offset, len, *table); @@ -819,7 +819,7 @@ enum target_xfer_status section_table_xfer_memory_partial (gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len, - const target_section_table §ions, + const std::vector §ions, gdb::function_view match_cb) { @@ -895,7 +895,7 @@ exec_target::xfer_partial (enum target_object object, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { - const target_section_table *table = target_get_section_table (this); + const std::vector *table = target_get_section_table (this); if (object == TARGET_OBJECT_MEMORY) return section_table_xfer_memory_partial (readbuf, writebuf, @@ -907,7 +907,7 @@ exec_target::xfer_partial (enum target_object object, void -print_section_info (const target_section_table *t, bfd *abfd) +print_section_info (const std::vector *t, bfd *abfd) { struct gdbarch *gdbarch = gdbarch_from_bfd (abfd); /* FIXME: 16 is not wide enough when gdbarch_addr_bit > 64. */ diff --git a/gdb/exec.h b/gdb/exec.h index 200a5c69265a..bde3fc8fcc0e 100644 --- a/gdb/exec.h +++ b/gdb/exec.h @@ -32,7 +32,7 @@ struct objfile; /* Builds a section table, given args BFD. */ -extern target_section_table build_section_table (struct bfd *); +extern std::vector build_section_table (struct bfd *); /* VFORK_CHILD is a child vforked and its program space is shared with its parent. This pushes the exec target on that inferior's target stack if @@ -75,7 +75,7 @@ extern enum target_xfer_status section_table_xfer_memory_partial (gdb_byte *, const gdb_byte *, ULONGEST, ULONGEST, ULONGEST *, - const target_section_table &, + const std::vector &, gdb::function_view match_cb = nullptr); @@ -95,7 +95,7 @@ extern void exec_set_section_address (const char *, int, CORE_ADDR); special cased --- it's filename is omitted; if it is the executable file, its entry point is printed. */ -extern void print_section_info (const target_section_table *table, +extern void print_section_info (const std::vector *table, bfd *abfd); /* Helper function that attempts to open the symbol file at EXEC_FILE_HOST. diff --git a/gdb/maint.c b/gdb/maint.c index f91184c20056..e0dc5bc0c7aa 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -470,7 +470,7 @@ maintenance_info_target_sections (const char *arg, int from_tty) { bfd *abfd = nullptr; int digits = 0; - const target_section_table *table + const std::vector *table = target_get_section_table (current_inferior ()->top_target ()); if (table == nullptr) return; diff --git a/gdb/progspace.h b/gdb/progspace.h index 0930d8583597..20dfc2e92e83 100644 --- a/gdb/progspace.h +++ b/gdb/progspace.h @@ -291,7 +291,7 @@ struct program_space /* Add the sections array defined by SECTIONS to the current set of target sections. */ void add_target_sections (const void *owner, - const target_section_table §ions); + const std::vector §ions); /* Add the sections of OBJFILE to the current set of target sections. They are given OBJFILE as the "owner". */ @@ -304,7 +304,7 @@ struct program_space } /* Return a reference to the M_TARGET_SECTIONS table. */ - target_section_table &target_sections () + std::vector &target_sections () { return m_target_sections; } @@ -380,7 +380,7 @@ struct program_space private: /* The set of target sections matching the sections mapped into this program space. Managed by both exec_ops and solib.c. */ - target_section_table m_target_sections; + std::vector m_target_sections; }; /* An address space. It is used for comparing if diff --git a/gdb/record-full.c b/gdb/record-full.c index f072bdd7f882..2ee08e6d54fb 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -173,7 +173,7 @@ struct record_full_core_buf_entry /* Record buf with core target. */ static detached_regcache *record_full_core_regbuf = NULL; -static target_section_table record_full_core_sections; +static std::vector record_full_core_sections; static struct record_full_core_buf_entry *record_full_core_buf_list = NULL; /* The following variables are used for managing the linked list that diff --git a/gdb/remote.c b/gdb/remote.c index 961061e02a9f..b58dbd4cb66e 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9446,7 +9446,8 @@ remote_target::remote_xfer_live_readonly_partial (gdb_byte *readbuf, { ULONGEST memend = memaddr + len; - const target_section_table *table = target_get_section_table (this); + const std::vector *table + = target_get_section_table (this); for (const target_section &p : *table) { if (memaddr >= p.addr) diff --git a/gdb/solib.c b/gdb/solib.c index 8f5b6e02e71c..3d6dfdc4e3c3 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -593,7 +593,7 @@ solib_map_sections (so_list &so) strcpy (so.so_name, bfd_get_filename (so.abfd)); if (so.sections == nullptr) - so.sections = new target_section_table; + so.sections = new std::vector; *so.sections = build_section_table (so.abfd); for (target_section &p : *so.sections) diff --git a/gdb/solist.h b/gdb/solist.h index 75e8e8ad0182..ca12fd55ba0f 100644 --- a/gdb/solist.h +++ b/gdb/solist.h @@ -84,7 +84,7 @@ struct so_list the file cannot be found or after the command "nosharedlibrary". */ struct objfile *objfile = nullptr; - target_section_table *sections = nullptr; + std::vector *sections = nullptr; /* Record the range of addresses belonging to this shared library. There may not be just one (e.g. if two segments are relocated diff --git a/gdb/symfile.c b/gdb/symfile.c index 5eb1638b781c..eebc5ea44b9b 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -216,7 +216,7 @@ find_lowest_section (asection *sect, asection **lowest) an existing section table. */ section_addr_info -build_section_addr_info_from_section_table (const target_section_table &table) +build_section_addr_info_from_section_table (const std::vector &table) { section_addr_info sap; diff --git a/gdb/symfile.h b/gdb/symfile.h index 296fee945c14..bb61a779314e 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -257,7 +257,7 @@ extern std::string find_separate_debug_file_by_debuglink existing section table. */ extern section_addr_info - build_section_addr_info_from_section_table (const target_section_table &table); + build_section_addr_info_from_section_table (const std::vector &table); /* Variables */ diff --git a/gdb/target-debug.h b/gdb/target-debug.h index 4082f8271179..3663ec21740e 100644 --- a/gdb/target-debug.h +++ b/gdb/target-debug.h @@ -104,8 +104,8 @@ target_debug_do_print (host_address_to_string (X)) #define target_debug_print_ui_file_p(X) \ target_debug_do_print (host_address_to_string (X)) -#define target_debug_print_const_target_section_table_p(X) \ - target_debug_do_print (host_address_to_string (X)) +#define target_debug_print_const_std_vector_target_section_p(X) \ + target_debug_do_print (host_address_to_string (X->data ())) #define target_debug_print_void_p(X) \ target_debug_do_print (host_address_to_string (X)) #define target_debug_print_find_memory_region_ftype(X) \ diff --git a/gdb/target-delegates.c b/gdb/target-delegates.c index d1b71a11c12d..580fc768dd1c 100644 --- a/gdb/target-delegates.c +++ b/gdb/target-delegates.c @@ -96,7 +96,7 @@ struct dummy_target : public target_ops void rcmd (const char *arg0, struct ui_file *arg1) override; const char *pid_to_exec_file (int arg0) override; void log_command (const char *arg0) override; - const target_section_table *get_section_table () override; + const std::vector *get_section_table () override; thread_control_capabilities get_thread_control_capabilities () override; bool attach_no_wait () override; bool can_async_p () override; @@ -271,7 +271,7 @@ struct debug_target : public target_ops void rcmd (const char *arg0, struct ui_file *arg1) override; const char *pid_to_exec_file (int arg0) override; void log_command (const char *arg0) override; - const target_section_table *get_section_table () override; + const std::vector *get_section_table () override; thread_control_capabilities get_thread_control_capabilities () override; bool attach_no_wait () override; bool can_async_p () override; @@ -2032,27 +2032,27 @@ debug_target::log_command (const char *arg0) gdb_puts (")\n", gdb_stdlog); } -const target_section_table * +const std::vector * target_ops::get_section_table () { return this->beneath ()->get_section_table (); } -const target_section_table * +const std::vector * dummy_target::get_section_table () { return default_get_section_table (); } -const target_section_table * +const std::vector * debug_target::get_section_table () { gdb_printf (gdb_stdlog, "-> %s->get_section_table (...)\n", this->beneath ()->shortname ()); - const target_section_table * result + const std::vector * result = this->beneath ()->get_section_table (); gdb_printf (gdb_stdlog, "<- %s->get_section_table (", this->beneath ()->shortname ()); gdb_puts (") = ", gdb_stdlog); - target_debug_print_const_target_section_table_p (result); + target_debug_print_const_std_vector_target_section_p (result); gdb_puts ("\n", gdb_stdlog); return result; } diff --git a/gdb/target-section.h b/gdb/target-section.h index 5d7c846a6e25..1c902baa7778 100644 --- a/gdb/target-section.h +++ b/gdb/target-section.h @@ -51,8 +51,4 @@ struct target_section const void *owner; }; -/* Holds an array of target sections. */ - -using target_section_table = std::vector; - #endif /* GDB_TARGET_SECTION_H */ diff --git a/gdb/target.c b/gdb/target.c index 6853c1432318..a2e78780b0bc 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1381,7 +1381,7 @@ target_xfer_status_to_string (enum target_xfer_status status) }; -const target_section_table * +const std::vector * target_get_section_table (struct target_ops *target) { return target->get_section_table (); @@ -1392,7 +1392,7 @@ target_get_section_table (struct target_ops *target) const struct target_section * target_section_by_addr (struct target_ops *target, CORE_ADDR addr) { - const target_section_table *table = target_get_section_table (target); + const std::vector *table = target_get_section_table (target); if (table == NULL) return NULL; @@ -1407,7 +1407,7 @@ target_section_by_addr (struct target_ops *target, CORE_ADDR addr) /* See target.h. */ -const target_section_table * +const std::vector * default_get_section_table () { return ¤t_program_space->target_sections (); @@ -1541,7 +1541,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object, if (pc_in_unmapped_range (memaddr, section)) { - const target_section_table *table = target_get_section_table (ops); + const std::vector *table = target_get_section_table (ops); const char *section_name = section->the_bfd_section->name; memaddr = overlay_mapped_address (memaddr, section); @@ -1565,7 +1565,7 @@ memory_xfer_partial_1 (struct target_ops *ops, enum target_object object, if (secp != NULL && (bfd_section_flags (secp->the_bfd_section) & SEC_READONLY)) { - const target_section_table *table = target_get_section_table (ops); + const std::vector *table = target_get_section_table (ops); return section_table_xfer_memory_partial (readbuf, writebuf, memaddr, len, xfered_len, *table); diff --git a/gdb/target.h b/gdb/target.h index 446c0a9fdbfa..68b269fb3e61 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -698,7 +698,7 @@ struct target_ops TARGET_DEFAULT_RETURN (NULL); virtual void log_command (const char *) TARGET_DEFAULT_IGNORE (); - virtual const target_section_table *get_section_table () + virtual const std::vector *get_section_table () TARGET_DEFAULT_RETURN (default_get_section_table ()); /* Provide default values for all "must have" methods. */ @@ -2401,12 +2401,12 @@ const struct target_section *target_section_by_addr (struct target_ops *target, /* Return the target section table this target (or the targets beneath) currently manipulate. */ -extern const target_section_table *target_get_section_table +extern const std::vector *target_get_section_table (struct target_ops *target); /* Default implementation of get_section_table for dummy_target. */ -extern const target_section_table *default_get_section_table (); +extern const std::vector *default_get_section_table (); /* From mem-break.c */ -- 2.42.0