From patchwork Sat Apr 28 03:31:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 27016 Received: (qmail 127010 invoked by alias); 28 Apr 2018 03:31:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 126999 invoked by uid 89); 28 Apr 2018 03:31:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=H*RU:sk:barracu, Hx-spam-relays-external:sk:barracu, H*r:sk:barracu, HX-HELO:sk:barracu X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 28 Apr 2018 03:31:31 +0000 X-ASG-Debug-ID: 1524886283-0c856e6189c2afe0001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id 91jhlkdgjKYPqYBK (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 27 Apr 2018 23:31:23 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id 6806F441D67; Fri, 27 Apr 2018 23:31:23 -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 v2 1/3] Don't allocate mapped_index on the objfile obstack Date: Fri, 27 Apr 2018 23:31:19 -0400 X-ASG-Orig-Subj: [PATCH v2 1/3] Don't allocate mapped_index on the objfile obstack Message-Id: <20180428033121.20163-2-simon.marchi@polymtl.ca> In-Reply-To: <20180428033121.20163-1-simon.marchi@polymtl.ca> References: <20180428033121.20163-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1524886283 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: 2982 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.50382 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-IsSubscribed: yes To make things simpler, allocate it with new and manage its lifetime using a unique_ptr (just like mapped_debug_names). We can also std::move the temporary local_map in the permanent map. gdb/ChangeLog; * dwarf2read.h (struct dwarf2_per_objfile) : Change type to std::unique_ptr. * dwarf2read.c (dwarf2_per_objfile::~dwarf2_per_objfile): Don't manually destroy mapped_index. (dwarf2_read_index): Adjust for unique_ptr, use std::move. (dw2_symtab_iter_init): Adjust for unique_ptr. --- gdb/dwarf2read.c | 14 ++++---------- gdb/dwarf2read.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 9eb98b2eab8e..b3bcb43a519b 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -2153,9 +2153,6 @@ dwarf2_per_objfile::~dwarf2_per_objfile () if (dwz_file != NULL && dwz_file->dwz_bfd) gdb_bfd_unref (dwz_file->dwz_bfd); - if (index_table != NULL) - index_table->~mapped_index (); - /* Everything else should be on the objfile obstack. */ } @@ -3541,7 +3538,7 @@ to use the section anyway."), static int dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile) { - struct mapped_index local_map, *map; + struct mapped_index local_map; const gdb_byte *cu_list, *types_list, *dwz_list = NULL; offset_type cu_list_elements, types_list_elements, dwz_list_elements = 0; struct dwz_file *dwz; @@ -3601,11 +3598,8 @@ dwarf2_read_index (struct dwarf2_per_objfile *dwarf2_per_objfile) create_addrmap_from_index (dwarf2_per_objfile, &local_map); - map = XOBNEW (&objfile->objfile_obstack, struct mapped_index); - map = new (map) mapped_index (); - *map = local_map; - - dwarf2_per_objfile->index_table = map; + dwarf2_per_objfile->index_table.reset (new mapped_index); + *dwarf2_per_objfile->index_table = std::move (local_map); dwarf2_per_objfile->using_index = 1; dwarf2_per_objfile->quick_file_names_table = create_quick_file_names_table (dwarf2_per_objfile->all_comp_units.size ()); @@ -3920,7 +3914,7 @@ dw2_symtab_iter_init (struct dw2_symtab_iterator *iter, iter->next = 0; iter->global_seen = 0; - mapped_index *index = dwarf2_per_objfile->index_table; + mapped_index *index = dwarf2_per_objfile->index_table.get (); /* index is NULL if OBJF_READNOW. */ if (index != NULL && find_slot_in_mapped_hash (index, name, &iter->vec)) diff --git a/gdb/dwarf2read.h b/gdb/dwarf2read.h index 8e6c41dc09ef..f36d039e7bea 100644 --- a/gdb/dwarf2read.h +++ b/gdb/dwarf2read.h @@ -209,7 +209,7 @@ public: bool using_index = false; /* The mapped index, or NULL if .gdb_index is missing or not being used. */ - mapped_index *index_table = NULL; + std::unique_ptr index_table; /* The mapped index, or NULL if .debug_names is missing or not being used. */ std::unique_ptr debug_names_table;