From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20196 invoked by alias); 25 Mar 2009 22:11:54 -0000 Received: (qmail 20188 invoked by uid 22791); 25 Mar 2009 22:11:54 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Mar 2009 22:11:49 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id E9D9D2BABE4; Wed, 25 Mar 2009 18:11:47 -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 ydRkgrQkdOXX; Wed, 25 Mar 2009 18:11:47 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id B22AD2BABE0; Wed, 25 Mar 2009 18:11:47 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 1382A5BD21; Wed, 25 Mar 2009 15:11:41 -0700 (PDT) Date: Wed, 25 Mar 2009 22:12:00 -0000 From: Joel Brobecker To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [RFA/commit] Minor cleanup in breakpoint_thread_match Message-ID: <20090325221141.GG9472@adacore.com> References: <20090325174911.GA9472@adacore.com> <20090325180033.GB9472@adacore.com> <200903251811.35835.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xQR6quUbZ63TTuTU" Content-Disposition: inline In-Reply-To: <200903251811.35835.pedro@codesourcery.com> User-Agent: Mutt/1.5.18 (2008-05-17) 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: 2009-03/txt/msg00569.txt.bz2 --xQR6quUbZ63TTuTU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 372 > > > 2009-03-25 Joel Brobecker > > > > > > * breakpoint.c (breakpoint_thread_match): Split a large condition > > > into several smaller conditions. No behavior change. > > > > Looks sane to me. Thanks, much, Pedro. Here is what I ended checking in. It's identical to the above, except for some whitespace screwups. -- Joel --xQR6quUbZ63TTuTU Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="cleanup.diff" Content-length: 1621 diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 7e50342..7ffdf77 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1893,28 +1893,39 @@ int breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid) { const struct bp_location *bpt; - int thread; - - thread = pid_to_thread_id (ptid); - + /* The thread ID associated to PTID, computed lazily. */ + int thread = -1; + ALL_BP_LOCATIONS (bpt) { if (bpt->loc_type != bp_loc_software_breakpoint && bpt->loc_type != bp_loc_hardware_breakpoint) continue; - if ((breakpoint_enabled (bpt->owner) - || bpt->owner->enable_state == bp_permanent) - && bpt->address == pc - && (bpt->owner->thread == -1 || bpt->owner->thread == thread)) + if (!breakpoint_enabled (bpt->owner) + && bpt->owner->enable_state != bp_permanent) + continue; + + if (bpt->address != pc) + continue; + + if (bpt->owner->thread != -1) { - if (overlay_debugging - && section_is_overlay (bpt->section) - && !section_is_mapped (bpt->section)) - continue; /* unmapped overlay -- can't be a match */ - else - return 1; + /* This is a thread-specific breakpoint. Check that ptid + matches that thread. If thread hasn't been computed yet, + it is now time to do so. */ + if (thread == -1) + thread = pid_to_thread_id (ptid); + if (bpt->owner->thread != thread) + continue; } + + if (overlay_debugging + && section_is_overlay (bpt->section) + && !section_is_mapped (bpt->section)) + continue; /* unmapped overlay -- can't be a match */ + + return 1; } return 0; --xQR6quUbZ63TTuTU--