Module Name: src
Committed By: martin
Date: Tue Oct 15 18:38:40 UTC 2019
Modified Files:
src/sys/kern [netbsd-9]: sys_ptrace_common.c
Log Message:
Pull up following revision(s) (requested by kamil in ticket #313):
sys/kern/sys_ptrace_common.c: revision 1.60
Restore the old behavior in PT_GET_PROCESS_STATE
For !child and !lwp events return zeroed struct ptrace_state.
There is code that depends on it (GDB).
Fixes PR toolchain/54590 by martin@
To generate a diff of this commit:
cvs rdiff -u -r1.58.2.2 -r1.58.2.3 src/sys/kern/sys_ptrace_common.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/sys_ptrace_common.c
diff -u src/sys/kern/sys_ptrace_common.c:1.58.2.2 src/sys/kern/sys_ptrace_common.c:1.58.2.3
--- src/sys/kern/sys_ptrace_common.c:1.58.2.2 Tue Oct 15 18:32:13 2019
+++ src/sys/kern/sys_ptrace_common.c Tue Oct 15 18:38:39 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sys_ptrace_common.c,v 1.58.2.2 2019/10/15 18:32:13 martin Exp $ */
+/* $NetBSD: sys_ptrace_common.c,v 1.58.2.3 2019/10/15 18:38:39 martin Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -118,7 +118,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.58.2.2 2019/10/15 18:32:13 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.58.2.3 2019/10/15 18:38:39 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ptrace.h"
@@ -688,6 +688,7 @@ ptrace_set_event_mask(struct proc *t, vo
static int
ptrace_get_process_state(struct proc *t, void *addr, size_t data)
{
+ struct _ksiginfo *si;
struct ptrace_state ps;
if (data != sizeof(ps)) {
@@ -698,20 +699,20 @@ ptrace_get_process_state(struct proc *t,
if (t->p_sigctx.ps_info._signo != SIGTRAP ||
(t->p_sigctx.ps_info._code != TRAP_CHLD &&
t->p_sigctx.ps_info._code != TRAP_LWP)) {
- return EINVAL;
- }
-
- ps.pe_report_event =
- t->p_sigctx.ps_info._reason._ptrace_state._pe_report_event;
+ memset(&ps, 0, sizeof(ps));
+ } else {
+ si = &t->p_sigctx.ps_info;
+ ps.pe_report_event = si->_reason._ptrace_state._pe_report_event;
- CTASSERT(sizeof(ps.pe_other_pid) ==
- sizeof(t->p_sigctx.ps_info._reason._ptrace_state._option._pe_other_pid));
- CTASSERT(sizeof(ps.pe_lwp) ==
- sizeof(t->p_sigctx.ps_info._reason._ptrace_state._option._pe_other_pid));
- CTASSERT(sizeof(ps.pe_other_pid) == sizeof(ps.pe_lwp));
+ CTASSERT(sizeof(ps.pe_other_pid) ==
+ sizeof(si->_reason._ptrace_state._option._pe_other_pid));
+ CTASSERT(sizeof(ps.pe_lwp) ==
+ sizeof(si->_reason._ptrace_state._option._pe_other_pid));
+ CTASSERT(sizeof(ps.pe_other_pid) == sizeof(ps.pe_lwp));
- ps.pe_other_pid =
- t->p_sigctx.ps_info._reason._ptrace_state._option._pe_other_pid;
+ ps.pe_other_pid =
+ si->_reason._ptrace_state._option._pe_other_pid;
+ }
DPRINTF(("%s: lwp=%d event=%#x pid=%d lwp=%d\n", __func__,
t->p_sigctx.ps_lwp, ps.pe_report_event,