This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Threads support -- right way to extend ptrace() calls?


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?

	paul 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]