From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id F2A44388B03A for ; Tue, 19 May 2020 01:35:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org F2A44388B03A X-ASG-Debug-ID: 1589852140-0c856e6d3826590001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id g54uZtlw7G1TDg3w (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 18 May 2020 21:35:40 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from smarchi-efficios.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 38CBC441B21; Mon, 18 May 2020 21:35:40 -0400 (EDT) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-164-54.qc.cable.ebox.net[192.222.164.54] X-Barracuda-Apparent-Source-IP: 192.222.164.54 X-Barracuda-RBL-IP: 192.222.164.54 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/3] gdb: make symfile_segment_data::segment_info an std::vector Date: Mon, 18 May 2020 21:35:33 -0400 X-ASG-Orig-Subj: [PATCH 3/3] gdb: make symfile_segment_data::segment_info an std::vector Message-Id: <20200519013533.1428830-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519013533.1428830-1-simon.marchi@efficios.com> References: <20200519013533.1428830-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1589852140 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 2468 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.81946 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2020 01:35:42 -0000 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. : 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 segment_info; }; using symfile_segment_data_up = std::unique_ptr; -- 2.26.2