From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130183 invoked by alias); 15 Sep 2017 04:34:17 -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 130158 invoked by uid 89); 15 Sep 2017 04:34:16 -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=thoroughly, debt 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 04:34:15 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4661BBDEA for ; Fri, 15 Sep 2017 04:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4661BBDEA 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 psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 106C969400; Fri, 15 Sep 2017 04:34:12 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Sergio Durigan Junior Subject: [PATCH] Use "switch_to_thread" more thoroughly on gdbserver Date: Fri, 15 Sep 2017 04:34:00 -0000 Message-Id: <20170915043357.26094-1-sergiodj@redhat.com> X-IsSubscribed: yes X-SW-Source: 2017-09/txt/msg00397.txt.bz2 This is a technical debt that I left when I ported "switch_to_thread" to gdbserver. It's a simple patch that converts occurences of: current_thread = find_thread_ptid (ptid); to: switch_to_thread (ptid); It helps to leave things more uniform across the code. Regtested on BuildBot. gdb/gdbserver/ChangeLog: yyyy-mm-dd Sergio Durigan Junior * gdbthread.h: Include "common-gdbthread.h". * remote-utils.c: Include "gdbthread.h". (prepare_resume_reply): Use "switch_to_thread". * target.c (set_desired_thread): Likewise. (done_accessing_memory): Likewise. --- gdb/gdbserver/gdbthread.h | 1 + gdb/gdbserver/remote-utils.c | 3 ++- gdb/gdbserver/target.c | 9 +++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h index 04cc47ba71..a864f95884 100644 --- a/gdb/gdbserver/gdbthread.h +++ b/gdb/gdbserver/gdbthread.h @@ -19,6 +19,7 @@ #ifndef GDB_THREAD_H #define GDB_THREAD_H +#include "common-gdbthread.h" #include "inferiors.h" struct btrace_target_info; diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 25b7e41a91..761604683c 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -23,6 +23,7 @@ #include "tdesc.h" #include "dll.h" #include "rsp-low.h" +#include "gdbthread.h" #include #if HAVE_SYS_IOCTL_H #include @@ -1188,7 +1189,7 @@ prepare_resume_reply (char *buf, ptid_t ptid, saved_thread = current_thread; - current_thread = find_thread_ptid (ptid); + switch_to_thread (ptid); regp = current_target_desc ()->expedite_regs; 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); } @@ -143,7 +140,7 @@ done_accessing_memory (void) /* Restore the previous selected thread. */ general_thread = prev_general_thread; - current_thread = find_thread_ptid (general_thread); + switch_to_thread (general_thread); } int -- 2.13.3