From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 766093887038 for ; Tue, 14 Apr 2020 17:54:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 766093887038 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-51-CWoKUOXwMreXMiHl58ecpg-1; Tue, 14 Apr 2020 13:54:45 -0400 X-MC-Unique: CWoKUOXwMreXMiHl58ecpg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3D9B3107ACCC for ; Tue, 14 Apr 2020 17:54:44 +0000 (UTC) Received: from cascais.Home (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD0AA5C1A2 for ; Tue, 14 Apr 2020 17:54:43 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 11/28] Don't write to inferior_ptid in remote.c Date: Tue, 14 Apr 2020 18:54:17 +0100 Message-Id: <20200414175434.8047-12-palves@redhat.com> In-Reply-To: <20200414175434.8047-1-palves@redhat.com> References: <20200414175434.8047-1-palves@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-29.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Apr 2020 17:54:49 -0000 gdb/ChangeLog: yyyy-mm-dd Pedro Alves =09* remote.c (remote_target::remote_notice_new_inferior): Use =09switch_to_thread instead of writing to inferior_ptid directly. =09(remote_target::add_current_inferior_and_thread): Use =09switch_to_no_thread instead of writing to inferior_ptid directly. =09(extended_remote_target::attach): Use switch_to_inferior_no_thread =09and switch_to_thread instead of using set_current_inferior or =09writing to inferior_ptid directly. --- gdb/remote.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index bfbc0bc21d..8f8d34f3e5 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -2492,8 +2492,9 @@ remote_target::remote_notice_new_inferior (ptid_t cur= rthread, int executing) =09 thread_change_ptid (this, inferior_ptid, currthread); =09 else =09 { -=09 remote_add_thread (currthread, running, executing); -=09 inferior_ptid =3D currthread; +=09 thread_info *thr +=09=09=3D remote_add_thread (currthread, running, executing); +=09 switch_to_thread (thr); =09 } =09 return; =09} @@ -4328,9 +4329,10 @@ remote_target::add_current_inferior_and_thread (char= *wait_status) struct remote_state *rs =3D get_remote_state (); bool fake_pid_p =3D false; =20 - inferior_ptid =3D null_ptid; + switch_to_no_thread (); =20 - /* Now, if we have thread information, update inferior_ptid. */ + /* Now, if we have thread information, update the current thread's + ptid. */ ptid_t curr_ptid =3D get_current_thread (wait_status); =20 if (curr_ptid !=3D null_ptid) @@ -5742,7 +5744,7 @@ remote_target::remote_detach_1 (inferior *inf, int fr= om_tty) } else { - inferior_ptid =3D null_ptid; + switch_to_no_thread (); detach_inferior (current_inferior ()); } } @@ -5888,33 +5890,33 @@ extended_remote_target::attach (const char *args, i= nt from_tty) =09 target_pid_to_str (ptid_t (pid)).c_str ()); } =20 - set_current_inferior (remote_add_inferior (false, pid, 1, 0)); + switch_to_inferior_no_thread (remote_add_inferior (false, pid, 1, 0)); =20 inferior_ptid =3D ptid_t (pid); =20 if (target_is_non_stop_p ()) { - struct thread_info *thread; - /* Get list of threads. */ update_thread_list (); =20 - thread =3D first_thread_of_inferior (current_inferior ()); - if (thread) -=09inferior_ptid =3D thread->ptid; - else -=09inferior_ptid =3D ptid_t (pid); + thread_info *thread =3D first_thread_of_inferior (current_inferior (= )); + if (thread !=3D nullptr) +=09switch_to_thread (thread); =20 /* Invalidate our notion of the remote current thread. */ record_currthread (rs, minus_one_ptid); } else { - /* Now, if we have thread information, update inferior_ptid. */ - inferior_ptid =3D remote_current_thread (inferior_ptid); + /* Now, if we have thread information, update the main thread's +=09 ptid. */ + ptid_t curr_ptid =3D remote_current_thread (ptid_t (pid)); =20 /* Add the main thread to the thread list. */ - thread_info *thr =3D add_thread_silent (this, inferior_ptid); + thread_info *thr =3D add_thread_silent (this, curr_ptid); + + switch_to_thread (thr); + /* Don't consider the thread stopped until we've processed the =09 saved stop reply. */ set_executing (this, thr->ptid, true); --=20 2.14.5