From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 85145 invoked by alias); 10 Apr 2017 14:50:50 -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 83657 invoked by uid 89); 10 Apr 2017 14:50:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Apr 2017 14:50:47 +0000 Received: by mail-wm0-f43.google.com with SMTP id w204so9184151wmd.1 for ; Mon, 10 Apr 2017 07:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=mpPukVAlYIZzm5cxnQfymUXTz9AreZQQD7GcGYj+fo8=; b=Ma8rBPxTJ3X1u7ytoJbnSNGncNzi0r2W2jA3gKCKPbR+u4yOfR5V1q9pL3JK/tDHq3 ITorX95rQsn+DLAwdhtchAFVj1N6Rd8N/fC26EfBQv9eaTshr0O2hgTuzTU0rmnsLCVh T/CZz5An4GBJPehZOaCvS1Axt1+gDzZj0iTS031GEvOjkup7hxuK75vI+SkEokPrORgz egoOjf5uAl5OxevTRbd8nrt3uJYck+vvEhOWiSmMmLD9qAd/g1BRo+bnGxHt96W99ZAs lXelWrYaYGVY5BW34LNOTQ2eRgaL5j8e7bPPPSr6l6wwCWGRKTY8/dcLj2gG4NQa0lzT i2PA== X-Gm-Message-State: AN3rC/7T3E9WCF/JMdXzrd/OBnOHJy76w4uNZqeyty2QnKnAiW3pgVgP Y/Q/kugtdnB7A2HW X-Received: by 10.28.69.72 with SMTP id s69mr11058923wma.85.1491835847221; Mon, 10 Apr 2017 07:50:47 -0700 (PDT) Received: from [192.168.0.101] ([37.189.166.198]) by smtp.gmail.com with ESMTPSA id g23sm10599104wme.8.2017.04.10.07.50.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Apr 2017 07:50:46 -0700 (PDT) Subject: [pushed] GC gdb/thread.c:current_thread_cleanup_chain (Re: [PATCH 2/2] Don't delete thread_info if refcount isn't zero) To: Yao Qi 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> <86a87sk1wz.fsf@gmail.com> <228668fb-05be-3f9b-9290-c12059a25cab@redhat.com> <861st0l6st.fsf@gmail.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: <0a7fb2a3-4aa3-bd96-7306-4e4ac509fa89@redhat.com> Date: Mon, 10 Apr 2017 14:50:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <861st0l6st.fsf@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-04/txt/msg00243.txt.bz2 On 04/10/2017 02:40 PM, Yao Qi wrote: > Pedro Alves writes: > >> I'm not sure what you mean by "wrong". I'm saying that the old comment >> still makes sense. That comment is talking about the >> "find_inferior_ptid (old->thread->ptid) != NULL" line, which is a >> lookup for an _inferior_ not a thread. Both the inferior and thread_info > > I thought it is about a thread. > >> object are still around, but the process may have exited/been detached >> meanwhile, and consequently the inferior's "pid" field is now >> zero. And in that case, we don't restore back the selected thread. > > I move the comment close to "find_inferior_ptid (old->thread->ptid) != NULL" > line, to make it clearer. Patch below is pushed in. Thanks! I noticed that ... > -/* A thread_ptid_changed observer. Update all currently installed > - current_thread_cleanup cleanups that want to switch back to > - OLD_PTID to switch back to NEW_PTID instead. */ > - > -static void > -restore_current_thread_ptid_changed (ptid_t old_ptid, ptid_t new_ptid) > -{ > - struct current_thread_cleanup *it; > - > - for (it = current_thread_cleanup_chain; it != NULL; it = it->next) > - { > - if (ptid_equal (it->inferior_ptid, old_ptid)) > - it->inferior_ptid = new_ptid; > - } > -} ... this means current_thread_cleanup_chain is no longer useful. So I pushed in the patch below. >From 996812e3d43f78b17b6454d2948cd825ec98c63b Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Mon, 10 Apr 2017 15:18:49 +0100 Subject: [PATCH] GC gdb/thread.c:current_thread_cleanup_chain Commit 803bdfe43083475c7df3db38dc96f4e20d05457d ("Don't delete thread_info if refcount isn't zero") eliminated restore_current_thread_ptid_changed, so current_thread_cleanup_chain is no longer necessary either. gdb/ChangeLog: 2017-04-10 Pedro Alves * thread.c (struct current_thread_cleanup) : Delete field. (current_thread_cleanup_chain): Delete. (restore_current_thread_cleanup_dtor) (make_cleanup_restore_current_thread): Remove references to current_thread_cleanup_chain. --- gdb/ChangeLog | 8 ++++++++ gdb/thread.c | 17 ----------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3cb6cd7..5e7736e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2017-04-10 Pedro Alves + + * thread.c (struct current_thread_cleanup) : Delete field. + (current_thread_cleanup_chain): Delete. + (restore_current_thread_cleanup_dtor) + (make_cleanup_restore_current_thread): Remove references to + current_thread_cleanup_chain. + 2017-04-10 Alan Hayward * msp430-tdep.c (msp430_pseudo_register_read): Never return diff --git a/gdb/thread.c b/gdb/thread.c index 2d936cd..3aca307 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1549,11 +1549,6 @@ restore_selected_frame (struct frame_id a_frame_id, int frame_level) struct current_thread_cleanup { - /* Next in list of currently installed 'struct - current_thread_cleanup' cleanups. See - 'current_thread_cleanup_chain' below. */ - struct current_thread_cleanup *next; - thread_info *thread; struct frame_id selected_frame_id; int selected_frame_level; @@ -1562,13 +1557,6 @@ struct current_thread_cleanup int was_removable; }; -/* A chain of currently installed 'struct current_thread_cleanup' - cleanups. Restoring the previously selected thread looks up the - old thread in the thread list by ptid. If the thread changes ptid, - we need to update the cleanup's thread structure so the look up - succeeds. */ -static struct current_thread_cleanup *current_thread_cleanup_chain; - static void do_restore_current_thread_cleanup (void *arg) { @@ -1609,8 +1597,6 @@ restore_current_thread_cleanup_dtor (void *arg) struct thread_info *tp; struct inferior *inf; - current_thread_cleanup_chain = current_thread_cleanup_chain->next; - if (old->thread != NULL) old->thread->decref (); @@ -1642,9 +1628,6 @@ make_cleanup_restore_current_thread (void) old->inf_id = current_inferior ()->num; old->was_removable = current_inferior ()->removable; - old->next = current_thread_cleanup_chain; - current_thread_cleanup_chain = old; - if (!ptid_equal (inferior_ptid, null_ptid)) { struct frame_info *frame; -- 2.5.5