Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 01/16] Add target_section constructor
Date: Mon, 19 Oct 2020 15:44:14 -0600	[thread overview]
Message-ID: <20201019214429.13815-2-tom@tromey.com> (raw)
In-Reply-To: <20201019214429.13815-1-tom@tromey.com>

This adds a constructor to target_section, simplifying the code that
creates instances of this.

gdb/ChangeLog
2020-10-19  Tom Tromey  <tom@tromey.com>

	* target-section.h (struct target_section): Add constructor.
	* exec.c (build_section_table, add_target_sections_of_objfile):
	Update.
	* corelow.c (core_target::build_file_mappings): Update.
---
 gdb/ChangeLog        |  7 +++++++
 gdb/corelow.c        |  7 +------
 gdb/exec.c           | 18 ++++++------------
 gdb/target-section.h |  9 +++++++++
 4 files changed, 23 insertions(+), 18 deletions(-)

diff --git a/gdb/corelow.c b/gdb/corelow.c
index d557475e06f..d73cc5b4b14 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -266,12 +266,7 @@ core_target::build_file_mappings ()
 	bfd_set_section_alignment (sec, 2);
 
 	/* Set target_section fields.  */
-	m_core_file_mappings.emplace_back ();
-	target_section &ts = m_core_file_mappings.back ();
-	ts.addr = start;
-	ts.endaddr = end;
-	ts.owner = nullptr;
-	ts.the_bfd_section = sec;
+	m_core_file_mappings.emplace_back (start, end, sec);
       });
 
   normalize_mem_ranges (&m_core_unavailable_mappings);
diff --git a/gdb/exec.c b/gdb/exec.c
index dd322129139..0646a4df89b 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -598,12 +598,9 @@ build_section_table (struct bfd *some_bfd)
       if (!(aflag & SEC_ALLOC))
 	continue;
 
-      table.emplace_back ();
-      target_section &sect = table.back ();
-      sect.owner = NULL;
-      sect.the_bfd_section = asect;
-      sect.addr = bfd_section_vma (asect);
-      sect.endaddr = sect.addr + bfd_section_size (asect);
+      table.emplace_back (bfd_section_vma (asect),
+			  bfd_section_vma (asect) + bfd_section_size (asect),
+			  asect);
     }
 
   return table;
@@ -662,12 +659,9 @@ add_target_sections_of_objfile (struct objfile *objfile)
       if (bfd_section_size (osect->the_bfd_section) == 0)
 	continue;
 
-      table->emplace_back ();
-      target_section &ts = table->back ();
-      ts.addr = obj_section_addr (osect);
-      ts.endaddr = obj_section_endaddr (osect);
-      ts.the_bfd_section = osect->the_bfd_section;
-      ts.owner = (void *) objfile;
+      table->emplace_back (obj_section_addr (osect),
+			   obj_section_endaddr (osect),
+			   osect->the_bfd_section, (void *) objfile);
     }
 }
 
diff --git a/gdb/target-section.h b/gdb/target-section.h
index ec6932da0a6..b19bcf9e997 100644
--- a/gdb/target-section.h
+++ b/gdb/target-section.h
@@ -26,6 +26,15 @@
 
 struct target_section
 {
+  target_section (CORE_ADDR addr_, CORE_ADDR end_, struct bfd_section *sect_,
+		  void *owner_ = nullptr)
+    : addr (addr_),
+      endaddr (end_),
+      the_bfd_section (sect_),
+      owner (owner_)
+  {
+  }
+
   /* Lowest address in section.  */
   CORE_ADDR addr;
   /* Highest address in section, plus 1.  */
-- 
2.17.2


  reply	other threads:[~2020-10-19 21:44 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 21:44 [PATCH v2 00/16] Remove some macros from exec.h and progspace.h Tom Tromey
2020-10-19 21:44 ` Tom Tromey [this message]
2020-10-19 21:44 ` [PATCH v2 02/16] Remove exec_filename macro Tom Tromey
2020-10-19 21:44 ` [PATCH v2 03/16] Change exec_close to be a method on program_space Tom Tromey
2020-10-19 21:44 ` [PATCH v2 04/16] Remove commented-out code from gcore.c Tom Tromey
2020-10-20 14:01   ` [PP?] " Simon Marchi
2020-10-29  1:19     ` Tom Tromey
2020-10-19 21:44 ` [PATCH v2 05/16] Remove exec_bfd_mtime define Tom Tromey
2020-10-19 21:44 ` [PATCH v2 06/16] Remove current_target_sections macro Tom Tromey
2020-10-19 21:44 ` [PATCH v2 07/16] Remove the exec_bfd macro Tom Tromey
2020-10-20 14:24   ` Simon Marchi
2020-10-20 21:20     ` Tom Tromey
2020-10-20 21:34       ` Simon Marchi
2020-10-19 21:44 ` [PATCH v2 08/16] Change program_space::ebfd to a gdb_bfd_ref_ptr Tom Tromey
2020-10-19 21:44 ` [PATCH v2 09/16] Remove symfile_objfile macro Tom Tromey
2020-10-19 21:44 ` [PATCH v2 10/16] Change clear_program_space_solib_cache to method on program_space Tom Tromey
2020-10-19 21:44 ` [PATCH v2 11/16] Change program_space_empty_p " Tom Tromey
2020-10-19 21:44 ` [PATCH v2 12/16] Change remove_target_sections " Tom Tromey
2020-10-20 14:40   ` [PP?] " Simon Marchi
2020-10-29  1:24     ` Tom Tromey
2020-10-19 21:44 ` [PATCH v2 13/16] Change add_target_sections " Tom Tromey
2020-10-19 21:44 ` [PATCH v2 14/16] Change add_target_sections_of_objfile " Tom Tromey
2020-10-19 21:44 ` [PATCH v2 15/16] Don't change current program space in exec_target::close Tom Tromey
2020-10-19 21:44 ` [PATCH v2 16/16] Remove call to exec_close Tom Tromey
2020-10-20 14:46 ` [PP?] [PATCH v2 00/16] Remove some macros from exec.h and progspace.h Simon Marchi
2020-10-29 21:06   ` Tom Tromey

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=20201019214429.13815-2-tom@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