This is the mail archive of the gdb-patches@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]

Re: [PATCH/RFC] Support rthreads on OpenBSD 5.2 and later.


Hey Mark,

On 02/27/2014 10:43 PM, Mark Kettenis wrote:
> OpenBSD 5.2 and later has a proper threads implementation based on
> kernel threads.  Debugging support is provided through additional
> ptrace(2) requests, so this diff extends the generic code in
> inf-ptrace.c with OpenBSD-specific code to discover additional
> threads.

Cool.

> I intend to commit this in a couple of days as I don't really expect
> other people to care.  But comments are welcome...

:-)

Looks fine to me.  Comments below.

> gdb/ChangeLog:
> 
>         * obsd-nat.h: New file.
>         * obsd-nat.c: New file.

Don't forget to Makefile glue to actually build this.  :-)

> +#include "inf-child.h"
> +#include "obsd-nat.h"
> +
> +/* OpenBSD 5.2 and later include rthreads which uses a thread model
> +   that maps userlan threads directly onto kernel threads in a 1:1

userland

> +
> +static void
> +obsd_find_new_threads (struct target_ops *ops)
> +{
> +  pid_t pid = ptid_get_pid (inferior_ptid);
> +  struct ptrace_thread_state pts;
> +
> +  if (ptrace(PT_GET_THREAD_FIRST, pid, (caddr_t)&pts, sizeof pts) == -1)

"ptrace ("

"(caddr_t) &pts"


> +    perror_with_name (("ptrace"));
> +
> +  while (pts.pts_tid != -1)
> +    {
> +      ptid_t ptid = ptid_build (pid, pts.pts_tid, 0);
> +
> +      if (!in_thread_list (ptid))
> +	{
> +	  if (ptid_get_lwp (inferior_ptid) == 0)
> +	    thread_change_ptid (inferior_ptid, ptid);
> +	  else
> +	    add_thread (ptid);
> +	}
> +
> +      if (ptrace(PT_GET_THREAD_NEXT, pid, (caddr_t)&pts, sizeof pts) == -1)

Ditto.

-- 
Pedro Alves


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