From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19572 invoked by alias); 18 Sep 2013 14:52:59 -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 19563 invoked by uid 89); 18 Sep 2013 14:52:59 -0000 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; Wed, 18 Sep 2013 14:52:59 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8IEqrNi023360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 18 Sep 2013 10:52:53 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r8IEqnQ7021657; Wed, 18 Sep 2013 10:52:50 -0400 Message-ID: <5239BE41.90607@redhat.com> Date: Wed, 18 Sep 2013 14:52: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: Yue Lu CC: Thomas Schwinge , gdb-patches , Luis Machado , bug-hurd@gnu.org Subject: [Hurd/gnu-nat.c] Use ptid_t.lwpid to store, thread ids instead of ptid_t.tid. (was: Re: [PATCH 1/2] Port gdbserver to GNU/Hurd) References: <87txi2i6t6.fsf@kepler.schwinge.homeip.net> <5225C3C6.8090101@redhat.com> <5228DBA7.9050408@redhat.com> <87ob87c5lr.fsf@kepler.schwinge.homeip.net> <87bo42b9l7.fsf@kepler.schwinge.homeip.net> <5239988F.6070600@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2013-09/txt/msg00603.txt.bz2 On 09/18/2013 02:48 PM, Yue Lu wrote: > On Wed, Sep 18, 2013 at 8:11 PM, Pedro Alves wrote: >> >> /me gives it a try. >> >> I grepped for ptid_build and ptid_get_tid in *gnu* files, and >> adjusted all I found. > > I have tried this way before, but it doesn't work. > After apply your patch, the gdb can't use, it says "Can't fetch > registers from thread Thread 29826.3: No such thread". ... > As before, I thought it is a big problem, so I don't dig into it. Your > last email has reminder me, both you and I forgot to patch the > i386gnu-nat.c which also used the tid filed. Eh, grep-fail then. > > Add this everything is ok. Nice, thanks. I've merged that in, and applied it. --------- Subject: [Hurd/gnu-nat.c] Use ptid_t.lwpid to store thread ids instead of ptid_t.tid. In preparation for reusing gnu-nat.c in gdbserver, switch to storing thread ids in the lwpid field of ptid_t rather than in the tid field. The Hurd's thread model is 1:1, so it doesn't feel wrong anyway. gdb/ 2013-09-18 Pedro Alves Yue Lu * gnu-nat.c (inf_validate_procs, gnu_wait, gnu_resume) (gnu_create_inferior) (gnu_attach, gnu_thread_alive, gnu_pid_to_str, cur_thread) (set_sig_thread_cmd): Use the lwpid field of ptids to store/extract thread ids instead of the tid field. * i386gnu-nat.c (gnu_fetch_registers): Adjust. --- gdb/gnu-nat.c | 24 ++++++++++++------------ gdb/i386gnu-nat.c | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index fa55b10..b4f99f8 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -1083,7 +1083,7 @@ inf_validate_procs (struct inf *inf) last = thread; proc_debug (thread, "new thread: %d", threads[i]); - ptid = ptid_build (inf->pid, 0, thread->tid); + ptid = ptid_build (inf->pid, thread->tid, 0); /* Tell GDB's generic thread code. */ @@ -1613,17 +1613,17 @@ rewait: thread = inf->wait.thread; if (thread) - ptid = ptid_build (inf->pid, 0, thread->tid); + ptid = ptid_build (inf->pid, thread->tid, 0); else if (ptid_equal (ptid, minus_one_ptid)) thread = inf_tid_to_thread (inf, -1); else - thread = inf_tid_to_thread (inf, ptid_get_tid (ptid)); + thread = inf_tid_to_thread (inf, ptid_get_lwp (ptid)); if (!thread || thread->port == MACH_PORT_NULL) { /* TID is dead; try and find a new thread. */ if (inf_update_procs (inf) && inf->threads) - ptid = ptid_build (inf->pid, 0, inf->threads->tid); /* The first + ptid = ptid_build (inf->pid, inf->threads->tid, 0); /* The first available thread. */ else @@ -2022,7 +2022,7 @@ gnu_resume (struct target_ops *ops, else /* Just allow a single thread to run. */ { - struct proc *thread = inf_tid_to_thread (inf, ptid_get_tid (ptid)); + struct proc *thread = inf_tid_to_thread (inf, ptid_get_lwp (ptid)); if (!thread) error (_("Can't run single thread id %s: no such thread!"), @@ -2033,7 +2033,7 @@ gnu_resume (struct target_ops *ops, if (step) { - step_thread = inf_tid_to_thread (inf, ptid_get_tid (ptid)); + step_thread = inf_tid_to_thread (inf, ptid_get_lwp (ptid)); if (!step_thread) warning (_("Can't step thread id %s: no such thread."), target_pid_to_str (ptid)); @@ -2133,7 +2133,7 @@ gnu_create_inferior (struct target_ops *ops, /* We now have thread info. */ thread_change_ptid (inferior_ptid, - ptid_build (inf->pid, 0, inf_pick_first_thread ())); + ptid_build (inf->pid, inf_pick_first_thread (), 0)); startup_inferior (inf->pending_execs); @@ -2190,7 +2190,7 @@ gnu_attach (struct target_ops *ops, char *args, int from_tty) inf_update_procs (inf); - inferior_ptid = ptid_build (pid, 0, inf_pick_first_thread ()); + inferior_ptid = ptid_build (pid, inf_pick_first_thread (), 0); /* We have to initialize the terminal settings now, since the code below might try to restore them. */ @@ -2261,7 +2261,7 @@ gnu_thread_alive (struct target_ops *ops, ptid_t ptid) { inf_update_procs (gnu_current_inf); return !!inf_tid_to_thread (gnu_current_inf, - ptid_get_tid (ptid)); + ptid_get_lwp (ptid)); } @@ -2596,7 +2596,7 @@ static char * gnu_pid_to_str (struct target_ops *ops, ptid_t ptid) { struct inf *inf = gnu_current_inf; - int tid = ptid_get_tid (ptid); + int tid = ptid_get_lwp (ptid); struct proc *thread = inf_tid_to_thread (inf, tid); if (thread) @@ -2729,7 +2729,7 @@ cur_thread (void) { struct inf *inf = cur_inf (); struct proc *thread = inf_tid_to_thread (inf, - ptid_get_tid (inferior_ptid)); + ptid_get_lwp (inferior_ptid)); if (!thread) error (_("No current thread.")); return thread; @@ -2928,7 +2928,7 @@ set_sig_thread_cmd (char *args, int from_tty) error (_("Thread ID %s not known. " "Use the \"info threads\" command to\n" "see the IDs of currently known threads."), args); - inf->signal_thread = inf_tid_to_thread (inf, ptid_get_tid (ptid)); + inf->signal_thread = inf_tid_to_thread (inf, ptid_get_lwp (ptid)); } } diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c index 0fd8d91..2b93fee 100644 --- a/gdb/i386gnu-nat.c +++ b/gdb/i386gnu-nat.c @@ -132,7 +132,7 @@ gnu_fetch_registers (struct target_ops *ops, inf_update_procs (gnu_current_inf); thread = inf_tid_to_thread (gnu_current_inf, - ptid_get_tid (inferior_ptid)); + ptid_get_lwp (inferior_ptid)); if (!thread) error (_("Can't fetch registers from thread %s: No such thread"), target_pid_to_str (inferior_ptid)); @@ -225,7 +225,7 @@ gnu_store_registers (struct target_ops *ops, inf_update_procs (gnu_current_inf); thread = inf_tid_to_thread (gnu_current_inf, - ptid_get_tid (inferior_ptid)); + ptid_get_lwp (inferior_ptid)); if (!thread) error (_("Couldn't store registers into thread %s: No such thread"), target_pid_to_str (inferior_ptid)); -- 1.7.11.7