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 [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 16D24385DC39 for ; Tue, 14 Apr 2020 17:54:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 16D24385DC39 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-373-PiMZCzJyPBy0nFqV__tZ6A-1; Tue, 14 Apr 2020 13:54:40 -0400 X-MC-Unique: PiMZCzJyPBy0nFqV__tZ6A-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 7C5FD8010FB for ; Tue, 14 Apr 2020 17:54:39 +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 1A20D5C1A2 for ; Tue, 14 Apr 2020 17:54:38 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 05/28] Don't write to inferior_ptid in inf-ptrace.c Date: Tue, 14 Apr 2020 18:54:11 +0100 Message-Id: <20200414175434.8047-6-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=-27.7 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:43 -0000 gdb/ChangeLog: yyyy-mm-dd Pedro Alves =09* inf-ptrace.c (inf_ptrace_target::create_inferior): Switch to the =09added thread. =09(inf_ptrace_target::attach): Don't write to inferior_ptid. Switch =09to the added thread. =09(inf_ptrace_target::detach_success): Use switch_to_no_thread =09instead of writing to inferior_ptid. --- gdb/inf-ptrace.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index 1fa7aa3f73..8005187975 100644 --- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -126,9 +126,6 @@ inf_ptrace_target::create_inferior (const char *exec_fi= le, =09=09=09=09 const std::string &allargs, =09=09=09=09 char **env, int from_tty) { - pid_t pid; - ptid_t ptid; - /* Do not change either targets above or the same target if already pres= ent. The reason is the target stack is shared across multiple inferiors. = */ int ops_already_pushed =3D target_is_pushed (this); @@ -141,14 +138,15 @@ inf_ptrace_target::create_inferior (const char *exec_= file, unpusher.reset (this); } =20 - pid =3D fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL, -=09=09 NULL, NULL, NULL); + pid_t pid =3D fork_inferior (exec_file, allargs, env, inf_ptrace_me, NUL= L, +=09=09=09 NULL, NULL, NULL); =20 - ptid =3D ptid_t (pid); + ptid_t ptid (pid); /* 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); + thread_info *thr =3D add_thread_silent (this, ptid); + switch_to_thread (thr); =20 unpusher.release (); =20 @@ -243,11 +241,12 @@ inf_ptrace_target::attach (const char *args, int from= _tty) inf =3D current_inferior (); inferior_appeared (inf, pid); inf->attach_flag =3D 1; - inferior_ptid =3D ptid_t (pid); =20 /* Always add a main thread. If some target extends the ptrace target, it should decorate the ptid later with more info. */ - thread_info *thr =3D add_thread_silent (this, inferior_ptid); + thread_info *thr =3D add_thread_silent (this, ptid_t (pid)); + switch_to_thread (thr); + /* Don't consider the thread stopped until we've processed its initial SIGSTOP stop. */ set_executing (this, thr->ptid, true); @@ -302,7 +301,7 @@ inf_ptrace_target::detach (inferior *inf, int from_tty) void inf_ptrace_target::detach_success (inferior *inf) { - inferior_ptid =3D null_ptid; + switch_to_no_thread (); detach_inferior (inf); =20 maybe_unpush_target (); --=20 2.14.5