From owner-freebsd-arch@FreeBSD.ORG Wed Jan 14 14:05:23 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9474E16A4CE; Wed, 14 Jan 2004 14:05:23 -0800 (PST) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 264CC43D66; Wed, 14 Jan 2004 14:05:17 -0800 (PST) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.10/8.12.10) with ESMTP id i0EM3TUd054250; Wed, 14 Jan 2004 17:03:29 -0500 (EST) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i0EM3TH8054247; Wed, 14 Jan 2004 17:03:29 -0500 (EST) (envelope-from robert@fledge.watson.org) Date: Wed, 14 Jan 2004 17:03:29 -0500 (EST) From: Robert Watson X-Sender: robert@fledge.watson.org To: Julian Elischer In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: arch@freebsd.org cc: David Xu Subject: Re: ptrace and thread X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Jan 2004 22:05:23 -0000 On Wed, 14 Jan 2004, Julian Elischer wrote: > On Wed, 14 Jan 2004, David Xu wrote: > > > I am current working on debug support for KSE thread program, however I > > found > > ptrace interface is not thread-aware, in a threaded program, I need to > > get/set registers > > set for individual threads, current ptrace can not support that > > features, there are two > > ways to support these requirements: > > Yes I tried to address this a bit around the time when I added the > single ttreading code. Ialso made several posts looking for advice from > gdb/ptrace experts but got very little response.. As you noticed, the > ptrace facility is almost completely useless WRT threads.. > > it is possible to imagine an extension where you select a single thread > of interest but you would have to decide whether you want all the other > threads to be left running or left suspended.. (you may need both > possibilities to correctly debug a problem) > > The problem is that the thread becomes invisible to the kernel when it > crosses over to userland so the UTS needs to take an active part, > (unless the kernel can recognise when the thread has yielded and the UTS > has been enterred. (possible I guess) at which time single stepping > would be turned off allowing the UTS to run at full speed. > > The UTS would hav eto co-operate by using a method of re-enterring the > thread that allows the kernel to re-start single stepping.. > > What the other threads are doing in teh meanwhile is unknown. Apparnelty one common model is to get the application's (or threading package's) help in the debugging process. Teach gdb to talk to libkse, and have libkse provide the information on threading to gdb, as well as do the scheduling/assert control. FWIW, I think ptrace/procfs are in a somewhat broken state following KSE -- stuff like gdb works, but strace is known to hang. Part of the problem appears to be slightly different models for stopping the process -- p_step vs p_stop(). I'm still getting my head around the details of the debugging facilities, which is complicated by the fact that procfs is a lot more capable than the man page claims :-). I hope to dig more into the problem next week. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Senior Research Scientist, McAfee Research