From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52030 invoked by alias); 15 Sep 2017 18:25:10 -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 52016 invoked by uid 89); 15 Sep 2017 18:25:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,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; Fri, 15 Sep 2017 18:25:08 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4DC4337EEA for ; Fri, 15 Sep 2017 18:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4DC4337EEA Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.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 25845729DC; Fri, 15 Sep 2017 18:25:04 +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> Date: Fri, 15 Sep 2017 18:25:00 -0000 Message-ID: <87r2v7akfz.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/msg00423.txt.bz2 On Friday, September 15 2017, Pedro Alves wrote: > On 09/15/2017 05:33 AM, Sergio Durigan Junior wrote: > >> diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c >> index 752646310a..2226dc802d 100644 >> --- a/gdb/gdbserver/target.c >> +++ b/gdb/gdbserver/target.c >> @@ -26,14 +26,11 @@ struct target_ops *the_target; >> int >> set_desired_thread (int use_general) >> { >> - struct thread_info *found; >> - >> if (use_general == 1) >> - found = find_thread_ptid (general_thread); >> + switch_to_thread (general_thread); >> else >> - found = find_thread_ptid (cont_thread); >> + switch_to_thread (cont_thread); >> >> - current_thread = found; >> return (current_thread != NULL); > > Did you double-check whether this is equivalent? Off hand, I'd > think it is, but the minus_one_ptid check in switch_to_thread > gave me pause. there's a 'set_continue_thread (minus_one_ptid)' in > gdb in early connection setup. Looks like we never call > 'set_desired_thread(0)' nowadays though. [Hc predates vCont]. I think I see what you mean, and I confess I didn't know that you could set the current thread as minus_one_ptid. No, I haven't checked if cont_thread can be minus_one_ptid in any moment in time. As I said I did some tests here before sending the patch and nothing came up wrong. > 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'. Maybe that's because GDB's version of switch_to_thread also doesn't assert that ptid != minus_one_ptid... -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/