public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 3/3] gdb: make symfile_segment_data::segment_info an std::vector
Date: Mon, 18 May 2020 21:35:33 -0400	[thread overview]
Message-ID: <20200519013533.1428830-4-simon.marchi@efficios.com> (raw)
In-Reply-To: <20200519013533.1428830-1-simon.marchi@efficios.com>

Change the symfile_segment_data::segment_info array to be an
std::vector.  No functional changes are expected.

gdb/ChangeLog:

	* symfile.h (struct symfile_segment_data)
	<~symfile_segment_data>: Remove.
	<segment_info>: Change to std::vector.
	* symfile.c (default_symfile_segments): Update.
	* elfread.c (elf_symfile_segments): Update.
---
 gdb/elfread.c | 4 +++-
 gdb/symfile.c | 4 +++-
 gdb/symfile.h | 7 +------
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index 822f443fa8d3..532fe96dcdca 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -117,7 +117,9 @@ elf_symfile_segments (bfd *abfd)
     data->segments.emplace_back (segments[i]->p_vaddr, segments[i]->p_memsz);
 
   num_sections = bfd_count_sections (abfd);
-  data->segment_info = XCNEWVEC (int, num_sections);
+
+  /* All elements are initialized to 0 (map to no segment).  */
+  data->segment_info.resize (num_sections);
 
   for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
     {
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 22793e736398..e6ec458504af 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -747,7 +747,9 @@ default_symfile_segments (bfd *abfd)
   symfile_segment_data_up data (new symfile_segment_data);
 
   num_sections = bfd_count_sections (abfd);
-  data->segment_info = XCNEWVEC (int, num_sections);
+
+  /* All elements are initialized to 0 (map to no segment).  */
+  data->segment_info.resize (num_sections);
 
   for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
     {
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 1f2395169af9..fe79f79a0482 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -93,11 +93,6 @@ struct symfile_segment_data
     CORE_ADDR size;
   };
 
-  ~symfile_segment_data ()
-  {
-    xfree (this->segment_info);
-  }
-
   /* The segments present in this file.  If there are
      two, the text segment is the first one and the data segment
      is the second one.  */
@@ -106,7 +101,7 @@ struct symfile_segment_data
   /* This is an array of entries recording which segment contains each BFD
      section.  SEGMENT_INFO[I] is S+1 if the I'th BFD section belongs to segment
      S, or zero if it is not in any segment.  */
-  int *segment_info = nullptr;
+  std::vector<int> segment_info;
 };
 
 using symfile_segment_data_up = std::unique_ptr<symfile_segment_data>;
-- 
2.26.2


  parent reply	other threads:[~2020-05-19  1:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  1:35 [PATCH 0/3] C++ification of symfile_segment_data Simon Marchi
2020-05-19  1:35 ` [PATCH 1/3] gdb: allocate symfile_segment_data with new Simon Marchi
2020-05-19  1:35 ` [PATCH 2/3] gdb: use std::vector to store segments in symfile_segment_data Simon Marchi
2020-05-19 14:55   ` Tom Tromey
2020-05-19 14:52     ` Simon Marchi
2020-05-19 15:44       ` Tom Tromey
2020-05-19  1:35 ` Simon Marchi [this message]
2020-05-19 14:57 ` [PATCH 0/3] C++ification of symfile_segment_data Tom Tromey
2020-05-19 16:25   ` Simon Marchi

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=20200519013533.1428830-4-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).