From patchwork Thu Sep 28 19:50:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23205 Received: (qmail 10558 invoked by alias); 28 Sep 2017 19:50: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 10429 invoked by uid 89); 28 Sep 2017 19:50:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Thu, 28 Sep 2017 19:50:19 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy6.mail.unifiedlayer.com (Postfix) with ESMTP id 2D5AD1E0844 for ; Thu, 28 Sep 2017 13:50:18 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id F7qE1w00p2f2jeq017qHzw; Thu, 28 Sep 2017 13:50:18 -0600 X-Authority-Analysis: v=2.2 cv=K4VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=m4rabjG0t3iXMtJlksMA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-0-208.hlrn.qwest.net ([75.166.0.208]:56208 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dxep4-003LpU-Kv; Thu, 28 Sep 2017 13:50:14 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 05/12] Remove some cleanups from stack.c Date: Thu, 28 Sep 2017 13:50:04 -0600 Message-Id: <20170928195011.27382-6-tom@tromey.com> In-Reply-To: <20170928195011.27382-1-tom@tromey.com> References: <20170928195011.27382-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dxep4-003LpU-Kv X-Source-Sender: 75-166-0-208.hlrn.qwest.net (bapiya.Home) [75.166.0.208]:56208 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes some cleanups from stack.c by using std::string or gdb::unique_xmalloc_ptr. One cleanup remains in this file; I did not remove it here because it is handled in another patch series that has yet to be resolved. gdb/ChangeLog 2017-09-28 Tom Tromey * stack.c (parse_frame_specification): Use std::string (info_frame_command): Use gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 5 +++++ gdb/stack.c | 20 +++++--------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/gdb/stack.c b/gdb/stack.c index a00e0c5..53dc829 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1277,8 +1277,6 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p) numargs = 0; while (1) { - char *addr_string; - struct cleanup *cleanup; const char *p; /* Skip leading white space, bail of EOL. */ @@ -1290,9 +1288,8 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p) for (p = frame_exp; *p && !ISSPACE (*p); p++); - addr_string = savestring (frame_exp, p - frame_exp); + std::string addr_string (frame_exp, p - frame_exp); frame_exp = p; - cleanup = make_cleanup (xfree, addr_string); /* NOTE: Parse and evaluate expression, but do not use functions such as parse_and_eval_long or @@ -1302,9 +1299,7 @@ parse_frame_specification (const char *frame_exp, int *selected_frame_p) side-effects. */ if (numargs >= ARRAY_SIZE (args)) error (_("Too many args in frame specification")); - args[numargs++] = parse_and_eval (addr_string); - - do_cleanups (cleanup); + args[numargs++] = parse_and_eval (addr_string.c_str ()); } } @@ -1400,7 +1395,6 @@ info_frame_command (char *addr_exp, int from_tty) const char *pc_regname; int selected_frame_p; struct gdbarch *gdbarch; - struct cleanup *back_to = make_cleanup (null_cleanup, NULL); CORE_ADDR frame_pc; int frame_pc_p; /* Initialize it to avoid "may be used uninitialized" warning. */ @@ -1428,6 +1422,7 @@ info_frame_command (char *addr_exp, int from_tty) func = get_frame_function (fi); symtab_and_line sal = find_frame_sal (fi); s = sal.symtab; + gdb::unique_xmalloc_ptr func_only; if (func) { funname = SYMBOL_PRINT_NAME (func); @@ -1439,13 +1434,10 @@ info_frame_command (char *addr_exp, int from_tty) stored in the symbol table, but we stored a version with DMGL_PARAMS turned on, and here we don't want to display parameters. So remove the parameters. */ - char *func_only = cp_remove_params (funname); + func_only.reset (cp_remove_params (funname)); if (func_only) - { - funname = func_only; - make_cleanup (xfree, func_only); - } + funname = func_only.get (); } } else if (frame_pc_p) @@ -1697,8 +1689,6 @@ info_frame_command (char *addr_exp, int from_tty) if (count || need_nl) puts_filtered ("\n"); } - - do_cleanups (back_to); } /* Print briefly all stack frames or just the innermost COUNT_EXP