From patchwork Wed Feb 7 22:04:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 25869 Received: (qmail 4017 invoked by alias); 7 Feb 2018 22:04:45 -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 3821 invoked by uid 89); 7 Feb 2018 22:04:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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=Hx-languages-length:1776 X-HELO: gateway31.websitewelcome.com Received: from gateway31.websitewelcome.com (HELO gateway31.websitewelcome.com) (192.185.144.219) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 07 Feb 2018 22:04:42 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway31.websitewelcome.com (Postfix) with ESMTP id B94DE8EC7F for ; Wed, 7 Feb 2018 16:04:40 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id jXpYe1EwOuMnyjXpYehkQT; Wed, 07 Feb 2018 16:04:40 -0600 Received: from 174-29-33-254.hlrn.qwest.net ([174.29.33.254]:59168 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ejXpY-002nlZ-Gf; Wed, 07 Feb 2018 16:04:40 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 8/9] Use unique_xmalloc_ptr in build_id_to_debug_bfd Date: Wed, 7 Feb 2018 15:04:33 -0700 Message-Id: <20180207220434.6045-9-tom@tromey.com> In-Reply-To: <20180207220434.6045-1-tom@tromey.com> References: <20180207220434.6045-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1ejXpY-002nlZ-Gf X-Source-Sender: 174-29-33-254.hlrn.qwest.net (pokyo.Home) [174.29.33.254]:59168 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This changes build_id_to_debug_bfd to use a unique_xmalloc_ptr, removing a cleanup. 2018-02-07 Tom Tromey * build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr. --- gdb/ChangeLog | 4 ++++ gdb/build-id.c | 9 +++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8bd04e47c7..84115ab5a9 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2018-02-07 Tom Tromey + * build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr. + +2018-02-07 Tom Tromey + * source.c (find_source_lines): Use std::vector. 2018-02-07 Tom Tromey diff --git a/gdb/build-id.c b/gdb/build-id.c index 945da4f3cf..685a2b0370 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -95,8 +95,6 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) const gdb_byte *data = build_id; size_t size = build_id_len; char *s; - char *filename = NULL; - struct cleanup *inner; memcpy (link, debugdir, debugdir_len); s = &link[debugdir_len]; @@ -116,16 +114,15 @@ build_id_to_debug_bfd (size_t build_id_len, const bfd_byte *build_id) printf_unfiltered (_(" Trying %s\n"), link); /* lrealpath() is expensive even for the usually non-existent files. */ + gdb::unique_xmalloc_ptr filename; if (access (link, F_OK) == 0) - filename = lrealpath (link); + filename.reset (lrealpath (link)); if (filename == NULL) continue; /* We expect to be silent on the non-existing files. */ - inner = make_cleanup (xfree, filename); - abfd = gdb_bfd_open (filename, gnutarget, -1); - do_cleanups (inner); + abfd = gdb_bfd_open (filename.get (), gnutarget, -1); if (abfd == NULL) continue;