From patchwork Tue Aug 29 19:25:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22412 Received: (qmail 15548 invoked by alias); 29 Aug 2017 19:37: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 15457 invoked by uid 89); 29 Aug 2017 19:37:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1789 X-HELO: gproxy3-pub.mail.unifiedlayer.com Received: from gproxy3-pub.mail.unifiedlayer.com (HELO gproxy3-pub.mail.unifiedlayer.com) (69.89.30.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 29 Aug 2017 19:37:33 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy3.mail.unifiedlayer.com (Postfix) with ESMTP id CA96641B17 for ; Tue, 29 Aug 2017 13:25:33 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id 37RW1w00b2f2jeq017RZyP; Tue, 29 Aug 2017 13:25:33 -0600 X-Authority-Analysis: v=2.2 cv=F98nTupN c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=KeKAF7QvOSUA:10 a=zstS-IiYAAAA:8 a=27OnYkit5VsE84OrQWYA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:36914 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dmm8g-004DCm-MS; Tue, 29 Aug 2017 13:25:30 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 10/10] Use std::string in reopen_exec_file Date: Tue, 29 Aug 2017 13:25:24 -0600 Message-Id: <20170829192524.29971-11-tom@tromey.com> In-Reply-To: <20170829192524.29971-1-tom@tromey.com> References: <20170829192524.29971-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dmm8g-004DCm-MS X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:36914 X-Source-Auth: tom+tromey.com X-Email-Count: 11 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes reopen_exec_file to use a std::string, removing a cleanup. ChangeLog 2017-08-29 Tom Tromey * corefile.c (reopen_exec_file): Use std::string. --- gdb/ChangeLog | 4 ++++ gdb/corefile.c | 11 +++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cc679ea..314a865 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-08-29 Tom Tromey + * corefile.c (reopen_exec_file): Use std::string. + +2017-08-29 Tom Tromey + * compile/compile.c (compile_register_name_mangled): Return std::string. * compile/compile-loc2c.c (pushf_register_address): Update. diff --git a/gdb/corefile.c b/gdb/corefile.c index 5631347..0996f9c 100644 --- a/gdb/corefile.c +++ b/gdb/corefile.c @@ -130,29 +130,24 @@ specify_exec_file_hook (void (*hook) (const char *)) void reopen_exec_file (void) { - char *filename; int res; struct stat st; - struct cleanup *cleanups; /* Don't do anything if there isn't an exec file. */ if (exec_bfd == NULL) return; /* If the timestamp of the exec file has changed, reopen it. */ - filename = xstrdup (bfd_get_filename (exec_bfd)); - cleanups = make_cleanup (xfree, filename); - res = stat (filename, &st); + std::string filename = bfd_get_filename (exec_bfd); + res = stat (filename.c_str (), &st); if (res == 0 && exec_bfd_mtime && exec_bfd_mtime != st.st_mtime) - exec_file_attach (filename, 0); + exec_file_attach (filename.c_str (), 0); else /* If we accessed the file since last opening it, close it now; this stops GDB from holding the executable open after it exits. */ bfd_cache_close_all (); - - do_cleanups (cleanups); } /* If we have both a core file and an exec file,