From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4999 invoked by alias); 18 Aug 2011 19:05:11 -0000 Received: (qmail 4990 invoked by uid 22791); 18 Aug 2011 19:05:09 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Aug 2011 19:04:53 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7IJ4jwQ024790 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 18 Aug 2011 15:04:45 -0400 Received: from host1.jankratochvil.net (ovpn-116-17.ams2.redhat.com [10.36.116.17]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7IJ4gxQ026628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 18 Aug 2011 15:04:44 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p7IJ4fdZ015742; Thu, 18 Aug 2011 21:04:41 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p7IJ4enb015734; Thu, 18 Aug 2011 21:04:40 +0200 Date: Thu, 18 Aug 2011 19:05:00 -0000 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: [patch] Code cleanup: Remove commands_left [Do not bpstat_clear_actions on throw_exception] Message-ID: <20110818190440.GA6072@host1.jankratochvil.net> References: <20110805201417.GA23405@host1.jankratochvil.net> <201108081644.08465.pedro@codesourcery.com> <20110818153413.GA23189@host1.jankratochvil.net> <201108181742.19980.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201108181742.19980.pedro@codesourcery.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-08/txt/msg00362.txt.bz2 On Thu, 18 Aug 2011 18:42:19 +0200, Pedro Alves wrote: > Since bs->commands is refcounted, I don't understand > why we need bs->commands_left at all. bpstat_do_actions_1 > could instead itself skip the first command if it is "silent". To make the discussion easier let's remove it first. The patch is simple, I will check it in soon myself. No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. Thanks, Jan gdb/ 2011-08-18 Jan Kratochvil Code cleanup. * breakpoint.c (bpstat_clear_actions): Remove clearing of commands_left. (command_line_is_silent): New function. (bpstat_do_actions_1): No longer use commands_left, use command_line_is_silent for commands. (bpstat_alloc): Remove clearing of commands_left. (bpstat_stop_status): Remove initialization of commands_left, use command_line_is_silent. * breakpoint.h (struct bpstats): Remove commands_left. --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3194,7 +3194,7 @@ bpstat_clear_actions (bpstat bs) for (; bs != NULL; bs = bs->next) { decref_counted_command_line (&bs->commands); - bs->commands_left = NULL; + if (bs->old_val != NULL) { value_free (bs->old_val); @@ -3231,6 +3231,16 @@ cleanup_executing_breakpoints (void *ignore) executing_breakpoint_commands = 0; } +/* Return non-zero iff CMD as the first line of a command sequence is `silent' + or its equivalent. */ + +static int +command_line_is_silent (struct command_line *cmd) +{ + return cmd && (strcmp ("silent", cmd->line) == 0 + || (xdb_commands && strcmp ("Q", cmd->line) == 0)); +} + /* Execute all the commands associated with all the breakpoints at this location. Any of these commands could cause the process to proceed beyond this point, etc. We look out for such changes by @@ -3279,10 +3289,13 @@ bpstat_do_actions_1 (bpstat *bsp) the tree when we're done. */ ccmd = bs->commands; bs->commands = NULL; - this_cmd_tree_chain - = make_cleanup_decref_counted_command_line (&ccmd); - cmd = bs->commands_left; - bs->commands_left = NULL; + this_cmd_tree_chain = make_cleanup_decref_counted_command_line (&ccmd); + cmd = ccmd ? ccmd->commands : NULL; + if (command_line_is_silent (cmd)) + { + /* The action has been already done by bpstat_stop_status. */ + cmd = cmd->next; + } while (cmd != NULL) { @@ -3474,7 +3487,6 @@ bpstat_alloc (struct bp_location *bl, bpstat **bs_link_pointer) incref_bp_location (bl); /* If the condition is false, etc., don't do the commands. */ bs->commands = NULL; - bs->commands_left = NULL; bs->old_val = NULL; bs->print_it = print_it_normal; return bs; @@ -4151,16 +4163,9 @@ bpstat_stop_status (struct address_space *aspace, bs->print = 0; bs->commands = b->commands; incref_counted_command_line (bs->commands); - bs->commands_left = bs->commands ? bs->commands->commands : NULL; - if (bs->commands_left - && (strcmp ("silent", bs->commands_left->line) == 0 - || (xdb_commands - && strcmp ("Q", - bs->commands_left->line) == 0))) - { - bs->commands_left = bs->commands_left->next; - bs->print = 0; - } + if (command_line_is_silent (bs->commands + ? bs->commands->commands : NULL)) + bs->print = 0; } /* Print nothing for this entry if we don't stop or don't print. */ --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -950,10 +950,6 @@ struct bpstats /* The associated command list. */ struct counted_command_line *commands; - /* Commands left to be done. This points somewhere in - base_command. */ - struct command_line *commands_left; - /* Old value associated with a watchpoint. */ struct value *old_val;