From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97001 invoked by alias); 14 Jul 2015 10:18:27 -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 96984 invoked by uid 89); 14 Jul 2015 10:18:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_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 (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 14 Jul 2015 10:18:25 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id C2FFABAEF4 for ; Tue, 14 Jul 2015 10:18:24 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6EAINkk012449; Tue, 14 Jul 2015 06:18:23 -0400 Message-ID: <55A4E1EF.7080204@redhat.com> Date: Tue, 14 Jul 2015 10:18:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Kevin Buettner , gdb-patches@sourceware.org Subject: Re: [PATCH] remote.c: Ensure that inferior_ptid is on the thread list References: <20150710135020.573a8f6c@pinnacle.lan> In-Reply-To: <20150710135020.573a8f6c@pinnacle.lan> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-07/txt/msg00394.txt.bz2 On 07/10/2015 09:50 PM, Kevin Buettner wrote: > get_current_thread() then calls remote_current_thread with (a null) > inferior_ptid. After the calls to putpkt() and getpkt(), rs->buf[0] is 'Q', > so read_ptid() is called and its result is returned. > > The buffer passed to read_ptid() is " not supported". read_ptid ultimately > returns a ptid of {pid = 4200, lwp = 0, tid = 0}. > Urgh. Showing a snippet of the "set debug remote 1" logs in question here would make this explanation clearer I think. > However, this thread is not on the thread list. An earlier call to > target_update_thread_list() had placed {pid = 42000, lwp = 1, tid = 0} > on the list. This is the only thread in the list. > > When these calls ultimately return to remote_start_remote(), > inferior_ptid gets set to {pid = 4200, lwp = 0, tid = 0}, which > (again) is not on the thread list. > Seems like read_ptid should return null_ptid if it parsed nothing instead of that. And/or remote_current_thread should return null_ptid if there's more text after the read ptid string. > I'm guessing that the string " not supported" is coming from the > debug agent. If so, it should be fixed, but I don't see a reason > to not consult the thread list in order to place a valid thread id > in inferior_ptid. Yeah, that seems fine. > > This (consultation of the thread list) is what is done when > inferior_ptid is null_ptid: > > if (ptid_equal (inferior_ptid, null_ptid)) > { Would you mind adding a remote_debug log here? > /* Odd... The target was able to list threads, but not > tell us which thread was current (no "thread" > register in T stop reply?). Just pick the first > thread in the thread list then. */ > inferior_ptid = thread_list->ptid; > } > > This change simply extends the test so that the "Odd..." case will > be used when inferior_ptid is not in the current set of threads. > > gdb/ChangeLog: > > * remote.c (remote_start_remote): Ensure that inferior_ptid is > set to a ptid from the thread list. Thanks, Pedro Alves