From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19797 invoked by alias); 19 Apr 2017 08:23:18 -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 19760 invoked by uid 89); 19 Apr 2017 08:23:17 -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=frequently, HX-Received:Wed, trade X-HELO: mail-wm0-f68.google.com Received: from mail-wm0-f68.google.com (HELO mail-wm0-f68.google.com) (74.125.82.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Apr 2017 08:23:16 +0000 Received: by mail-wm0-f68.google.com with SMTP id d79so3555268wmi.2 for ; Wed, 19 Apr 2017 01:23:18 -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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=o/VUwLjAhmLvMwWUPkGVBYDufnhq6oDIy/LPUv6Ej7s=; b=ZYNplabNWLxWp3GjKRqs0QBwbrWO7OwG4YSDRmRk18MPMKc16vIAZCD5Lh4fneVO69 WdhAkXPkK7YTSmylC0RY5B3Rkg7XSlJ9ty+DheHxIMI/8F1zK6hOs+UbV6BkaQ/ERVIq CWGaEk5otjlTUn8GLSz605K7fJvT7K5qsyvg9qBznHsVoHlmsgHXYzBmrNG9GeHa6Zry NcUPZ3qWzw4D7nt/2BueqzRaXx7Ojte8hUktNf4jUOApgq5uwJxNOjM6U5Ofr76S6Kqa SP4iAwOhc6qJjdAJngumlHpUNgz4W3K8iIaXyVc1J/oei4K1tx6vi2ZRmLQb4YoP8FwK +32w== X-Gm-Message-State: AN3rC/7gilsojaX3vXjw2hmY0DV35cKKhPa1jYC0CB5wgjBAqL/La0zo hvu5cDP+MD/Zmw== X-Received: by 10.28.87.16 with SMTP id l16mr1689204wmb.114.1492590196346; Wed, 19 Apr 2017 01:23:16 -0700 (PDT) Received: from E107787-LIN ([194.214.185.158]) by smtp.gmail.com with ESMTPSA id u47sm2298457wrb.27.2017.04.19.01.23.15 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 19 Apr 2017 01:23:15 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 8/8] Fix removing inferiors from within "thread apply" commands References: <1491954673-29172-1-git-send-email-palves@redhat.com> <1491954673-29172-9-git-send-email-palves@redhat.com> <86o9w08ru5.fsf@gmail.com> <3e492ba6-f183-cc41-6b5c-cc23a6ed116a@redhat.com> Date: Wed, 19 Apr 2017 08:23:00 -0000 In-Reply-To: (Pedro Alves's message of "Thu, 13 Apr 2017 15:49:39 +0100") Message-ID: <86o9vsajrj.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) 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/msg00550.txt.bz2 Pedro Alves writes: > See patch below that implements this. I also added comments > explaining the thread_info and inferior objects' refcount handling > to hopefully make things clearer. > Yes, they are helpful. > I then realized that unlike thread_info objects, there's a > "current inferior" pointer, and switching the current > inferior always goes through a single function (set_current_inferior), > so we can make being the current inferior be a strong reference > accounted for in the inferior's refcount. This simplifies the It is reasonable to me. > inferior::deletable method's implementation which no longer > compares this with current_inferior(). It's just a trade off, > because now set_current_inferior and initialize_inferiors > must manage the refcounts. The end result is just the same. > Not sure which version is clearer -- this, or keeping inferior::deletable > as it was (and reverting the set_current_inferior change). > Maybe the other way is a little bit more efficient given > deleting inferiors is way less frequently done than switching > around the current inferior. OTOH maybe this way is clearer. > If you have a preference, let me know. This version is good to me. > -struct thread_info > +/* Threads are intrusively refcounted objects. Being the > + user-selected thread is normally considered an implicit strong > + reference and is thus not accounted in the refcount, unlike > + inferior objects. This is necessary, because there's no "current > + thread" pointer. Instead the current thread is inferred from the > + inferior_ptid global. However, when GDB needs to remember the > + selected thread to later restore it, GDB bumps the thread object's > + refcount, to prevent something deleting the thread object before > + reverting back (e.g., due to a "kill" command. If the thread Missing ")"? --=20 Yao (=E9=BD=90=E5=B0=A7)