From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28354 invoked by alias); 8 Oct 2013 11:48:40 -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 28308 invoked by uid 89); 8 Oct 2013 11:48:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 08 Oct 2013 11:48:38 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 580D01165DC for ; Tue, 8 Oct 2013 07:48:57 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id W23UMERLqb8v for ; Tue, 8 Oct 2013 07:48:57 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id D764C1165DD for ; Tue, 8 Oct 2013 07:48:56 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 342E6E105A; Tue, 8 Oct 2013 15:48:33 +0400 (RET) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [commit/Ada 1/4] Rework a bit Ada exception catchpoint support (in prep for GDB/MI) Date: Tue, 08 Oct 2013 11:48:00 -0000 Message-Id: <1381232908-5868-2-git-send-email-brobecker@adacore.com> In-Reply-To: <1381232908-5868-1-git-send-email-brobecker@adacore.com> References: <1381232908-5868-1-git-send-email-brobecker@adacore.com> X-SW-Source: 2013-10/txt/msg00211.txt.bz2 Hello, This patch reworks a bit how the different steps required to insert an Ada exception catchpoints are organized. They used to be: 1. Call a "decode" function which does: 1.a. Parse the command and its arguments 1.b. Create a SAL & OPS from some of those arguments 2. Call create_ada_exception_catchpoint using SAL as well as some of the arguments extracted above. The bulk of the change consists in integrating step (1.b) into step (2) in order to turn create_ada_exception_catchpoint into a function whose arguments are all user-level concepts. This paves the way from a straightforward implementation of the equivalent commands in the GDB/MI interpreter. gdb/ChangeLog: * ada-lang.c (ada_decode_exception_location): Delete. (create_ada_exception_catchpoint): Remove arguments "sal", "addr_string" and "ops". Add argument "ex_kind" instead. Adjust implementation accordingly, calling ada_exception_sal to get the entities it no longer gets passed as arguments. Document the function's arguments. (catch_ada_exception_command): Use catch_ada_exception_command_split instead of ada_decode_exception_location, and update call to create_ada_exception_catchpoint. (catch_ada_assert_command_split): Renames ada_decode_assert_location. Remove parameters "addr_string" and "ops", and now returns void. Adjust implementation accordingly. Update the function documentation. (catch_assert_command): Use catch_ada_assert_command_split instead of ada_decode_assert_location. Update call to create_ada_exception_catchpoint. Tested on x86_64-linux. I will check it in in a few days, pending comments. -- Joel --- gdb/ada-lang.c | 79 +++++++++++++++++++++------------------------------------- 1 file changed, 29 insertions(+), 50 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9ebc851..d6a6818 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12175,43 +12175,34 @@ ada_exception_sal (enum exception_catchpoint_kind ex, char *excep_string, return find_function_start_sal (sym, 1); } -/* Parse the arguments (ARGS) of the "catch exception" command. - - If the user asked the catchpoint to catch only a specific - exception, then save the exception name in ADDR_STRING. +/* Create an Ada exception catchpoint. - If the user provided a condition, then set COND_STRING to - that condition expression (the memory must be deallocated - after use). Otherwise, set COND_STRING to NULL. + EX_KIND is the kind of exception catchpoint to be created. - See ada_exception_sal for a description of all the remaining - function arguments of this function. */ + EXCEPT_STRING, if not NULL, indicates the name of the exception + to which this catchpoint applies. If NULL, this catchpoint is + expected to trigger for all exceptions. -static struct symtab_and_line -ada_decode_exception_location (char *args, char **addr_string, - char **excep_string, - char **cond_string, - const struct breakpoint_ops **ops) -{ - enum exception_catchpoint_kind ex; + COND_STRING, if not NULL, is the catchpoint condition. - catch_ada_exception_command_split (args, &ex, excep_string, cond_string); - return ada_exception_sal (ex, *excep_string, addr_string, ops); -} + TEMPFLAG, if nonzero, means that the underlying breakpoint + should be temporary. -/* Create an Ada exception catchpoint. */ + FROM_TTY is the usual argument passed to all commands implementations. */ static void create_ada_exception_catchpoint (struct gdbarch *gdbarch, - struct symtab_and_line sal, - char *addr_string, + enum exception_catchpoint_kind ex_kind, char *excep_string, char *cond_string, - const struct breakpoint_ops *ops, int tempflag, int from_tty) { struct ada_catchpoint *c; + char *addr_string = NULL; + const struct breakpoint_ops *ops = NULL; + struct symtab_and_line sal + = ada_exception_sal (ex_kind, excep_string, &addr_string, &ops); c = XNEW (struct ada_catchpoint); init_ada_exception_breakpoint (&c->base, gdbarch, sal, addr_string, @@ -12231,38 +12222,31 @@ catch_ada_exception_command (char *arg, int from_tty, { struct gdbarch *gdbarch = get_current_arch (); int tempflag; - struct symtab_and_line sal; - char *addr_string = NULL; + enum exception_catchpoint_kind ex_kind; char *excep_string = NULL; char *cond_string = NULL; - const struct breakpoint_ops *ops = NULL; tempflag = get_cmd_context (command) == CATCH_TEMPORARY; if (!arg) arg = ""; - sal = ada_decode_exception_location (arg, &addr_string, &excep_string, - &cond_string, &ops); - create_ada_exception_catchpoint (gdbarch, sal, addr_string, - excep_string, cond_string, ops, + catch_ada_exception_command_split (arg, &ex_kind, &excep_string, + &cond_string); + create_ada_exception_catchpoint (gdbarch, ex_kind, + excep_string, cond_string, tempflag, from_tty); } -/* Assuming that ARGS contains the arguments of a "catch assert" - command, parse those arguments and return a symtab_and_line object - for a failed assertion catchpoint. +/* Split the arguments specified in a "catch assert" command. - Set ADDR_STRING to the name of the function where the real - breakpoint that implements the catchpoint is set. + ARGS contains the command's arguments (or the empty string if + no arguments were passed). If ARGS contains a condition, set COND_STRING to that condition - (the memory needs to be deallocated after use). Otherwise, set - COND_STRING to NULL. */ + (the memory needs to be deallocated after use). */ -static struct symtab_and_line -ada_decode_assert_location (char *args, char **addr_string, - char **cond_string, - const struct breakpoint_ops **ops) +static void +catch_ada_assert_command_split (char *args, char **cond_string) { args = skip_spaces (args); @@ -12281,8 +12265,6 @@ ada_decode_assert_location (char *args, char **addr_string, the command. */ else if (args[0] != '\0') error (_("Junk at end of arguments.")); - - return ada_exception_sal (ex_catch_assert, NULL, addr_string, ops); } /* Implement the "catch assert" command. */ @@ -12293,19 +12275,16 @@ catch_assert_command (char *arg, int from_tty, { struct gdbarch *gdbarch = get_current_arch (); int tempflag; - struct symtab_and_line sal; - char *addr_string = NULL; char *cond_string = NULL; - const struct breakpoint_ops *ops = NULL; tempflag = get_cmd_context (command) == CATCH_TEMPORARY; if (!arg) arg = ""; - sal = ada_decode_assert_location (arg, &addr_string, &cond_string, &ops); - create_ada_exception_catchpoint (gdbarch, sal, addr_string, - NULL, cond_string, ops, tempflag, - from_tty); + catch_ada_assert_command_split (arg, &cond_string); + create_ada_exception_catchpoint (gdbarch, ex_catch_assert, + NULL, cond_string, + tempflag, from_tty); } /* Operators */ /* Information about operators given special treatment in functions -- 1.8.1.2