From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23177 invoked by alias); 17 May 2010 21:22:54 -0000 Received: (qmail 23162 invoked by uid 22791); 17 May 2010 21:22:52 -0000 X-SWARE-Spam-Status: No, hits=-5.6 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; Mon, 17 May 2010 21:22:48 +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 o4HLMkSa026464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 17 May 2010 17:22:46 -0400 Received: from host0.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 o4HLMiQh025179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 17 May 2010 17:22:46 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id o4HLMhAt026600 for ; Mon, 17 May 2010 23:22:43 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id o4HLMhOF026599 for gdb-patches@sourceware.org; Mon, 17 May 2010 23:22:43 +0200 Date: Mon, 17 May 2010 21:25:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch 1/3] Clear stale specific locs, not whole bpts [rediff] Message-ID: <20100517212243.GA25843@host0.dyn.jankratochvil.net> References: <20100503200201.GB30386@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100503200201.GB30386@host0.dyn.jankratochvil.net> User-Agent: Mutt/1.5.20 (2009-08-17) 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-05/txt/msg00367.txt.bz2 Hi, while I do not have a reproducer of a bug I believe this is a right cleanup as currently after update_breakpoint_locations thread_info->stop_bpstat may contain stale bp_location references. Just the current code never dereferences such stale reference. As the new handle_inferior_event code can execute multiple actions where the preceding ones can call update_breakpoint_locations I have found this fixups as required for this patchset. Thanks, Jan gdb/ 2010-05-17 Jan Kratochvil Clear stale specific bp_location from former whole breakpoint. * breakpoint.c (delete_breakpoint): Move the stale referencing clear code ... (free_bp_location): ... here. Rename there the called function to bpstat_remove_bp_location_callback. (bpstat_remove_breakpoint_callback): Rename to ... (bpstat_remove_bp_location_callback): ... here, change DATA resolution to struct bp_location. Change the called function to bpstat_remove_bp_location. Create new declaration for the function. (bpstat_remove_breakpoint): Rename to ... (bpstat_remove_bp_location): ..., change the parameter to loc, adjust code for the new parameter type. --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -206,6 +206,9 @@ static void update_global_location_list (int); static void update_global_location_list_nothrow (int); +static int bpstat_remove_bp_location_callback (struct thread_info *th, + void *data); + static int is_hardware_watchpoint (const struct breakpoint *bpt); static int is_watchpoint (const struct breakpoint *bpt); @@ -5371,6 +5374,18 @@ allocate_bp_location (struct breakpoint *bpt) static void free_bp_location (struct bp_location *loc) { + /* Be sure no bpstat's are pointing at it after it's been freed. */ + /* FIXME, how can we find all bpstat's? + We just check stop_bpstat for now. Note that we cannot just + remove bpstats pointing at bpt from the stop_bpstat list + entirely, as breakpoint commands are associated with the bpstat; + if we remove it here, then the later call to + bpstat_do_actions (&stop_bpstat); + in event-top.c won't do anything, and temporary breakpoints + with commands won't work. */ + + iterate_over_threads (bpstat_remove_bp_location_callback, loc); + if (loc->cond) xfree (loc->cond); @@ -9219,14 +9234,14 @@ update_global_location_list_nothrow (int inserting) update_global_location_list (inserting); } -/* Clear BPT from a BPS. */ +/* Clear LOC from a BPS. */ static void -bpstat_remove_breakpoint (bpstat bps, struct breakpoint *bpt) +bpstat_remove_bp_location (bpstat bps, struct bp_location *loc) { bpstat bs; for (bs = bps; bs; bs = bs->next) - if (bs->breakpoint_at && bs->breakpoint_at->owner == bpt) + if (bs->breakpoint_at == loc) { bs->breakpoint_at = NULL; bs->old_val = NULL; @@ -9236,11 +9251,11 @@ bpstat_remove_breakpoint (bpstat bps, struct breakpoint *bpt) /* Callback for iterate_over_threads. */ static int -bpstat_remove_breakpoint_callback (struct thread_info *th, void *data) +bpstat_remove_bp_location_callback (struct thread_info *th, void *data) { - struct breakpoint *bpt = data; + struct bp_location *loc = data; - bpstat_remove_breakpoint (th->stop_bpstat, bpt); + bpstat_remove_bp_location (th->stop_bpstat, loc); return 0; } @@ -9303,18 +9318,6 @@ delete_breakpoint (struct breakpoint *bpt) xfree (bpt->exec_pathname); clean_up_filters (&bpt->syscalls_to_be_caught); - /* Be sure no bpstat's are pointing at it after it's been freed. */ - /* FIXME, how can we find all bpstat's? - We just check stop_bpstat for now. Note that we cannot just - remove bpstats pointing at bpt from the stop_bpstat list - entirely, as breakpoint commands are associated with the bpstat; - if we remove it here, then the later call to - bpstat_do_actions (&stop_bpstat); - in event-top.c won't do anything, and temporary breakpoints - with commands won't work. */ - - iterate_over_threads (bpstat_remove_breakpoint_callback, bpt); - /* Now that breakpoint is removed from breakpoint list, update the global location list. This will remove locations that used to belong to