Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Threads support -- right way to extend ptrace() calls?
@ 2010-03-19 16:36 Paul Koning
  2010-03-25 10:57 ` Mark Kettenis
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Koning @ 2010-03-19 16:36 UTC (permalink / raw)
  To: gdb

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 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Threads support -- right way to extend ptrace() calls?
  2010-03-19 16:36 Threads support -- right way to extend ptrace() calls? Paul Koning
@ 2010-03-25 10:57 ` Mark Kettenis
  2010-03-26 21:26   ` Paul Koning
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Kettenis @ 2010-03-25 10:57 UTC (permalink / raw)
  To: Paul_Koning; +Cc: gdb

> Date: Fri, 19 Mar 2010 12:36:34 -0400
> From: "Paul Koning" <Paul_Koning@Dell.com>
> 
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Threads support -- right way to extend ptrace() calls?
  2010-03-25 10:57 ` Mark Kettenis
@ 2010-03-26 21:26   ` Paul Koning
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Koning @ 2010-03-26 21:26 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb

> > 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

Thanks Mark.

I've been heading in the direction you describe already, especially
since there are some more changes to ptrace() needed for the feature to
work right.  The net is that it looks cleanest to put all the changes
into nbsd-threads.c (or, if necessary, target hardware specific nbsd
files) and not clutter up the more general files with any of this.

I'm nearly done with this.  The main issue for contributing the changes
is that NetBSD additions are needed and those will need to be agreed to
before it's ready to go.

	paul


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-26 21:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-19 16:36 Threads support -- right way to extend ptrace() calls? Paul Koning
2010-03-25 10:57 ` Mark Kettenis
2010-03-26 21:26   ` Paul Koning

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox