Remove p_oppid from struct proc

This field is not needed as it duplicated p_opptr that is alread safe to
use, unless proven otherwise.

eventswitch() already contained a check for != initproc (pid1).

Ride ABI bump for 9.99.16.
This commit is contained in:
kamil 2019-10-12 10:55:23 +00:00
parent bc9a7e7a72
commit b3bca7a74f
4 changed files with 13 additions and 15 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.482 2019/09/30 21:13:33 kamil Exp $ */
/* $NetBSD: kern_exec.c,v 1.483 2019/10/12 10:55:23 kamil Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.482 2019/09/30 21:13:33 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.483 2019/10/12 10:55:23 kamil Exp $");
#include "opt_exec.h"
#include "opt_execfmt.h"
@ -2249,7 +2249,7 @@ spawn_return(void *arg)
}
mutex_enter(p->p_lock);
eventswitch(TRAP_CHLD, PTRACE_POSIX_SPAWN, p->p_oppid);
eventswitch(TRAP_CHLD, PTRACE_POSIX_SPAWN, p->p_opptr->p_pid);
}
cpu_return:
@ -2630,7 +2630,6 @@ do_posix_spawn(struct lwp *l1, pid_t *pid_res, bool *child_ok, const char *path,
if ((p1->p_slflag & (PSL_TRACEPOSIX_SPAWN|PSL_TRACED)) ==
(PSL_TRACEPOSIX_SPAWN|PSL_TRACED)) {
proc_changeparent(p2, p1->p_pptr);
p2->p_oppid = p1->p_pid;
}
LIST_INSERT_AFTER(p1, p2, p_pglist);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.214 2019/09/30 21:13:33 kamil Exp $ */
/* $NetBSD: kern_fork.c,v 1.215 2019/10/12 10:55:23 kamil Exp $ */
/*-
* Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.214 2019/09/30 21:13:33 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.215 2019/10/12 10:55:23 kamil Exp $");
#include "opt_ktrace.h"
#include "opt_dtrace.h"
@ -510,10 +510,8 @@ fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize,
/*
* Trace fork(2) and vfork(2)-like events on demand in a debugger.
*/
if (tracefork(p1, flags) || tracevfork(p1, flags)) {
if (tracefork(p1, flags) || tracevfork(p1, flags))
proc_changeparent(p2, p1->p_pptr);
p2->p_oppid = p1->p_pid;
}
LIST_INSERT_AFTER(p1, p2, p_pglist);
LIST_INSERT_HEAD(&allproc, p2, p_list);
@ -640,7 +638,7 @@ child_return(void *arg)
mutex_enter(p->p_lock);
eventswitch(TRAP_CHLD,
ISSET(p->p_lflag, PL_PPWAIT) ? PTRACE_VFORK : PTRACE_FORK,
p->p_oppid);
p->p_opptr->p_pid);
}
my_tracer_is_gone:

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_proc.c,v 1.235 2019/09/30 21:13:33 kamil Exp $ */
/* $NetBSD: kern_proc.c,v 1.236 2019/10/12 10:55:23 kamil Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.235 2019/09/30 21:13:33 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.236 2019/10/12 10:55:23 kamil Exp $");
#ifdef _KERNEL_OPT
#include "opt_kstack.h"
@ -2263,7 +2263,6 @@ fill_proc(const struct proc *psrc, struct proc *p, bool allowaddr)
COND_SET_VALUE(p->p_sigpend, psrc->p_sigpend, allowaddr);
COND_SET_VALUE(p->p_lwpctl, psrc->p_lwpctl, allowaddr);
p->p_ppid = psrc->p_ppid;
p->p_oppid = psrc->p_oppid;
COND_SET_VALUE(p->p_path, psrc->p_path, allowaddr);
COND_SET_VALUE(p->p_sigctx, psrc->p_sigctx, allowaddr);
p->p_nice = psrc->p_nice;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.367 2019/10/08 18:02:46 kamil Exp $ */
/* $NetBSD: kern_sig.c,v 1.368 2019/10/12 10:55:23 kamil Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.367 2019/10/08 18:02:46 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.368 2019/10/12 10:55:23 kamil Exp $");
#include "opt_ptrace.h"
#include "opt_dtrace.h"
@ -1599,6 +1599,8 @@ eventswitch(int code, int pe_report_event, int entity)
KASSERT(p->p_nrlwps > 0);
KASSERT((code == TRAP_CHLD) || (code == TRAP_LWP) ||
(code == TRAP_EXEC));
KASSERT((code != TRAP_CHLD) || (entity > 1)); /* prevent pid1 */
KASSERT((code != TRAP_LWP) || (entity > 0));
repeat:
/*