Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH/RFC] Support rthreads on OpenBSD 5.2 and later.
Date: Fri, 28 Feb 2014 10:59:00 -0000	[thread overview]
Message-ID: <53106C21.9050608@redhat.com> (raw)
In-Reply-To: <201402272243.s1RMheVq007573@glazunov.sibelius.xs4all.nl>

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


  reply	other threads:[~2014-02-28 10:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-27 22:43 Mark Kettenis
2014-02-28 10:59 ` Pedro Alves [this message]
2014-02-28 18:36   ` Tom Tromey
2014-02-28 21:54   ` Mark Kettenis
2014-02-28 21:58     ` Tom Tromey
2014-02-28 22:14       ` Mark Kettenis
2014-03-03 12:07     ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53106C21.9050608@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox