From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30536 invoked by alias); 11 Aug 2010 20:11:17 -0000 Received: (qmail 30477 invoked by uid 22791); 11 Aug 2010 20:11:06 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD 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; Wed, 11 Aug 2010 20:10:32 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7BKAUPS026150 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 11 Aug 2010 16:10:30 -0400 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7BKASIS027407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 11 Aug 2010 16:10:30 -0400 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o7BKAS42016161 for ; Wed, 11 Aug 2010 22:10:28 +0200 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o7BKAR1K016160 for gdb-patches@sourceware.org; Wed, 11 Aug 2010 22:10:27 +0200 Date: Wed, 11 Aug 2010 20:11:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] Code cleanup: bpstat_alloc calling semantics standardization Message-ID: <20100811201027.GA16057@host1.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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: 2010-08/txt/msg00157.txt.bz2 Hi, this is just for the second patch I am going to send in a minute. I would not patch it standalone but I could not manage to code anything on top of it. No regressions on {x86_64,x86_64-m32,i686}-fedora14snapshot-linux-gnu. (Tested together with the second patch.) Thanks, Jan 2010-08-11 Jan Kratochvil Code cleanup. * breakpoint.c (bpstat_alloc): Remove unused prototype. (bpstat_alloc): Change parameters cbs to bs_link_pointer. Adjust the code. (bpstat_stop_status): Change root_bs into bs_head and bs_link. Adjust calls of bpstat_alloc. Remove explicit bs chain termination. --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -135,8 +135,6 @@ static void watchpoints_info (char *, int); static int breakpoint_1 (int, int, int (*) (const struct breakpoint *)); -static bpstat bpstat_alloc (const struct bp_location *, bpstat); - static int breakpoint_cond_eval (void *); static void cleanup_executing_breakpoints (void *); @@ -3442,15 +3440,17 @@ breakpoint_cond_eval (void *exp) return i; } -/* Allocate a new bpstat and chain it to the current one. */ +/* Allocate a new bpstat. Link it to the FIFO list by BS_LINK_POINTER. */ static bpstat -bpstat_alloc (const struct bp_location *bl, bpstat cbs /* Current "bs" value */ ) +bpstat_alloc (const struct bp_location *bl, bpstat **bs_link_pointer) { bpstat bs; bs = (bpstat) xmalloc (sizeof (*bs)); - cbs->next = bs; + bs->next = NULL; + **bs_link_pointer = bs; + *bs_link_pointer = &bs->next; bs->breakpoint_at = bl; /* If the condition is false, etc., don't do the commands. */ bs->commands = NULL; @@ -4027,10 +4027,10 @@ bpstat_stop_status (struct address_space *aspace, struct breakpoint *b = NULL; struct bp_location *bl; struct bp_location *loc; - /* Root of the chain of bpstat's */ - struct bpstats root_bs[1]; + /* First item of allocated bpstat's. */ + bpstat bs_head = NULL, *bs_link = &bs_head; /* Pointer to the last thing in the chain currently. */ - bpstat bs = root_bs; + bpstat bs; int ix; int need_remove_insert; @@ -4061,7 +4061,7 @@ bpstat_stop_status (struct address_space *aspace, /* Come here if it's a watchpoint, or if the break address matches */ - bs = bpstat_alloc (bl, bs); /* Alloc a bpstat to explain stop */ + bs = bpstat_alloc (bl, &bs_link); /* Alloc a bpstat to explain stop */ /* Assume we stop. Should we find watchpoint that is not actually triggered, or if condition of breakpoint is false, we'll reset @@ -4119,7 +4119,7 @@ bpstat_stop_status (struct address_space *aspace, if (breakpoint_address_match (loc->pspace->aspace, loc->address, aspace, bp_addr)) { - bs = bpstat_alloc (loc, bs); + bs = bpstat_alloc (loc, &bs_link); /* For hits of moribund locations, we should just proceed. */ bs->stop = 0; bs->print = 0; @@ -4127,15 +4127,13 @@ bpstat_stop_status (struct address_space *aspace, } } - bs->next = NULL; /* Terminate the chain */ - /* If we aren't stopping, the value of some hardware watchpoint may not have changed, but the intermediate memory locations we are watching may have. Don't bother if we're stopping; this will get done later. */ need_remove_insert = 0; - if (! bpstat_causes_stop (root_bs->next)) - for (bs = root_bs->next; bs != NULL; bs = bs->next) + if (! bpstat_causes_stop (bs_head)) + for (bs = bs_head; bs != NULL; bs = bs->next) if (!bs->stop && bs->breakpoint_at->owner && is_hardware_watchpoint (bs->breakpoint_at->owner)) @@ -4150,7 +4148,7 @@ bpstat_stop_status (struct address_space *aspace, if (need_remove_insert) update_global_location_list (1); - return root_bs->next; + return bs_head; } static void