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 723F33945055 for ; Tue, 14 Apr 2020 17:54:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 723F33945055 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-510-OwdV4OI5OA-m7Sa4CJR-aw-1; Tue, 14 Apr 2020 13:54:48 -0400 X-MC-Unique: OwdV4OI5OA-m7Sa4CJR-aw-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 116B9DB60 for ; Tue, 14 Apr 2020 17:54:48 +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 A2C7C9F9B4 for ; Tue, 14 Apr 2020 17:54:47 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 16/28] Don't write to inferior_ptid in darwin-nat.c Date: Tue, 14 Apr 2020 18:54:22 +0100 Message-Id: <20200414175434.8047-17-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.8 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:54 -0000 Untested. gdb/ChangeLog: yyyy-mm-dd Pedro Alves =09* darwin-nat.c (darwin_nat_target::decode_message): Don't write to =09inferior_ptid. =09(darwin_nat_target::stop_inferior, darwin_nat_target::kill): Avoid =09inferior_ptid. =09(darwin_attach_pid): Use switch_to_no_thread instead of writing to =09inferior_ptid directly. =09(darwin_nat_target::init_thread_list): Switch to thread, instead =09of writing to inferior_ptid. =09(darwin_nat_target::attach): Don't write to inferior_ptid. =09(darwin_nat_target::get_ada_task_ptid): Avoid inferior_ptid. --- gdb/darwin-nat.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 3bd8d8ce00..aacd40ba6f 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -1141,8 +1141,7 @@ darwin_nat_target::decode_message (mach_msg_header_t = *hdr, =09 /* Looks necessary on Leopard and harmless... */ =09 wait4 (inf->pid, &wstatus, 0, NULL); =20 -=09 inferior_ptid =3D ptid_t (inf->pid, 0, 0); -=09 return inferior_ptid; +=09 return ptid_t (inf->pid); =09 } =09 else =09 { @@ -1432,7 +1431,7 @@ darwin_nat_target::stop_inferior (inferior *inf) /* Wait until the process is really stopped. */ while (1) { - ptid =3D wait_1 (inferior_ptid, &wstatus); + ptid =3D wait_1 (pid_t (inf->pid), &wstatus); if (wstatus.kind =3D=3D TARGET_WAITKIND_STOPPED =09 && wstatus.value.sig =3D=3D GDB_SIGNAL_STOP) =09break; @@ -1557,13 +1556,13 @@ darwin_nat_target::kill () =20 darwin_resume_inferior (inf); =20 - ptid =3D wait_1 (inferior_ptid, &wstatus); + ptid =3D wait_1 (pid_t (inf->pid), &wstatus); } else if (errno !=3D ESRCH) warning (_("Failed to kill inferior: kill (%d, 9) returned [%s]"), =09 inf->pid, safe_strerror (errno)); =20 - target_mourn_inferior (inferior_ptid); + target_mourn_inferior (pid_t (inf->pid)); } =20 static void @@ -1683,7 +1682,7 @@ darwin_attach_pid (struct inferior *inf) catch (const gdb_exception &ex) { exit_inferior (inf); - inferior_ptid =3D null_ptid; + switch_to_no_thread (); =20 throw; } @@ -1722,7 +1721,7 @@ darwin_nat_target::init_thread_list (inferior *inf) struct thread_info *first_thread =3D thread_info_from_private_thread_info (first_pti); =20 - inferior_ptid =3D first_thread->ptid; + switch_to_thread (first_thread); } =20 /* The child must synchronize with gdb: gdb must set the exception port @@ -2057,7 +2056,6 @@ darwin_nat_target::attach (const char *args, int from= _tty) error (_("Can't attach to process %d: %s (%d)"), pid, safe_strerror (errno), errno); =20 - inferior_ptid =3D ptid_t (pid); inf =3D current_inferior (); inferior_appeared (inf, pid); inf->attach_flag =3D 1; @@ -2469,7 +2467,7 @@ darwin_nat_target::get_ada_task_ptid (long lwp, long = thread) names_count * sizeof (mach_port_t)); =20 if (res) - return ptid_t (inferior_ptid.pid (), 0, res); + return ptid_t (current_inferior ()->pid, 0, res); else return null_ptid; } --=20 2.14.5