Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Restore the old behavior in PT_GET_PROCESS_STATE
details: https://anonhg.NetBSD.org/src/rev/e07424afcd2f
branches: trunk
changeset: 845414:e07424afcd2f
user: kamil <kamil%NetBSD.org@localhost>
date: Tue Oct 01 18:44:22 2019 +0000
description:
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@
diffstat:
sys/kern/sys_ptrace_common.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diffs (59 lines):
diff -r 714405de82f1 -r e07424afcd2f sys/kern/sys_ptrace_common.c
--- a/sys/kern/sys_ptrace_common.c Tue Oct 01 18:41:58 2019 +0000
+++ b/sys/kern/sys_ptrace_common.c Tue Oct 01 18:44:22 2019 +0000
@@ -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 @@
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 @@
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,
Home |
Main Index |
Thread Index |
Old Index