From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70746 invoked by alias); 2 Mar 2018 00:51:25 -0000 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 Received: (qmail 69941 invoked by uid 89); 2 Mar 2018 00:51:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: 9pmail.ess.barracuda.com Received: from 9pmail.ess.barracuda.com (HELO 9pmail.ess.barracuda.com) (64.235.150.225) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 02 Mar 2018 00:51:23 +0000 Received: from MIPSMAIL01.mipstec.com (mailrelay.mips.com [12.201.5.28]) by mx1.ess.sfj.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Fri, 02 Mar 2018 00:51:13 +0000 Received: from [10.20.78.157] (10.20.78.157) by mips01.mipstec.com (10.20.43.31) with Microsoft SMTP Server id 14.3.361.1; Thu, 1 Mar 2018 16:13:36 -0800 Date: Fri, 02 Mar 2018 00:51:00 -0000 From: "Maciej W. Rozycki" To: John Baldwin CC: Subject: Re: [PATCH] Workaround a FreeBSD ptrace() bug with clearing thread events. In-Reply-To: <20180224000935.43344-1-jhb@FreeBSD.org> Message-ID: References: <20180224000935.43344-1-jhb@FreeBSD.org> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-BESS-ID: 1519951872-298552-9265-20437-7 X-BESS-VER: 2018.2-r1802232356 X-BESS-Apparent-Source-IP: 12.201.5.28 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.190580 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS59374 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status:1 X-SW-Source: 2018-03/txt/msg00043.txt.bz2 On Fri, 23 Feb 2018, John Baldwin wrote: > diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c > index d44950618c..9c87bfed33 100644 > --- a/gdb/fbsd-nat.c > +++ b/gdb/fbsd-nat.c > @@ -1163,6 +1163,39 @@ fbsd_resume (struct target_ops *ops, > } > ptid = inferior_ptid; > } > + > +#if __FreeBSD_version < 1200052 > + /* > + * When multiple threads within a process wish to report STOPPED > + * events from wait(), the kernel picks one thread event as the > + * thread event to report. The chosen thread event is retrieved via > + * PT_LWPINFO by passing the process ID as the request pid. If > + * multiple events are pending, then the subsequent wait() after > + * resuming a process will report another STOPPED event after > + * resuming the process to handle the next thread event and so on. > + * > + * A single thread event is cleared as a side effect of resuming the > + * process with PT_CONTINUE, PT_STEP, etc. In older kernels, > + * however, the request pid was used to select which thread's event > + * was cleared rather than always clearing the event that was just > + * reported. To avoid clearing the event of the wrong LWP, always > + * pass the process ID instead of an LWP ID to PT_CONTINUE or > + * PT_SYSCALL. Hmm, doesn't it have to be a run-time check then? Otherwise you're basing your decision on the host system GDB has been built for and not one it will be run on, which I suppose does not necessarily have to be of the same version. Or am I missing anything here? Maciej