From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 95877 invoked by alias); 28 Sep 2017 20:11:07 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 94527 invoked by uid 89); 28 Sep 2017 20:11:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=*line, Fish X-HELO: gproxy5-pub.mail.unifiedlayer.com Received: from gproxy5-pub.mail.unifiedlayer.com (HELO gproxy5-pub.mail.unifiedlayer.com) (67.222.38.55) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 28 Sep 2017 20:11:05 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy5.mail.unifiedlayer.com (Postfix) with ESMTP id 9ADC214073F for ; Thu, 28 Sep 2017 13:50:18 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id F7qF1w02e2f2jeq017qJcZ; Thu, 28 Sep 2017 13:50:18 -0600 X-Authority-Analysis: v=2.2 cv=dZfw5Tfe c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=Y0rIlSU4lXTeKtCiIukA:9 a=19UzhTMxzJnCeVLN:21 a=z1Z2GypzMbRF2tsT:21 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 1dxep5-003LpU-AT; Thu, 28 Sep 2017 13:50:15 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 07/12] Remove some cleanups from tracepoint.c Date: Thu, 28 Sep 2017 20:11:00 -0000 Message-Id: <20170928195011.27382-8-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: 1dxep5-003LpU-AT 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: 8 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-09/txt/msg00883.txt.bz2 This removes some cleanups from tracepoint.c by using std::string. It also removes some unused cleanup declarations. gdb/ChangeLog 2017-09-28 Tom Tromey * tracepoint.c (trace_variable_command): Use std::string. (encode_actions_1): Remove unused declarations. (create_tsv_from_upload): Use std::string. --- gdb/ChangeLog | 6 ++++++ gdb/tracepoint.c | 42 ++++++++++++------------------------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 30e3a3a..daa55f6 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -371,10 +371,9 @@ validate_trace_state_variable_name (const char *name) static void trace_variable_command (char *args, int from_tty) { - struct cleanup *old_chain; LONGEST initval = 0; struct trace_state_variable *tsv; - char *name, *p; + char *name_start, *p; if (!args || !*args) error_no_arg (_("Syntax is $NAME [ = EXPR ]")); @@ -385,23 +384,22 @@ trace_variable_command (char *args, int from_tty) if (*p++ != '$') error (_("Name of trace variable should start with '$'")); - name = p; + name_start = p; while (isalnum (*p) || *p == '_') p++; - name = savestring (name, p - name); - old_chain = make_cleanup (xfree, name); + std::string name (name_start, p - name_start); p = skip_spaces (p); if (*p != '=' && *p != '\0') error (_("Syntax must be $NAME [ = EXPR ]")); - validate_trace_state_variable_name (name); + validate_trace_state_variable_name (name.c_str ()); if (*p == '=') initval = value_as_long (parse_and_eval (++p)); /* If the variable already exists, just change its initial value. */ - tsv = find_trace_state_variable (name); + tsv = find_trace_state_variable (name.c_str ()); if (tsv) { if (tsv->initial_value != initval) @@ -412,12 +410,11 @@ trace_variable_command (char *args, int from_tty) printf_filtered (_("Trace state variable $%s " "now has initial value %s.\n"), tsv->name, plongest (tsv->initial_value)); - do_cleanups (old_chain); return; } /* Create a new variable. */ - tsv = create_trace_state_variable (name); + tsv = create_trace_state_variable (name.c_str ()); tsv->initial_value = initval; observer_notify_tsv_created (tsv); @@ -425,8 +422,6 @@ trace_variable_command (char *args, int from_tty) printf_filtered (_("Trace state variable $%s " "created, with initial value %s.\n"), tsv->name, plongest (tsv->initial_value)); - - do_cleanups (old_chain); } static void @@ -663,7 +658,6 @@ void validate_actionline (const char *line, struct breakpoint *b) { struct cmd_list_element *c; - struct cleanup *old_chain = NULL; const char *tmp_p; const char *p; struct bp_location *loc; @@ -999,8 +993,6 @@ collection_list::collect_symbol (struct symbol *sym, /* Expressions are the most general case. */ if (treat_as_expr) { - struct cleanup *old_chain1 = NULL; - agent_expr_up aexpr = gen_trace_for_var (scope, gdbarch, sym, trace_string); @@ -1383,7 +1375,6 @@ encode_actions_1 (struct command_line *action, else { unsigned long addr; - struct cleanup *old_chain1 = NULL; expression_up exp = parse_exp_1 (&action_exp, tloc->address, block_for_pc (tloc->address), @@ -1478,8 +1469,6 @@ encode_actions_1 (struct command_line *action, action_exp = skip_spaces (action_exp); { - struct cleanup *old_chain1 = NULL; - expression_up exp = parse_exp_1 (&action_exp, tloc->address, block_for_pc (tloc->address), 1); @@ -3310,7 +3299,7 @@ static struct trace_state_variable * create_tsv_from_upload (struct uploaded_tsv *utsv) { const char *namebase; - char *buf; + std::string buf; int try_num = 0; struct trace_state_variable *tsv; struct cleanup *old_chain; @@ -3318,33 +3307,26 @@ create_tsv_from_upload (struct uploaded_tsv *utsv) if (utsv->name) { namebase = utsv->name; - buf = xstrprintf ("%s", namebase); + buf = namebase; } else { namebase = "__tsv"; - buf = xstrprintf ("%s_%d", namebase, try_num++); + buf = string_printf ("%s_%d", namebase, try_num++); } /* Fish for a name that is not in use. */ /* (should check against all internal vars?) */ - while (find_trace_state_variable (buf)) - { - xfree (buf); - buf = xstrprintf ("%s_%d", namebase, try_num++); - } - - old_chain = make_cleanup (xfree, buf); + while (find_trace_state_variable (buf.c_str ())) + buf = string_printf ("%s_%d", namebase, try_num++); /* We have an available name, create the variable. */ - tsv = create_trace_state_variable (buf); + tsv = create_trace_state_variable (buf.c_str ()); tsv->initial_value = utsv->initial_value; tsv->builtin = utsv->builtin; observer_notify_tsv_created (tsv); - do_cleanups (old_chain); - return tsv; } -- 2.9.5