From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17130 invoked by alias); 9 Nov 2005 17:41:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 17012 invoked by uid 22791); 9 Nov 2005 17:41:42 -0000 Received: from fra-del-01.spheriq.net (HELO fra-del-01.spheriq.net) (195.46.51.97) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 09 Nov 2005 17:41:42 +0000 Received: from fra-out-01.spheriq.net (fra-out-01.spheriq.net [195.46.51.129]) by fra-del-01.spheriq.net with ESMTP id jA9HfdhE018226 for ; Wed, 9 Nov 2005 17:41:39 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-01.spheriq.net with ESMTP id jA9Hfcix009759 for ; Wed, 9 Nov 2005 17:41:38 GMT Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by fra-cus-01.spheriq.net with ESMTP id jA9HfbMu029504 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK) for ; Wed, 9 Nov 2005 17:41:38 GMT Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 788F9DA41 for ; Wed, 9 Nov 2005 17:41:37 +0000 (GMT) Received: by zeta.dmz-eu.st.com (STMicroelectronics, from userid 60012) id 18F4E47333; Wed, 9 Nov 2005 17:44:33 +0000 (GMT) Received: from zeta.dmz-eu.st.com (localhost [127.0.0.1]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CBDB875995 for ; Wed, 9 Nov 2005 17:44:32 +0000 (UTC) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 44C724732F for ; Wed, 9 Nov 2005 17:44:32 +0000 (GMT) Received: from [164.129.15.13] (terrorhawk.bri.st.com [164.129.15.13]) by mail1.bri.st.com (MOS 3.5.8-GR) with ESMTP id CGQ00957 (AUTH "andrew stubbs"); Wed, 9 Nov 2005 17:41:35 GMT Message-ID: <43723446.7000903@st.com> Date: Wed, 09 Nov 2005 19:06:00 -0000 From: Andrew STUBBS User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [PATCH] Disable thread specific breakpoints when thread dies Content-Type: multipart/mixed; boundary="------------070705020404090407080900" X-O-Spoofed: Not Scanned X-O-General-Status: No X-O-Spam1-Status: Not Scanned X-O-Spam2-Status: Not Scanned X-O-URL-Status: Not Scanned X-O-Virus1-Status: No X-O-Virus2-Status: Not Scanned X-O-Virus3-Status: No X-O-Virus4-Status: No X-O-Virus5-Status: Not Scanned X-O-Image-Status: Not Scanned X-O-Attach-Status: Not Scanned X-SpheriQ-Ver: 4.1.07 X-SW-Source: 2005-11/txt/msg00111.txt.bz2 This is a multi-part message in MIME format. --------------070705020404090407080900 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 533 Hi, The attached patch disables thread specific breakpoints if they are hit (in another thread) after the specific thread has died. The rationale is that, once dead, the thread in question can never come back, and the breakpoint is then only a, potentially serious, performance drain. Even if another thread can be created with that ID it would not be appropriate to 'hit' the breakpoint. The breakpoint is not deleted, only disabled. It may still be easily re-enabled when the program is re-run. Is this OK? Andrew Stubbs --------------070705020404090407080900 Content-Type: text/plain; name="thread-break.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="thread-break.patch" Content-length: 1472 2005-11-09 Andrew Stubbs * breakpoint.c (breakpoint_thread_match): Disable thread specific breakpoints if we hit one after the thread has ceased to exist. Index: src/gdb/breakpoint.c =================================================================== --- src.orig/gdb/breakpoint.c 2005-05-29 04:13:17.000000000 +0100 +++ src/gdb/breakpoint.c 2005-11-01 13:49:40.000000000 +0000 @@ -1797,9 +1797,23 @@ breakpoint_thread_match (CORE_ADDR pc, p if ((breakpoint_enabled (bpt->owner) || bpt->owner->enable_state == bp_permanent) - && bpt->address == pc - && (bpt->owner->thread == -1 || bpt->owner->thread == thread)) + && bpt->address == pc) { + /* Disable matched breakpoint if thread no longer exists: this + prevents other tasks from hitting the breakpoint and improves + performance. */ + if ((bpt->owner->thread != -1) && (bpt->owner->thread != thread)) + { + if (!target_thread_alive(thread_id_to_pid(bpt->owner->thread))) + { + printf_filtered ( + "Breakpoint %d disabled as thread %d no longer alive.\n", + bpt->owner->number, bpt->owner->thread); + disable_breakpoint(bpt->owner); + } + continue; /* no need to consider this breakpoint any further */ + } + if (overlay_debugging && section_is_overlay (bpt->section) && !section_is_mapped (bpt->section)) --------------070705020404090407080900--