From patchwork Sat May 19 15:23:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27335 Received: (qmail 107135 invoked by alias); 19 May 2018 15:23:22 -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 107118 invoked by uid 89); 19 May 2018 15:23:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.145.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 May 2018 15:23:20 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id D687BA183E1 for ; Sat, 19 May 2018 10:23:18 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id K3hWfVlrBWCOCK3hWfM4im; Sat, 19 May 2018 10:23:18 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:36450 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fK3hW-002Njt-M2; Sat, 19 May 2018 10:23:18 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Use std::unique_ptr in dwarf2_read_debug_names Date: Sat, 19 May 2018 09:23:16 -0600 Message-Id: <20180519152316.18973-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fK3hW-002Njt-M2 X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:36450 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This changes dwarf2_read_debug_names to use std::unique_ptr from the outset. This simplifies the code that installs the resulting map into dwarf2_per_objfile. Tested by the buildbot. gdb/ChangeLog 2018-05-19 Tom Tromey * dwarf2read.c (dwarf2_read_debug_names): Use std::unique_ptr. --- gdb/ChangeLog | 4 ++++ gdb/dwarf2read.c | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 0690785c5e..9a77502826 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -5603,17 +5603,18 @@ create_cus_from_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile, static bool dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile) { - mapped_debug_names local_map (dwarf2_per_objfile); + std::unique_ptr map + (new mapped_debug_names (dwarf2_per_objfile)); mapped_debug_names dwz_map (dwarf2_per_objfile); struct objfile *objfile = dwarf2_per_objfile->objfile; if (!read_debug_names_from_section (objfile, objfile_name (objfile), &dwarf2_per_objfile->debug_names, - local_map)) + *map)) return false; /* Don't use the index if it's empty. */ - if (local_map.name_count == 0) + if (map->name_count == 0) return false; /* If there is a .dwz file, read it so we can get its CU list as @@ -5631,9 +5632,9 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile) } } - create_cus_from_debug_names (dwarf2_per_objfile, local_map, dwz_map); + create_cus_from_debug_names (dwarf2_per_objfile, *map, dwz_map); - if (local_map.tu_count != 0) + if (map->tu_count != 0) { /* We can only handle a single .debug_types when we have an index. */ @@ -5644,15 +5645,13 @@ dwarf2_read_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile) dwarf2_per_objfile->types, 0); create_signatured_type_table_from_debug_names - (dwarf2_per_objfile, local_map, section, &dwarf2_per_objfile->abbrev); + (dwarf2_per_objfile, *map, section, &dwarf2_per_objfile->abbrev); } create_addrmap_from_aranges (dwarf2_per_objfile, &dwarf2_per_objfile->debug_aranges); - dwarf2_per_objfile->debug_names_table.reset - (new mapped_debug_names (dwarf2_per_objfile)); - *dwarf2_per_objfile->debug_names_table = std::move (local_map); + dwarf2_per_objfile->debug_names_table = std::move (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 ());