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 5AAA33887025 for ; Tue, 14 Apr 2020 17:54:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5AAA33887025 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-404-lu45Zs76PJmeDmrTnNGmWg-1; Tue, 14 Apr 2020 13:54:42 -0400 X-MC-Unique: lu45Zs76PJmeDmrTnNGmWg-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 E98EB800D5B for ; Tue, 14 Apr 2020 17:54:41 +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 82E149F99D for ; Tue, 14 Apr 2020 17:54:41 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 08/28] Don't write to inferior_ptid in procfs.c Date: Tue, 14 Apr 2020 18:54:14 +0100 Message-Id: <20200414175434.8047-9-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.1 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:46 -0000 The inferior_ptid write in procfs_do_thread_registers should be unnecessary because the target fetch_registers method should (and does) extract the ptid from the regcache. Not tested. gdb/ChangeLog: yyyy-mm-dd Pedro Alves =09* procfs.c (procfs_target::attach): Don't write to inferior_ptid. =09(procfs_target::detach): Use switch_to_no_thread =09instead of writing to inferior_ptid directly. =09(do_attach): Change return type to void. Switch to the added =09thread. =09(procfs_target::create_inferior): Switch to the added thread. =09(procfs_do_thread_registers): Don't write to inferior_ptid. --- gdb/procfs.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/gdb/procfs.c b/gdb/procfs.c index 09a036f90b..dbb042cedf 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -1805,7 +1805,7 @@ proc_iterate_over_threads (procinfo *pi, /* Here are all of the gdb target vector functions and their friends. */ =20 -static ptid_t do_attach (ptid_t ptid); +static void do_attach (ptid_t ptid); static void do_detach (); static void proc_trace_syscalls_1 (procinfo *pi, int syscallnum, =09=09=09=09 int entry_or_exit, int mode, int from_tty); @@ -1894,7 +1894,7 @@ procfs_target::attach (const char *args, int from_tty= ) =20 fflush (stdout); } - inferior_ptid =3D do_attach (ptid_t (pid)); + do_attach (ptid_t (pid)); if (!target_is_pushed (this)) push_target (this); } @@ -1918,12 +1918,12 @@ procfs_target::detach (inferior *inf, int from_tty) =20 do_detach (); =20 - inferior_ptid =3D null_ptid; + switch_to_no_thread (); detach_inferior (inf); maybe_unpush_target (); } =20 -static ptid_t +static void do_attach (ptid_t ptid) { procinfo *pi; @@ -1991,9 +1991,8 @@ do_attach (ptid_t ptid) =20 /* Add it to gdb's thread list. */ ptid =3D ptid_t (pi->pid, lwpid, 0); - add_thread (&the_procfs_target, ptid); - - return ptid; + thread_info *thr =3D add_thread (&the_procfs_target, ptid); + switch_to_thread (thr); } =20 static void @@ -3092,7 +3091,8 @@ procfs_target::create_inferior (const char *exec_file= , /* We have something that executes now. We'll be running through the shell at this point (if startup-with-shell is true), but the pid shouldn't change. */ - add_thread_silent (this, ptid_t (pid)); + thread_info *thr =3D add_thread_silent (this, ptid_t (pid)); + switch_to_thread (thr); =20 procfs_init_inferior (pid); } @@ -3755,8 +3755,6 @@ procfs_do_thread_registers (bfd *obfd, ptid_t ptid, once it is implemented in this platform: gdbarch_iterate_over_regset_sections(). */ =20 - scoped_restore save_inferior_ptid =3D make_scoped_restore (&inferior_pti= d); - inferior_ptid =3D ptid; target_fetch_registers (regcache, -1); =20 fill_gregset (regcache, &gregs, -1); --=20 2.14.5