From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30948 invoked by alias); 16 Jan 2006 16:19:52 -0000 Received: (qmail 30932 invoked by uid 22791); 16 Jan 2006 16:19:51 -0000 X-Spam-Check-By: sourceware.org Received: from fra-del-01.spheriq.net (HELO fra-del-01.spheriq.net) (195.46.51.97) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 16 Jan 2006 16:19:49 +0000 Received: from fra-out-02.spheriq.net (fra-out-02.spheriq.net [195.46.51.130]) by fra-del-01.spheriq.net with ESMTP id k0GGJjEp026331 for ; Mon, 16 Jan 2006 16:19:45 GMT Received: from fra-cus-01.spheriq.net (fra-cus-01.spheriq.net [195.46.51.37]) by fra-out-02.spheriq.net with ESMTP id k0GGJhOU024182 for ; Mon, 16 Jan 2006 16:19:45 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 k0GGJctU015948 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=OK); Mon, 16 Jan 2006 16:19:42 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 AA407DA42; Mon, 16 Jan 2006 16:19:32 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B2B9D47535; Mon, 16 Jan 2006 16:22:59 +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 CHD33000 (AUTH stubbsa); Mon, 16 Jan 2006 16:18:52 GMT Message-ID: <43CBC6EB.9080904@st.com> Date: Mon, 16 Jan 2006 16:19:00 -0000 From: Andrew STUBBS User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Daniel Jacobowitz Cc: gdb-patches@sources.redhat.com Subject: Re: [PATCH] Disable thread specific breakpoints when thread dies References: <43723446.7000903@st.com> <20051113184515.GG3599@nevyn.them.org> <437875B0.4000007@st.com> <20051114155659.GA25717@nevyn.them.org> <437A19DE.6040905@st.com> <437B47A1.4040705@st.com> <20051117034811.GB3057@nevyn.them.org> <437CA66B.9060201@st.com> <20060112162659.GA16141@nevyn.them.org> <43C7E466.9080703@st.com> <20060114160611.GA12603@nevyn.them.org> <43CB97A2.20205@st.com> In-Reply-To: <43CB97A2.20205@st.com> Content-Type: multipart/mixed; boundary="------------030203060305010809020002" 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.2.0 X-IsSubscribed: yes 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 X-SW-Source: 2006-01/txt/msg00195.txt.bz2 This is a multi-part message in MIME format. --------------030203060305010809020002 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 997 Andrew STUBBS wrote: > Now onto figuring out why it doesn't work.... The smoking gun seems to be here: [From linux-thread-db.c] static void detach_thread (ptid_t ptid, int verbose) { struct thread_info *thread_info; if (verbose) printf_unfiltered (_("[%s exited]\n"), target_pid_to_str (ptid)); /* Don't delete the thread now, because it still reports as active until it has executed a few instructions after the event breakpoint - if we deleted it now, "info threads" would cause us to re-attach to it. Just mark it as having had a TD_DEATH event. This means that we won't delete it from our thread list until we notice that it's dead (via prune_threads), or until something re-uses its thread ID. */ thread_info = find_thread_pid (ptid); gdb_assert (thread_info != NULL); thread_info->private->dying = 1; } The attached patch fixes the problem, but I don't know if it does it the best way. What do you think? Andrew Stubbs --------------030203060305010809020002 Content-Type: text/plain; name="prune_threads.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="prune_threads.patch" Content-length: 1949 2006-01-16 Amdrew Stubbs * gdbthread.h (prune_threads): Add prototype. * infrun.c (normal_stop): Call prune_threads(). * thread.c (prune_threads): Remove 'static'. Index: src/gdb/gdbthread.h =================================================================== --- src.orig/gdb/gdbthread.h 2006-01-16 16:08:57.000000000 +0000 +++ src/gdb/gdbthread.h 2006-01-16 16:13:57.000000000 +0000 @@ -80,6 +80,9 @@ extern struct thread_info *add_thread (p /* Delete an existing thread list entry. */ extern void delete_thread (ptid_t); +/* Delete all dead threads from the list. */ +extern void prune_threads (void); + /* Delete a step_resume_breakpoint from the thread database. */ extern void delete_step_resume_breakpoint (void *); Index: src/gdb/infrun.c =================================================================== --- src.orig/gdb/infrun.c 2006-01-16 16:08:57.000000000 +0000 +++ src/gdb/infrun.c 2006-01-16 16:13:57.000000000 +0000 @@ -3037,6 +3037,9 @@ Further execution is probably impossible if (stopped_by_random_signal) disable_current_display (); + /* Delete any threads which have died. */ + prune_threads (); + /* Don't print a message if in the middle of doing a "step n" operation for n > 1 */ if (step_multi && stop_step) Index: src/gdb/thread.c =================================================================== --- src.orig/gdb/thread.c 2006-01-16 16:08:57.000000000 +0000 +++ src/gdb/thread.c 2006-01-16 16:13:57.000000000 +0000 @@ -64,7 +64,6 @@ static void info_threads_command (char * static void thread_apply_command (char *, int); static void restore_current_thread (ptid_t); static void switch_to_thread (ptid_t ptid); -static void prune_threads (void); void delete_step_resume_breakpoint (void *arg) @@ -382,7 +381,7 @@ thread_alive (struct thread_info *tp) return 1; } -static void +void prune_threads (void) { struct thread_info *tp, *next; --------------030203060305010809020002--