From patchwork Thu May 4 14:18:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 20274 Received: (qmail 9508 invoked by alias); 4 May 2017 14:18:32 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 9474 invoked by uid 89); 4 May 2017 14:18:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, 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, 04 May 2017 14:18:30 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 096037AE99 for ; Thu, 4 May 2017 14:18:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 096037AE99 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 096037AE99 Received: from cascais.lan (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89A597D955 for ; Thu, 4 May 2017 14:18:31 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [pushed/ob] make_cleanup_restore_current_thread: Look up thread earlier Date: Thu, 4 May 2017 15:18:30 +0100 Message-Id: <1493907510-24747-1-git-send-email-palves@redhat.com> The unconditional is_stopped call already asserts that the thread exists. gdb/ChangeLog: 2017-05-04 Pedro Alves * thread.c (make_cleanup_restore_current_thread): Move find_thread_ptid call before the is_stopped call. Assert that the thread is found. Replace is_stopped call by checking the thread's state directly. Remove unnecessary NULL-thread check. --- gdb/ChangeLog | 7 +++++++ gdb/thread.c | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aeb83dd..7c48c3d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2017-05-04 Pedro Alves + * thread.c (make_cleanup_restore_current_thread): Move + find_thread_ptid call before the is_stopped call. Assert that the + thread is found. Replace is_stopped call by checking the thread's + state directly. Remove unnecessary NULL-thread check. + +2017-05-04 Pedro Alves + * corelow.c (thread_section_name): New class. (get_core_register_section, get_core_siginfo): Use it. diff --git a/gdb/thread.c b/gdb/thread.c index d08f414..fce37c5 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -1626,9 +1626,12 @@ make_cleanup_restore_current_thread (void) if (inferior_ptid != null_ptid) { + thread_info *tp = find_thread_ptid (inferior_ptid); struct frame_info *frame; - old->was_stopped = is_stopped (inferior_ptid); + gdb_assert (tp != NULL); + + old->was_stopped = tp->state == THREAD_STOPPED; if (old->was_stopped && target_has_registers && target_has_stack @@ -1647,10 +1650,7 @@ make_cleanup_restore_current_thread (void) old->selected_frame_id = get_frame_id (frame); old->selected_frame_level = frame_relative_level (frame); - struct thread_info *tp = find_thread_ptid (inferior_ptid); - - if (tp) - tp->incref (); + tp->incref (); old->thread = tp; }