Module Name: src Committed By: kamil Date: Tue Oct 1 18:44:22 UTC 2019
Modified Files: src/sys/kern: sys_ptrace_common.c Log Message: 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.59 -r1.60 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.59 src/sys/kern/sys_ptrace_common.c:1.60 --- src/sys/kern/sys_ptrace_common.c:1.59 Mon Sep 30 21:13:33 2019 +++ src/sys/kern/sys_ptrace_common.c Tue Oct 1 18:44:22 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_ptrace_common.c,v 1.59 2019/09/30 21:13:33 kamil Exp $ */ +/* $NetBSD: sys_ptrace_common.c,v 1.60 2019/10/01 18:44:22 kamil 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.59 2019/09/30 21:13:33 kamil Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_ptrace_common.c,v 1.60 2019/10/01 18:44:22 kamil 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,