From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 102605 invoked by alias); 30 Nov 2017 03:01:48 -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 102342 invoked by uid 89); 30 Nov 2017 03:01:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.50.164) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Nov 2017 03:01:45 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway23.websitewelcome.com (Postfix) with ESMTP id B96FB72D1 for ; Wed, 29 Nov 2017 21:01:43 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id KF6deB7X3RtUXKF6deIGCj; Wed, 29 Nov 2017 21:01:43 -0600 Received: from 71-218-90-63.hlrn.qwest.net ([71.218.90.63]:57898 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eKF6d-002PmB-I3; Wed, 29 Nov 2017 21:01:43 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/6] Remove cleanup from create_excep_cond_exprs Date: Thu, 30 Nov 2017 03:01:00 -0000 Message-Id: <20171130030140.14830-3-tom@tromey.com> In-Reply-To: <20171130030140.14830-1-tom@tromey.com> References: <20171130030140.14830-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1eKF6d-002PmB-I3 X-Source-Sender: 71-218-90-63.hlrn.qwest.net (bapiya.Home) [71.218.90.63]:57898 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-SW-Source: 2017-11/txt/msg00818.txt.bz2 This removes a cleanup from create_excep_cond_exprs by changing ada_exception_catchpoint_cond_string to return a std::string. ChangeLog 2017-11-29 Tom Tromey * ada-lang.c (create_excep_cond_exprs): Update. (ada_exception_catchpoint_cond_string): Return std::string. --- gdb/ChangeLog | 5 +++++ gdb/ada-lang.c | 28 ++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index d5dfa07b78..28df250104 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12177,7 +12177,8 @@ ada_exception_name_addr (enum ada_exception_catchpoint_kind ex, return result; } -static char *ada_exception_catchpoint_cond_string (const char *excep_string); +static std::string ada_exception_catchpoint_cond_string + (const char *excep_string); /* Ada catchpoints. @@ -12242,9 +12243,7 @@ struct ada_catchpoint : public breakpoint static void create_excep_cond_exprs (struct ada_catchpoint *c) { - struct cleanup *old_chain; struct bp_location *bl; - char *cond_string; /* Nothing to do if there's no specific exception to catch. */ if (c->excep_string == NULL) @@ -12256,8 +12255,8 @@ create_excep_cond_exprs (struct ada_catchpoint *c) /* Compute the condition expression in text form, from the specific expection we want to catch. */ - cond_string = ada_exception_catchpoint_cond_string (c->excep_string); - old_chain = make_cleanup (xfree, cond_string); + std::string cond_string + = ada_exception_catchpoint_cond_string (c->excep_string); /* Iterate over all the catchpoint's locations, and parse an expression for each. */ @@ -12271,7 +12270,7 @@ create_excep_cond_exprs (struct ada_catchpoint *c) { const char *s; - s = cond_string; + s = cond_string.c_str (); TRY { exp = parse_exp_1 (&s, bl->address, @@ -12289,8 +12288,6 @@ create_excep_cond_exprs (struct ada_catchpoint *c) ada_loc->excep_cond_expr = std::move (exp); } - - do_cleanups (old_chain); } /* ada_catchpoint destructor. */ @@ -12898,12 +12895,9 @@ ada_exception_breakpoint_ops (enum ada_exception_catchpoint_kind ex) /* Return the condition that will be used to match the current exception being raised with the exception that the user wants to catch. This assumes that this condition is used when the inferior just triggered - an exception catchpoint. - - The string returned is a newly allocated string that needs to be - deallocated later. */ + an exception catchpoint. */ -static char * +static std::string ada_exception_catchpoint_cond_string (const char *excep_string) { int i; @@ -12931,11 +12925,13 @@ ada_exception_catchpoint_cond_string (const char *excep_string) { if (strcmp (standard_exc [i], excep_string) == 0) { - return xstrprintf ("long_integer (e) = long_integer (&standard.%s)", - excep_string); + return + string_printf ("long_integer (e) = long_integer (&standard.%s)", + excep_string); } } - return xstrprintf ("long_integer (e) = long_integer (&%s)", excep_string); + return string_printf ("long_integer (e) = long_integer (&%s)", + excep_string); } /* Return the symtab_and_line that should be used to insert an exception -- 2.13.6