From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 52B0F385DC0E for ; Tue, 14 Apr 2020 17:54:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 52B0F385DC0E 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-104-X8BWoEvYPSW-0tfy9dHKug-1; Tue, 14 Apr 2020 13:54:46 -0400 X-MC-Unique: X8BWoEvYPSW-0tfy9dHKug-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 BFB731083E80 for ; Tue, 14 Apr 2020 17:54:45 +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 5CA845C1A2 for ; Tue, 14 Apr 2020 17:54:45 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 13/28] Don't write to inferior_ptid in nto-procfs.c Date: Tue, 14 Apr 2020 18:54:19 +0100 Message-Id: <20200414175434.8047-14-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 A best effort patch, which fixes some bit rot and removes some inferior_ptid references -- this port clearly hasn't been built in a long while. gdb/ChangeLog: yyyy-mm-dd Pedro Alves =09* nto-procfs.c (nto_procfs_target::update_thread_list): Avoid =09inferior_ptid. =09(nto_procfs_target::attach): Avoid inferior_ptid. Switch to =09thread. =09(nto_procfs_target::detach): Avoid referencing =09inferior_ptid. Use switch_to_no_thread instead of writing to =09inferior_ptid directly. =09(nto_procfs_target::mourn_inferior): Use switch_to_no_thread =09instead of writing to inferior_ptid directly. =09(nto_procfs_target::create_inferior): Avoid inferior_ptid. Switch =09to thread. --- gdb/nto-procfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c index 58e572c094..f649b6cf58 100644 --- a/gdb/nto-procfs.c +++ b/gdb/nto-procfs.c @@ -393,7 +393,7 @@ nto_procfs_target::update_thread_list () =20 prune_threads (); =20 - pid =3D inferior_ptid.pid (); + pid =3D current_inferior ()->pid; =20 status.tid =3D 1; =20 @@ -712,7 +712,7 @@ nto_procfs_target::attach (const char *args, int from_t= ty) =09printf_unfiltered ("Attaching to %s\n", =09=09=09 target_pid_to_str (ptid_t (pid)).c_str ()); } - inferior_ptid =3D do_attach (ptid_t (pid)); + ptid_t ptid =3D do_attach (ptid_t (pid)); inf =3D current_inferior (); inferior_appeared (inf, pid); inf->attach_flag =3D 1; @@ -720,7 +720,9 @@ nto_procfs_target::attach (const char *args, int from_t= ty) if (!target_is_pushed (ops)) push_target (ops); =20 - procfs_update_thread_list (ops); + update_thread_list (); + + switch_to_thread (find_thread_ptid (this, ptid)); } =20 void @@ -1000,19 +1002,16 @@ nto_procfs_target::xfer_partial (enum target_object= object, void nto_procfs_target::detach (inferior *inf, int from_tty) { - int pid; - target_announce_detach (); =20 if (siggnal) - SignalKill (nto_node (), inferior_ptid.pid (), 0, 0, 0, 0); + SignalKill (nto_node (), inf->pid, 0, 0, 0, 0); =20 close (ctl_fd); ctl_fd =3D -1; =20 - pid =3D inferior_ptid.pid (); - inferior_ptid =3D null_ptid; - detach_inferior (pid); + switch_to_no_thread (); + detach_inferior (inf->pid); init_thread_list (); inf_child_maybe_unpush_target (ops); } @@ -1132,7 +1131,7 @@ nto_procfs_target::mourn_inferior () SignalKill (nto_node (), inferior_ptid.pid (), 0, SIGKILL, 0, 0); close (ctl_fd); } - inferior_ptid =3D null_ptid; + switch_to_no_thread (); init_thread_list (); inf_child_mourn_inferior (ops); } @@ -1303,8 +1302,9 @@ nto_procfs_target::create_inferior (const char *exec_= file, if (fds[2] !=3D STDERR_FILENO) close (fds[2]); =20 - inferior_ptid =3D do_attach (ptid_t (pid)); - procfs_update_thread_list (ops); + ptid_t ptid =3D do_attach (ptid_t (pid)); + update_thread_list (); + switch_to_thread (find_thread_ptid (this, ptid)); =20 inf =3D current_inferior (); inferior_appeared (inf, pid); --=20 2.14.5