From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27925 invoked by alias); 25 Mar 2010 10:57:05 -0000 Received: (qmail 27906 invoked by uid 22791); 25 Mar 2010 10:57:04 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 25 Mar 2010 10:56:59 +0000 Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3) with ESMTP id o2PAuoCu004254; Thu, 25 Mar 2010 11:56:50 +0100 (CET) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.3/8.14.3/Submit) id o2PAumOq018611; Thu, 25 Mar 2010 11:56:48 +0100 (CET) Date: Thu, 25 Mar 2010 10:57:00 -0000 Message-Id: <201003251056.o2PAumOq018611@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: Paul_Koning@Dell.com CC: gdb@sourceware.org In-reply-to: (Paul_Koning@Dell.com) Subject: Re: Threads support -- right way to extend ptrace() calls? References: Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00203.txt.bz2 > Date: Fri, 19 Mar 2010 12:36:34 -0400 > From: "Paul Koning" > > Gentlepeople, > > I'm working on NetBSD support for threads. > > A lot of what is needed already exists in GDB, or exists with just small > modifications needed. That brings me to the question: > > NetBSD uses ptrace, so inf-ptrace.c does a lot of the work. Some pieces > are target architecture specific but common across BSD flavors, for > example i386bsd-nat.c does ptrace() getregs and setregs calls. > > In NetBSD, a thread is an LWP which exists underneath a process, so a > thread ID is a pair of PID and LWPID. The ptid datatype handles this > nicely. > > In a number of ptrace calls, for example the PT_GETREGS and PT_SETREGS > calls, the LWPID is now passed as the fourth argument, which was > reserved and in existing code is passed as zero. The simple answer is > to replace that 0 by TIDGET(ptid), and that works. > > But what is the right way to fit this into the bigger GDB? Copy those > get/set register target functions, with that change, into NetBSD > specific source files? Just change it in i386bsd-nat.c? In the latter > case that means other *BSD targets would get the change too, which would > be safe so long as they build ptid values with zero in the TID field or > if ptrace still ignores the fourth argument there. I could verify the > former fairly easily, but is that the right GDB way to proceed? I've not tracked the developments in FreeBSD on this front. But OpenBSD still ignores the fourth argument for the PT_GETREGS and PT_SETREGS requests. Assuming FreeBSD does this as well, I think I'm ok with modifying the BSD-specific -nat.c files in the way you suggest. I'm not so keen on having similar changes in the inf-ptrace.c code though. And if you need modifications there, you can't really use the code from i386-bsd.c. At that point you're probably better off having a nbsd-nat.c and putting the i386-specific bits in i386-nbsd.c Cheers, Mark