From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8233 invoked by alias); 21 Sep 2017 15:42:05 -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 8222 invoked by uid 89); 21 Sep 2017 15:42:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Thu, 21 Sep 2017 15:42:03 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E373B7E45B for ; Thu, 21 Sep 2017 15:42:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E373B7E45B Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=sergiodj@redhat.com Received: from localhost (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBB515EE06; Thu, 21 Sep 2017 15:42:01 +0000 (UTC) From: Sergio Durigan Junior To: Pedro Alves Cc: GDB Patches Subject: Re: [PATCH] Use "switch_to_thread" more thoroughly on gdbserver References: <20170915043357.26094-1-sergiodj@redhat.com> <6f36073a-eed8-123d-94ec-8922aa0aa648@redhat.com> <87r2v7akfz.fsf@redhat.com> Date: Thu, 21 Sep 2017 15:42:00 -0000 In-Reply-To: (Pedro Alves's message of "Thu, 21 Sep 2017 16:11:45 +0100") Message-ID: <87fubgjbxy.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00642.txt.bz2 On Thursday, September 21 2017, Pedro Alves wrote: > On 09/15/2017 07:25 PM, Sergio Durigan Junior wrote: >> On Friday, September 15 2017, Pedro Alves wrote: >> >>> Do you remember why that check is there in switch_to_thread in the >>> first place, as opposed to, say, an assertion? >> >> I tried to do some archaeology here and find the patch that implemented >> this feature, and it seems to me that the patch always used 'if' instead >> of an 'assert'. > > Yeah, gdbserver's switch_to_thread was added with your fork > inferior sharing series. Exactly. >> Maybe that's because GDB's version of switch_to_thread >> also doesn't assert that ptid != minus_one_ptid... > > Except it does: > > static void > switch_to_thread (thread_info *thr) > { > gdb_assert (thr != NULL); > ^^^^^^^^^^^^^^^^^^^^^^^^ > ... > > Called from: > > void > switch_to_thread (ptid_t ptid) > { > if (ptid == null_ptid) > switch_to_no_thread (); > else > switch_to_thread (find_thread_ptid (ptid)); > } > > ... and find_thread_ptid returns NULL because there's > never a thread with ptid == minus_one_ptid. Oh. There's an overload, then. And there's also a check to see if ptid == null_ptid. Maybe it's worth extending gdbserver's switch_to_thread to mimic that behaviour. -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/