This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH/RFC] Support rthreads on OpenBSD 5.2 and later.
- From: Pedro Alves <palves at redhat dot com>
- To: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 28 Feb 2014 10:59:45 +0000
- Subject: Re: [PATCH/RFC] Support rthreads on OpenBSD 5.2 and later.
- Authentication-results: sourceware.org; auth=none
- References: <201402272243 dot s1RMheVq007573 at glazunov dot sibelius dot xs4all dot 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