From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22572 invoked by alias); 9 Aug 2008 22:48:55 -0000 Received: (qmail 22562 invoked by uid 22791); 9 Aug 2008 22:48:55 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 09 Aug 2008 22:48:18 +0000 Received: (qmail 10779 invoked from network); 9 Aug 2008 22:48:16 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Aug 2008 22:48:16 -0000 From: Pedro Alves To: gdb-patches@sourceware.org Subject: Re: ttrace: Protocal error Date: Sat, 09 Aug 2008 22:48:00 -0000 User-Agent: KMail/1.9.9 Cc: "John David Anglin" References: <20080808201457.3064B4EBE@hiauly1.hia.nrc.ca> <200808091551.17013.pedro@codesourcery.com> In-Reply-To: <200808091551.17013.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_r6hnISuh9VwS52+" Message-Id: <200808092348.11721.pedro@codesourcery.com> 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: 2008-08/txt/msg00262.txt.bz2 --Boundary-00=_r6hnISuh9VwS52+ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Content-length: 651 On Saturday 09 August 2008 15:51:16, Pedro Alves wrote: > Also, when we detect a TTEVT_LWP_CREATE, TTEVT_LWP_EXIT or > TTEVT_LWP_TERMINATE, The ttrace docs indicate that only one lwp is > stopped. =A0There's no reason to stop all lwps, and return > TARGET_WAITKING_SPURIOUS, only to resume all lwps again. > This just adds overhead and messes more with the > scheduling of the inferior than needed. =A0We could just resume > the stopped lwp, and return TARGET_WAITKIND_IGNORE. Here's a patch to do this. It applies on top of the other I just sent, which itself applied on top of my other patch to always register the main thread. --=20 Pedro Alves --Boundary-00=_r6hnISuh9VwS52+ Content-Type: text/x-diff; charset="iso-8859-1"; name="fix_daves_bug_part_2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="fix_daves_bug_part_2.diff" Content-length: 2720 2008-08-09 Pedro Alves * inf-ttrace.c (inf_ttrace_wait): On TTEVT_LWP_CREATE and LWP_TERMINATE, resume the caller thread. On TTEVT_LWP_CREATE, TTEVT_LWP_EXIT and TTEVT_LWP_TERMINATE, don't stop the whole process, and return TARGET_WAITKIND_IGNORE. --- gdb/inf-ttrace.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) Index: src/gdb/inf-ttrace.c =================================================================== --- src.orig/gdb/inf-ttrace.c 2008-08-09 23:15:40.000000000 +0100 +++ src/gdb/inf-ttrace.c 2008-08-09 23:15:53.000000000 +0100 @@ -1041,7 +1041,12 @@ inf_ttrace_wait (ptid_t ptid, struct tar sizeof (struct inf_ttrace_private_thread_info)); inf_ttrace_num_lwps++; ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0); - break; + /* Let the lwp_create-caller thread continue. */ + ttrace (TT_LWP_CONTINUE, ptid_get_pid (ptid), + ptid_get_lwp (ptid), TT_NOPC, 0, 0); + /* Return without stopping the whole process. */ + ourstatus->kind = TARGET_WAITKIND_IGNORE; + return ptid; case TTEVT_LWP_EXIT: if (print_thread_events) @@ -1050,22 +1055,31 @@ inf_ttrace_wait (ptid_t ptid, struct tar gdb_assert (ti != NULL); ((struct inf_ttrace_private_thread_info *)ti->private)->dying = 1; inf_ttrace_num_lwps--; + /* Let the thread really exit. */ ttrace (TT_LWP_CONTINUE, ptid_get_pid (ptid), ptid_get_lwp (ptid), TT_NOPC, 0, 0); - /* If we don't return -1 here, core GDB will re-add the thread. */ - ptid = minus_one_ptid; - break; + /* Return without stopping the whole process. */ + ourstatus->kind = TARGET_WAITKIND_IGNORE; + return ptid; case TTEVT_LWP_TERMINATE: lwpid = tts.tts_u.tts_thread.tts_target_lwpid; ptid = ptid_build (tts.tts_pid, lwpid, 0); - printf_filtered(_("[%s has been terminated]\n"), target_pid_to_str (ptid)); + if (print_thread_events) + printf_unfiltered(_("[%s has been terminated]\n") + target_pid_to_str (ptid)); ti = find_thread_pid (ptid); gdb_assert (ti != NULL); ((struct inf_ttrace_private_thread_info *)ti->private)->dying = 1; inf_ttrace_num_lwps--; + + /* Resume the lwp_terminate-caller thread. */ ptid = ptid_build (tts.tts_pid, tts.tts_lwpid, 0); - break; + ttrace (TT_LWP_CONTINUE, ptid_get_pid (ptid), + ptid_get_lwp (ptid), TT_NOPC, 0, 0); + /* Return without stopping the whole process. */ + ourstatus->kind = TARGET_WAITKIND_IGNORE; + return ptid; case TTEVT_SIGNAL: ourstatus->kind = TARGET_WAITKIND_STOPPED; --Boundary-00=_r6hnISuh9VwS52+--