From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1136 invoked by alias); 28 Feb 2014 10:59:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 1126 invoked by uid 89); 28 Feb 2014 10:59:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Feb 2014 10:59:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1SAxltZ030648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Feb 2014 05:59:47 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s1SAxjle002820; Fri, 28 Feb 2014 05:59:46 -0500 Message-ID: <53106C21.9050608@redhat.com> Date: Fri, 28 Feb 2014 10:59:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Mark Kettenis CC: gdb-patches@sourceware.org Subject: Re: [PATCH/RFC] Support rthreads on OpenBSD 5.2 and later. References: <201402272243.s1RMheVq007573@glazunov.sibelius.xs4all.nl> In-Reply-To: <201402272243.s1RMheVq007573@glazunov.sibelius.xs4all.nl> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-SW-Source: 2014-02/txt/msg00855.txt.bz2 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