From patchwork Sun Oct 1 04:06:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23266 Received: (qmail 100230 invoked by alias); 1 Oct 2017 04:06:55 -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 100113 invoked by uid 89); 1 Oct 2017 04:06:53 -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_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:2017100, quits, H*Ad:U*tom X-HELO: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Oct 2017 04:06:52 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy6.mail.unifiedlayer.com (Postfix) with ESMTP id 4EF8F1E0630 for ; Sat, 30 Sep 2017 22:06:51 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id G46o1w0092f2jeq0146rTz; Sat, 30 Sep 2017 22:06:51 -0600 X-Authority-Analysis: v=2.2 cv=K/VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=UyMeADLQJI1eRy_35VcA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-0-208.hlrn.qwest.net ([75.166.0.208]:43148 helo=pokyo.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dyVWi-002l9R-5L; Sat, 30 Sep 2017 22:06:48 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 8/8] Use std::string in info_symbol_command Date: Sat, 30 Sep 2017 22:06:43 -0600 Message-Id: <20171001040643.25162-9-tom@tromey.com> In-Reply-To: <20171001040643.25162-1-tom@tromey.com> References: <20171001040643.25162-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dyVWi-002l9R-5L X-Source-Sender: 75-166-0-208.hlrn.qwest.net (pokyo.Home) [75.166.0.208]:43148 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes a cleanup by using std::string in info_symbol_command. 2017-09-30 Tom Tromey * printcmd.c (info_symbol_command): Use std::string. --- gdb/ChangeLog | 4 ++++ gdb/printcmd.c | 16 +++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 293c796..20fa08c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-09-30 Tom Tromey + * printcmd.c (info_symbol_command): Use std::string. + +2017-09-30 Tom Tromey + * top.c (gdb_safe_append_history): Use std::string. 2017-09-30 Tom Tromey diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a254e3a..994259d 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1314,7 +1314,7 @@ info_symbol_command (char *arg, int from_tty) = lookup_minimal_symbol_by_pc_section (sect_addr, osect).minsym)) { const char *obj_name, *mapped, *sec_name, *msym_name; - char *loc_string; + const char *loc_string; struct cleanup *old_chain; matches = 1; @@ -1325,14 +1325,14 @@ info_symbol_command (char *arg, int from_tty) /* Don't print the offset if it is zero. We assume there's no need to handle i18n of "sym + offset". */ + std::string string_holder; if (offset) - loc_string = xstrprintf ("%s + %u", msym_name, offset); + { + string_holder = string_printf ("%s + %u", msym_name, offset); + loc_string = string_holder.c_str (); + } else - loc_string = xstrprintf ("%s", msym_name); - - /* Use a cleanup to free loc_string in case the user quits - a pagination request inside printf_filtered. */ - old_chain = make_cleanup (xfree, loc_string); + loc_string = msym_name; gdb_assert (osect->objfile && objfile_name (osect->objfile)); obj_name = objfile_name (osect->objfile); @@ -1370,8 +1370,6 @@ info_symbol_command (char *arg, int from_tty) else printf_filtered (_("%s in section %s\n"), loc_string, sec_name); - - do_cleanups (old_chain); } } if (matches == 0)