From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 36691 invoked by alias); 7 Apr 2017 09:22:25 -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 36650 invoked by uid 89); 7 Apr 2017 09:22:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-wr0-f193.google.com Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 07 Apr 2017 09:22:22 +0000 Received: by mail-wr0-f193.google.com with SMTP id g19so18300897wrb.0 for ; Fri, 07 Apr 2017 02:22:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=O0vP3GVLaVG15RpmceWbifob7Yf4sytntttKdOkW8/A=; b=WMndjDjHUhaMcWZY0SFPQDjWoUx8rAoF0K3VeTwVdUhO5hcGi+QGZWB9WIZfn87W9l Xv5sFS7zdz7O+ca1VY5oz6wNFq0EAvxKGoHm+L0ENEDHgOTezly0M+Rw7bufklS/CMNz KkaEWz8Cv3LBWSv6GkdOa3LUXP6482pcBUzbH4I0JkU8Yh//Lt/ZjA4QpFZKFePDn4/5 M/WuPu2oHqPrRCwKHigLT3Vd3IDCxqgtQ4MSctBNyXIs/0ngtqUtYg3j2Dd3NIrhw6Es 39YAr/ejo2ZpGC41B35hA6V+XkfGQVx876NG6n7objg59998btvamBkg/itKavGzTy5u UCwQ== X-Gm-Message-State: AFeK/H1GYB2oPW0N9K9AGw+PiBXRoDk8RMB2tq2SoN2bClC1k+Tf6uTL 7IAMSXS7VKB7EQ== X-Received: by 10.28.226.4 with SMTP id z4mr27542436wmg.135.1491556942261; Fri, 07 Apr 2017 02:22:22 -0700 (PDT) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id o9sm5296757wrc.9.2017.04.07.02.22.21 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 07 Apr 2017 02:22:21 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 2/2] Don't delete thread_info if refcount isn't zero In-Reply-To: <9c8ed015-2eb0-9b5c-affc-b5ba59179a7f@redhat.com> (Pedro Alves's message of "Thu, 6 Apr 2017 11:18:27 +0100") References: <1f525e52-f547-63ac-0a31-e92686c9caf8@redhat.com> <1491426942-6306-1-git-send-email-yao.qi@linaro.org> <1491426942-6306-3-git-send-email-yao.qi@linaro.org> <9c8ed015-2eb0-9b5c-affc-b5ba59179a7f@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Date: Fri, 07 Apr 2017 09:22:00 -0000 Message-ID: <86a87sk1wz.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-04/txt/msg00162.txt.bz2 Pedro Alves writes: >> - tp =3D find_thread_ptid (old->inferior_ptid); >> - >> - /* If the previously selected thread belonged to a process that has >> - in the mean time been deleted (due to normal exit, detach, etc.), >> - then don't revert back to it, but instead simply drop back to no >> - thread selected. */ > > This comment still makes sense, with a small tweak -- saying "deleted" > has always been a bit misleading here: > > /* If the previously selected thread belonged to a process that has > in the mean time exited (or killed, detached, etc.), then don't reve= rt > back to it, but instead simply drop back to no thread selected. */ > > I'll be happy with restoring this comment alongside your new comment. The comments describe something different from what the code does. With my patch, in make_cleanup_restore_current_thread, if we can find thread_info by inferior_ptid, saved it in old->thread and increase the refcount, so that it won't be deleted, but it can be marked as exited. Then, in do_restore_current_thread_cleanup,=20 + if (old->thread !=3D NULL + && find_inferior_ptid (old->thread->ptid) !=3D NULL) + restore_current_thread (old->thread->ptid); else { restore_current_thread (null_ptid); the first line means we previously selected one existing thread, we still switch to that thread, which may be already marked as exited. It is nothing wrong as far as I can see. --=20 Yao (=E9=BD=90=E5=B0=A7)