From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by sourceware.org (Postfix) with ESMTPS id C716B3944439 for ; Wed, 18 Mar 2020 21:50:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C716B3944439 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gmx.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=n54@gmx.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1584568218; bh=XjV60YqHXc9W/Zx/3YKKWrTdJprCy6G6pqPUhtuTEcg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=Wk6GHtpxDsUmCKUCyHLenO57sMwcCLxeMEFv8zmwj32Bql5PtlA5Su0SvfWFq6QUw mVBQiE+pHictYSDO/gSDa965CA56DF4FNAvNh5eVWuvJDYyc83Zrl5nArpMx1VaW/x k01ntFqnyt1kWu70RFgV4H1IaledAOKdwqrSuRoI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([89.79.191.25]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MQMyf-1it0rA3CPh-00MHIl; Wed, 18 Mar 2020 22:50:17 +0100 From: Kamil Rytarowski To: gdb-patches@sourceware.org Cc: tom@tromey.com, Kamil Rytarowski Subject: [PATCH] Disable get_ptrace_pid for NetBSD Date: Wed, 18 Mar 2020 22:49:34 +0100 Message-Id: <20200318214934.24306-1-n54@gmx.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Ol/VHFzNCwjHker7cKg1KXou2Y46scsfEUtKIdsKn2d+kPxEN1Q icYqJQCTb0AAFYiiBJDeUfCI7/r3kvARN/uBD/fyGqtG3ElHLb16QoUqZSw/JOFrNsRZPuI HP7H7085LPErhaRMCG+KqAA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BVx /KIyJxkz+r6261+SPnbSRvUtG0QWv/xF6hEMSt7gXzkzxRxo2br4juAK+VTgvjFOcnSojGT+d nVM46GpEpRqf7xb/4eAIjF/PSHbTPAHKuf7TC7+IKjVjE40zTElbKbhbS+hpEKQyOYXDGv5LT iOpSf7jxVG9N8tEC53Yb3WK5oVtdjuPePWBK8dxkwnwejTAFo2XlYfz1euiXdln9gIojEp91Q IpaQHGWbC2T7eq4oOg0xeIf4MkYbharfBucFJ+19j6b6UlNtrNoLSATl2gg639ni1Y5vA= X-Spam-Status: No, score=-25.4 required=5.0 tests=DKIM_SIGNED, DKIM_VALID, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS 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: Wed, 18 Mar 2020 21:50:33 -0000 Unlike most other Operating Systems, NetBSD tracks both pid and lwp. The process id on NetBSD is stored always in the pid field of ptid. gdb/ChangeLog: * inf-ptrace.h: Disable get_ptrace_pid on NetBSD. * inf-ptrace.c: Likewise. * (gdb_ptrace): Add. * (inf_ptrace_target::resume): Update. * (inf_ptrace_target::xfer_partial): Likewise. =2D-- gdb/ChangeLog | 8 ++++++++ gdb/inf-ptrace.c | 32 +++++++++++++++++++++++--------- gdb/inf-ptrace.h | 2 ++ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 84964dc00ac..406414cee76 100644 =2D-- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2020-03-18 Kamil Rytarowski + + * inf-ptrace.h: Disable get_ptrace_pid on NetBSD. + * inf-ptrace.c: Likewise. + * (gdb_ptrace): Add. + * (inf_ptrace_target::resume): Update. + * (inf_ptrace_target::xfer_partial): Likewise. + 2020-03-17 Kamil Rytarowski * regformats/regdef.h: Put reg in gdb namespace. diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c index db17a76d946..304a749f3f3 100644 =2D-- a/gdb/inf-ptrace.c +++ b/gdb/inf-ptrace.c @@ -37,6 +37,18 @@ =0C +static int +gdb_ptrace (PTRACE_TYPE_ARG1 request, ptid_t ptid, PTRACE_TYPE_ARG3 addr, + PTRACE_TYPE_ARG4 data) +{ +#ifdef __NetBSD__ + return ptrace (request, ptid.pid (), addr, data); +#else + pid_t pid =3D get_ptrace_pid (ptid); + return ptrace (request, pid, addr, data); +#endif +} + /* A unique_ptr helper to unpush a target. */ struct target_unpusher @@ -313,8 +325,12 @@ inf_ptrace_target::kill () target_mourn_inferior (inferior_ptid); } +#ifndef __NetBSD__ /* Return which PID to pass to ptrace in order to observe/control the - tracee identified by PTID. */ + tracee identified by PTID. + + Unlike most other Operating Systems, NetBSD tracks both pid and lwp + and avoids this function. */ pid_t get_ptrace_pid (ptid_t ptid) @@ -328,6 +344,7 @@ get_ptrace_pid (ptid_t ptid) pid =3D ptid.pid (); return pid; } +#endif /* Resume execution of thread PTID, or all threads if PTID is -1. If STEP is nonzero, single-step it. If SIGNAL is nonzero, give it @@ -336,15 +353,12 @@ get_ptrace_pid (ptid_t ptid) void inf_ptrace_target::resume (ptid_t ptid, int step, enum gdb_signal signal) { - pid_t pid; int request; if (minus_one_ptid =3D=3D ptid) /* Resume all threads. Traditionally ptrace() only supports single-threaded processes, so simply resume the inferior. */ - pid =3D inferior_ptid.pid (); - else - pid =3D get_ptrace_pid (ptid); + ptid =3D inferior_ptid; if (catch_syscall_enabled () > 0) request =3D PT_SYSCALL; @@ -365,7 +379,7 @@ inf_ptrace_target::resume (ptid_t ptid, int step, enum= gdb_signal signal) where it was. If GDB wanted it to start some other way, we have already written a new program counter value to the child. */ errno =3D 0; - ptrace (request, pid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (signal))= ; + gdb_ptrace (request, ptid, (PTRACE_TYPE_ARG3)1, gdb_signal_to_host (sig= nal)); if (errno !=3D 0) perror_with_name (("ptrace")); } @@ -528,7 +542,7 @@ inf_ptrace_target::xfer_partial (enum target_object ob= ject, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) { - pid_t pid =3D get_ptrace_pid (inferior_ptid); + ptid_t ptid =3D inferior_ptid; switch (object) { @@ -552,7 +566,7 @@ inf_ptrace_target::xfer_partial (enum target_object ob= ject, piod.piod_len =3D len; errno =3D 0; - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) =3D=3D 0) + if (gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) =3D=3D 0) { /* Return the actual number of bytes read or written. */ *xfered_len =3D piod.piod_len; @@ -588,7 +602,7 @@ inf_ptrace_target::xfer_partial (enum target_object ob= ject, piod.piod_len =3D len; errno =3D 0; - if (ptrace (PT_IO, pid, (caddr_t)&piod, 0) =3D=3D 0) + if (gdb_ptrace (PT_IO, ptid, (caddr_t)&piod, 0) =3D=3D 0) { /* Return the actual number of bytes read or written. */ *xfered_len =3D piod.piod_len; diff --git a/gdb/inf-ptrace.h b/gdb/inf-ptrace.h index dd0733736f2..340d41d8beb 100644 =2D-- a/gdb/inf-ptrace.h +++ b/gdb/inf-ptrace.h @@ -78,9 +78,11 @@ struct inf_ptrace_target : public inf_child_target void detach_success (inferior *inf); }; +#ifndef __NetBSD__ /* Return which PID to pass to ptrace in order to observe/control the tracee identified by PTID. */ extern pid_t get_ptrace_pid (ptid_t); +#endif #endif =2D- 2.25.0