Move all non-emulation-specific coredump code into the coredump module,

and remove all #ifdef COREDUMP conditional compilation.  Now, the
coredump module is completely separated from the emulation modules, and
they can all be independently loaded and unloaded.

Welcome to 9.99.18 !
This commit is contained in:
pgoyette 2019-11-20 19:37:51 +00:00
parent 764206462f
commit 1d577fe379
49 changed files with 329 additions and 310 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.4 2018/04/01 04:35:03 ryo Exp $ */ /* $NetBSD: core_machdep.c,v 1.5 2019/11/20 19:37:51 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2014 The NetBSD Foundation, Inc. * Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -31,13 +31,14 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: core_machdep.c,v 1.4 2018/04/01 04:35:03 ryo Exp $"); __KERNEL_RCSID(1, "$NetBSD: core_machdep.c,v 1.5 2019/11/20 19:37:51 pgoyette Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/cpu.h> #include <sys/cpu.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/core.h> #include <sys/core.h>
#include <sys/lwp.h> #include <sys/lwp.h>
#include <sys/compat_stub.h>
#include <aarch64/pcb.h> #include <aarch64/pcb.h>
#include <aarch64/frame.h> #include <aarch64/frame.h>
@ -79,11 +80,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.7 2019/07/12 06:44:49 skrll Exp $ */ /* $NetBSD: netbsd32_machdep.c,v 1.8 2019/11/20 19:37:51 pgoyette Exp $ */
/* /*
* Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org> * Copyright (c) 2018 Ryo Shimizu <ryo@nerv.org>
@ -27,7 +27,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7 2019/07/12 06:44:49 skrll Exp $"); __KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.8 2019/11/20 19:37:51 pgoyette Exp $");
#if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT)
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.7 2019/07/12 06:44:49 skrll E
#include <sys/ras.h> #include <sys/ras.h>
#include <sys/signalvar.h> #include <sys/signalvar.h>
#include <sys/syscallargs.h> #include <sys/syscallargs.h>
#include <sys/compat_stub.h>
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
@ -193,13 +194,15 @@ cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
&cseg, chdr->c_seghdrsize); &cseg, chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
&md_core32, sizeof(md_core32)); &md_core32, sizeof(md_core32)), ENOSYS, error);
return error;
} }
static void static void

View File

@ -1,4 +1,4 @@
# $NetBSD: files.aarch64,v 1.13 2019/01/27 02:08:36 pgoyette Exp $ # $NetBSD: files.aarch64,v 1.14 2019/11/20 19:37:51 pgoyette Exp $
defflag opt_cpuoptions.h AARCH64_ALIGNMENT_CHECK defflag opt_cpuoptions.h AARCH64_ALIGNMENT_CHECK
defflag opt_cpuoptions.h AARCH64_EL0_STACK_ALIGNMENT_CHECK defflag opt_cpuoptions.h AARCH64_EL0_STACK_ALIGNMENT_CHECK
@ -88,7 +88,7 @@ file arch/aarch64/aarch64/bus_space_notimpl.S
file arch/arm/arm/bootconfig.c file arch/arm/arm/bootconfig.c
file arch/aarch64/aarch64/aarch64_machdep.c file arch/aarch64/aarch64/aarch64_machdep.c
file arch/aarch64/aarch64/aarch64_reboot.c file arch/aarch64/aarch64/aarch64_reboot.c
file arch/aarch64/aarch64/core_machdep.c file arch/aarch64/aarch64/core_machdep.c coredump
file arch/aarch64/aarch64/copyinout.S file arch/aarch64/aarch64/copyinout.S
file arch/aarch64/aarch64/cpu_in_cksum.S (inet | inet6) & cpu_in_cksum file arch/aarch64/aarch64/cpu_in_cksum.S (inet | inet6) & cpu_in_cksum
file arch/aarch64/aarch64/cpu_machdep.c file arch/aarch64/aarch64/cpu_machdep.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.9 2014/05/16 19:18:21 matt Exp $ */ /* $NetBSD: core_machdep.c,v 1.10 2019/11/20 19:37:51 pgoyette Exp $ */
/* /*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@ -29,7 +29,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2014/05/16 19:18:21 matt Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.10 2019/11/20 19:37:51 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -39,6 +39,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2014/05/16 19:18:21 matt Exp $"
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/core.h> #include <sys/core.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -79,11 +80,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &cpustate, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
sizeof(cpustate)); &cpustate, sizeof(cpustate)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.130 2019/11/20 10:57:08 rin Exp $ */ /* $NetBSD: netbsd32_machdep.c,v 1.131 2019/11/20 19:37:51 pgoyette Exp $ */
/* /*
* Copyright (c) 2001 Wasabi Systems, Inc. * Copyright (c) 2001 Wasabi Systems, Inc.
@ -36,12 +36,11 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.130 2019/11/20 10:57:08 rin Exp $"); __KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.131 2019/11/20 19:37:51 pgoyette Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
#include "opt_compat_netbsd32.h" #include "opt_compat_netbsd32.h"
#include "opt_coredump.h"
#include "opt_execfmt.h" #include "opt_execfmt.h"
#include "opt_user_ldt.h" #include "opt_user_ldt.h"
#include "opt_mtrr.h" #include "opt_mtrr.h"
@ -283,7 +282,6 @@ netbsd32_sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
netbsd32_sendsig_siginfo(ksi, mask)); netbsd32_sendsig_siginfo(ksi, mask));
} }
#ifdef COREDUMP
/* /*
* Dump the machine specific segment at the start of a core dump. * Dump the machine specific segment at the start of a core dump.
*/ */
@ -323,15 +321,16 @@ cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }
#endif
int int
netbsd32_ptrace_translate_request(int req) netbsd32_ptrace_translate_request(int req)

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.8 2015/04/27 06:54:12 skrll Exp $ */ /* $NetBSD: core_machdep.c,v 1.9 2019/11/20 19:37:51 pgoyette Exp $ */
/* /*
* Copyright (c) 1994-1998 Mark Brinicombe. * Copyright (c) 1994-1998 Mark Brinicombe.
@ -37,7 +37,7 @@
#include <sys/param.h> #include <sys/param.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2015/04/27 06:54:12 skrll Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2019/11/20 19:37:51 pgoyette Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_execfmt.h" #include "opt_execfmt.h"
@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2015/04/27 06:54:12 skrll Exp $
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> /* for MID_* */ #include <sys/exec_aout.h> /* for MID_* */
@ -104,13 +105,15 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
&cseg, chdr->c_seghdrsize); &cseg, chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
&cpustate, sizeof(cpustate)); &cpustate, sizeof(cpustate)), ENOSYS, error);
return error;
} }
#ifdef EXEC_ELF32 #ifdef EXEC_ELF32

View File

@ -1,4 +1,4 @@
# $NetBSD: files.arm,v 1.148 2019/01/27 02:08:37 pgoyette Exp $ # $NetBSD: files.arm,v 1.149 2019/11/20 19:37:52 pgoyette Exp $
# temporary define to allow easy moving to ../arch/arm/arm32 # temporary define to allow easy moving to ../arch/arm/arm32
defflag ARM32 defflag ARM32
@ -162,7 +162,7 @@ file arch/arm/arm/bootconfig.c
file arch/arm/arm/compat_13_machdep.c compat_13 file arch/arm/arm/compat_13_machdep.c compat_13
file arch/arm/arm/compat_16_machdep.c compat_16 file arch/arm/arm/compat_16_machdep.c compat_16
file arch/arm/arm/copystr.S file arch/arm/arm/copystr.S
file arch/arm/arm/core_machdep.c file arch/arm/arm/core_machdep.c coredump
file arch/arm/arm/cpu_in_cksum.S (inet | inet6) & cpu_in_cksum file arch/arm/arm/cpu_in_cksum.S (inet | inet6) & cpu_in_cksum
file arch/arm/arm/cpufunc.c file arch/arm/arm/cpufunc.c
file arch/arm/arm/cpufunc_asm.S file arch/arm/arm/cpufunc_asm.S

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.6 2014/01/04 00:10:02 dsl Exp $ */ /* $NetBSD: core_machdep.c,v 1.7 2019/11/20 19:37:52 pgoyette Exp $ */
/* $OpenBSD: vm_machdep.c,v 1.25 2001/09/19 20:50:56 mickey Exp $ */ /* $OpenBSD: vm_machdep.c,v 1.25 2001/09/19 20:50:56 mickey Exp $ */
@ -29,7 +29,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2014/01/04 00:10:02 dsl Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.7 2019/11/20 19:37:52 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -41,6 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2014/01/04 00:10:02 dsl Exp $")
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/core.h> #include <sys/core.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -85,11 +86,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = core->c_cpusize; cseg.c_size = core->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
core->c_seghdrsize); core->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
# $NetBSD: files.ia64,v 1.8 2016/08/05 16:48:04 scole Exp $ # $NetBSD: files.ia64,v 1.9 2019/11/20 19:37:52 pgoyette Exp $
# #
# new style config file for ia64 architecture # new style config file for ia64 architecture
# #
@ -14,6 +14,7 @@ defflag opt_cputype.h IA64_CPU
define cpubus {} define cpubus {}
file arch/ia64/ia64/autoconf.c file arch/ia64/ia64/autoconf.c
file arch/ia64/ia64/core_machdep.c coredump
file arch/ia64/ia64/machdep.c file arch/ia64/ia64/machdep.c
file arch/ia64/ia64/clock.c file arch/ia64/ia64/clock.c
file arch/ia64/ia64/process_machdep.c file arch/ia64/ia64/process_machdep.c

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.6 2014/01/04 00:10:02 dsl Exp $ */ /* $NetBSD: core_machdep.c,v 1.7 2019/11/20 19:37:52 pgoyette Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2014/01/04 00:10:02 dsl Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.7 2019/11/20 19:37:52 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2014/01/04 00:10:02 dsl Exp $")
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/core.h> #include <sys/core.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -103,11 +104,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.8 2015/06/26 21:58:53 matt Exp $ */ /* $NetBSD: core_machdep.c,v 1.9 2019/11/20 19:37:52 pgoyette Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -39,7 +39,7 @@
*/ */
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2015/06/26 21:58:53 matt Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2019/11/20 19:37:52 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -50,6 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2015/06/26 21:58:53 matt Exp $"
#include <sys/core.h> #include <sys/core.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/cpu.h> #include <sys/cpu.h>
#include <sys/compat_stub.h>
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
@ -91,11 +92,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &cpustate, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
chdr->c_cpusize); &cpustate, chdr->c_cpusize), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.18 2019/03/01 11:06:55 pgoyette Exp $ */ /* $NetBSD: netbsd32_machdep.c,v 1.19 2019/11/20 19:37:52 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2009 The NetBSD Foundation, Inc. * Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -30,10 +30,9 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.18 2019/03/01 11:06:55 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.19 2019/11/20 19:37:52 pgoyette Exp $");
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
#include "opt_coredump.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -264,7 +263,6 @@ cpu_setmcontext32(struct lwp *l, const mcontext32_t *mc32, unsigned int flags)
return cpu_setmcontext(l, &mc, flags); return cpu_setmcontext(l, &mc, flags);
} }
#ifdef COREDUMP
/* /*
* Dump the machine specific segment at the start of a core dump. * Dump the machine specific segment at the start of a core dump.
*/ */
@ -298,15 +296,16 @@ cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &cpustate, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
chdr->c_cpusize); &cpustate, chdr->c_cpusize), ENOSYS, error);
return error;
} }
#endif
struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook; struct netbsd32_sendsig_hook_t netbsd32_sendsig_hook;

View File

@ -1,4 +1,4 @@
/* $NetBSD: vm_machdep.c,v 1.159 2017/07/14 17:54:00 christos Exp $ */ /* $NetBSD: vm_machdep.c,v 1.160 2019/11/20 19:37:52 pgoyette Exp $ */
/* /*
* Copyright (c) 1988 University of Utah. * Copyright (c) 1988 University of Utah.
@ -39,10 +39,9 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.159 2017/07/14 17:54:00 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.160 2019/11/20 19:37:52 pgoyette Exp $");
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_coredump.h"
#include "opt_cputype.h" #include "opt_cputype.h"
#define __PMAP_PRIVATE #define __PMAP_PRIVATE

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.9 2014/01/01 18:57:16 dsl Exp $ */ /* $NetBSD: core_machdep.c,v 1.10 2019/11/20 19:37:52 pgoyette Exp $ */
/* /*
* Copyright (C) 1995, 1996 Wolfgang Solfrank. * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2014/01/01 18:57:16 dsl Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.10 2019/11/20 19:37:52 pgoyette Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_altivec.h" #include "opt_altivec.h"
@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.9 2014/01/01 18:57:16 dsl Exp $")
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -95,11 +96,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
# $NetBSD: files.riscv,v 1.3 2019/06/16 07:42:52 maxv Exp $ # $NetBSD: files.riscv,v 1.4 2019/11/20 19:37:52 pgoyette Exp $
# #
maxpartitions 16 maxpartitions 16
@ -21,7 +21,7 @@ file arch/riscv/riscv/syscall.c # syscall handler
file arch/riscv/riscv/trap.c # trap handlers file arch/riscv/riscv/trap.c # trap handlers
file arch/riscv/riscv/core_machdep.c coredump file arch/riscv/riscv/core_machdep.c coredump
file arch/riscv/riscv/clock_machdep.c coredump file arch/riscv/riscv/clock_machdep.c
file arch/riscv/riscv/db_machdep.c ddb | kgdb file arch/riscv/riscv/db_machdep.c ddb | kgdb
file arch/riscv/riscv/exec_machdep.c file arch/riscv/riscv/exec_machdep.c
file arch/riscv/riscv/kgdb_machdep.c kgdb file arch/riscv/riscv/kgdb_machdep.c kgdb

View File

@ -30,7 +30,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifndef CORENAME #ifndef CORENAME
__RCSID("$NetBSD: core_machdep.c,v 1.2 2019/06/01 12:42:28 maxv Exp $"); __RCSID("$NetBSD: core_machdep.c,v 1.3 2019/11/20 19:37:52 pgoyette Exp $");
#endif #endif
#include <sys/param.h> #include <sys/param.h>
@ -39,6 +39,7 @@ __RCSID("$NetBSD: core_machdep.c,v 1.2 2019/06/01 12:42:28 maxv Exp $");
#include <sys/core.h> #include <sys/core.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/cpu.h> #include <sys/cpu.h>
#include <sys/compat_stub.h>
#include <riscv/locore.h> #include <riscv/locore.h>
@ -92,11 +93,13 @@ CORENAME(cpu_coredump)(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &cpustate, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
chdr->c_cpusize); &cpustate, chdr->c_cpusize), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: coff_exec.c,v 1.33 2009/06/29 05:08:15 dholland Exp $ */ /* $NetBSD: coff_exec.c,v 1.34 2019/11/20 19:37:52 pgoyette Exp $ */
/* /*
* Copyright (c) 1994, 1995 Scott Bartram * Copyright (c) 1994, 1995 Scott Bartram
@ -35,11 +35,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: coff_exec.c,v 1.33 2009/06/29 05:08:15 dholland Exp $"); __KERNEL_RCSID(0, "$NetBSD: coff_exec.c,v 1.34 2019/11/20 19:37:52 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_coredump.h"
#endif
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -54,13 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: coff_exec.c,v 1.33 2009/06/29 05:08:15 dholland Exp
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
#ifdef COREDUMP MODULE(MODULE_CLASS_MISC, exec_coff, NULL);
#define DEP "coredump"
#else
#define DEP NULL
#endif
MODULE(MODULE_CLASS_MISC, exec_coff, DEP);
static int coff_find_section(struct lwp *, struct vnode *, static int coff_find_section(struct lwp *, struct vnode *,
struct coff_filehdr *, struct coff_scnhdr *, int); struct coff_filehdr *, struct coff_scnhdr *, int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.5 2014/01/01 18:57:16 dsl Exp $ */ /* $NetBSD: core_machdep.c,v 1.6 2019/11/20 19:37:52 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@ -81,7 +81,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.5 2014/01/01 18:57:16 dsl Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2019/11/20 19:37:52 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.5 2014/01/01 18:57:16 dsl Exp $")
#include <sys/core.h> #include <sys/core.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <sys/compat_stub.h>
#include <sh3/reg.h> #include <sh3/reg.h>
@ -126,11 +127,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: process_machdep.c,v 1.21 2016/11/02 00:11:59 pgoyette Exp $ */ /* $NetBSD: process_machdep.c,v 1.22 2019/11/20 19:37:52 pgoyette Exp $ */
/* /*
* Copyright (c) 1993 The Regents of the University of California. * Copyright (c) 1993 The Regents of the University of California.
@ -77,7 +77,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.21 2016/11/02 00:11:59 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.22 2019/11/20 19:37:52 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -91,7 +91,6 @@ __KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.21 2016/11/02 00:11:59 pgoyett
#include <machine/reg.h> #include <machine/reg.h>
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
#include "opt_coredump.h"
#include "opt_ptrace.h" #include "opt_ptrace.h"
#ifdef COMPAT_40 #ifdef COMPAT_40
@ -101,8 +100,6 @@ static int process_machdep_write_regs40(struct lwp *l, struct __reg40 *);
#endif /* COMPAT_40 */ #endif /* COMPAT_40 */
#if defined(PTRACE_HOOKS) || defined(COREDUMP)
static inline struct trapframe * static inline struct trapframe *
process_frame(struct lwp *l) process_frame(struct lwp *l)
{ {
@ -141,9 +138,6 @@ process_read_regs(struct lwp *l, struct reg *regs)
return (0); return (0);
} }
#endif /* PTRACE_HOOKS || COREDUMP */
#ifdef PTRACE_HOOKS #ifdef PTRACE_HOOKS
int int

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.7 2014/02/28 10:16:51 skrll Exp $ */ /* $NetBSD: core_machdep.c,v 1.8 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1996 * Copyright (c) 1996
@ -49,7 +49,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.7 2014/02/28 10:16:51 skrll Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.7 2014/02/28 10:16:51 skrll Exp $
#include <sys/buf.h> #include <sys/buf.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -103,11 +104,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.6 2014/01/01 18:57:16 dsl Exp $ */ /* $NetBSD: core_machdep.c,v 1.7 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved. * Copyright (c) 1996-2002 Eduardo Horvath. All rights reserved.
@ -50,7 +50,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2014/01/01 18:57:16 dsl Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.7 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2014/01/01 18:57:16 dsl Exp $")
#include <sys/buf.h> #include <sys/buf.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -147,11 +148,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.113 2019/03/01 11:06:55 pgoyette Exp $ */ /* $NetBSD: netbsd32_machdep.c,v 1.114 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1998, 2001 Matthew R. Green * Copyright (c) 1998, 2001 Matthew R. Green
@ -27,14 +27,13 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.113 2019/03/01 11:06:55 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.114 2019/11/20 19:37:53 pgoyette Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h" #include "opt_compat_netbsd.h"
#include "opt_compat_sunos.h" #include "opt_compat_sunos.h"
#include "opt_modular.h" #include "opt_modular.h"
#include "opt_execfmt.h" #include "opt_execfmt.h"
#include "opt_coredump.h"
#include "firm_events.h" #include "firm_events.h"
#endif #endif
@ -354,7 +353,6 @@ netbsd32_process_write_fpregs(struct lwp *l, const struct fpreg32 *regs,
/* /*
* 32-bit version of cpu_coredump. * 32-bit version of cpu_coredump.
*/ */
#ifdef COREDUMP
int int
cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie, cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie,
struct core32 *chdr) struct core32 *chdr)
@ -402,15 +400,16 @@ cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }
#endif
void netbsd32_cpu_getmcontext(struct lwp *, mcontext_t *, unsigned int *); void netbsd32_cpu_getmcontext(struct lwp *, mcontext_t *, unsigned int *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.7 2017/05/22 16:39:40 ragge Exp $ */ /* $NetBSD: core_machdep.c,v 1.8 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden. * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@ -26,13 +26,14 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.7 2017/05/22 16:39:40 ragge Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.8 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/core.h> #include <sys/core.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -67,11 +68,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, &md_core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &md_core,
sizeof(md_core)); sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_machdep.c,v 1.5 2014/01/04 00:10:03 dsl Exp $ */ /* $NetBSD: core_machdep.c,v 1.6 2019/11/20 19:37:53 pgoyette Exp $ */
/*- /*-
* Copyright (c) 1982, 1986 The Regents of the University of California. * Copyright (c) 1982, 1986 The Regents of the University of California.
@ -80,7 +80,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.5 2014/01/04 00:10:03 dsl Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.6 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -90,6 +90,7 @@ __KERNEL_RCSID(0, "$NetBSD: core_machdep.c,v 1.5 2014/01/04 00:10:03 dsl Exp $")
#include <sys/core.h> #include <sys/core.h>
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <sys/compat_stub.h>
#include <sys/exec_aout.h> #include <sys/exec_aout.h>
@ -142,11 +143,13 @@ cpu_coredump(struct lwp *l, struct coredump_iostate *iocookie,
cseg.c_addr = 0; cseg.c_addr = 0;
cseg.c_size = chdr->c_cpusize; cseg.c_size = chdr->c_cpusize;
error = coredump_write(iocookie, UIO_SYSSPACE, &cseg, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cseg,
chdr->c_seghdrsize); chdr->c_seghdrsize), ENOSYS, error);
if (error) if (error)
return error; return error;
return coredump_write(iocookie, UIO_SYSSPACE, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE,
&md_core, sizeof(md_core)); &md_core, sizeof(md_core)), ENOSYS, error);
return error;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: m68k4k_exec.c,v 1.24 2014/03/07 01:33:43 christos Exp $ */ /* $NetBSD: m68k4k_exec.c,v 1.25 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1993, 1994 Christopher G. Demetriou * Copyright (c) 1993, 1994 Christopher G. Demetriou
@ -41,7 +41,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: m68k4k_exec.c,v 1.24 2014/03/07 01:33:43 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: m68k4k_exec.c,v 1.25 2019/11/20 19:37:53 pgoyette Exp $");
#if !defined(__m68k__) #if !defined(__m68k__)
#error YOU GOTTA BE KIDDING! #error YOU GOTTA BE KIDDING!
@ -59,13 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: m68k4k_exec.c,v 1.24 2014/03/07 01:33:43 christos Ex
#include <compat/m68k4k/m68k4k_exec.h> #include <compat/m68k4k/m68k4k_exec.h>
#ifdef COREDUMP MODULE(MODULE_CLASS_EXEC, exec_m68k4k, NULL);
#define DEP "coredump"
#else
#define DEP NULL
#endif
MODULE(MODULE_CLASS_EXEC, exec_m68k4k, DEP);
static struct execsw exec_m68k4k_execsw = { static struct execsw exec_m68k4k_execsw = {
.es_hdrsz = sizeof(struct exec), .es_hdrsz = sizeof(struct exec),

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_core.c,v 1.14 2011/02/02 20:10:09 chuck Exp $ */ /* $NetBSD: netbsd32_core.c,v 1.15 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1997 Charles D. Cranor and Washington University. * Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -45,9 +45,22 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_core.c,v 1.14 2011/02/02 20:10:09 chuck Exp $"); __KERNEL_RCSID(0, "$NetBSD: netbsd32_core.c,v 1.15 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/lwp.h>
#define CORENAME(x) __CONCAT(x,32) #define CORENAME(x) __CONCAT(x,32)
#define COREINC <compat/netbsd32/netbsd32.h> #define COREINC <compat/netbsd32/netbsd32.h>
struct coredump_iostate;
int CORENAME(real_coredump_netbsd)(struct lwp *, struct coredump_iostate *);
#include "../../kern/core_netbsd.c" #include "../../kern/core_netbsd.c"
int
CORENAME(coredump_netbsd)(struct lwp *l, struct coredump_iostate *iocookie)
{
return CORENAME(real_coredump_netbsd)(l, iocookie);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_mod.c,v 1.15 2019/01/27 02:08:40 pgoyette Exp $ */ /* $NetBSD: netbsd32_mod.c,v 1.16 2019/11/20 19:37:53 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2008 The NetBSD Foundation, Inc. * Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15 2019/01/27 02:08:40 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.16 2019/11/20 19:37:53 pgoyette Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_execfmt.h" #include "opt_execfmt.h"
@ -55,7 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mod.c,v 1.15 2019/01/27 02:08:40 pgoyette E
struct compat32_80_modctl_hook_t compat32_80_modctl_hook; struct compat32_80_modctl_hook_t compat32_80_modctl_hook;
# define DEPS1 "ksem,coredump,compat_util" # define DEPS1 "ksem,compat_util"
#if defined(EXEC_ELF32) #if defined(EXEC_ELF32)
# define DEPS2 ",exec_elf32" # define DEPS2 ",exec_elf32"

View File

@ -1,4 +1,4 @@
/* $NetBSD: vax1k_exec.c,v 1.18 2014/03/07 01:33:44 christos Exp $ */ /* $NetBSD: vax1k_exec.c,v 1.19 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1993, 1994 Christopher G. Demetriou * Copyright (c) 1993, 1994 Christopher G. Demetriou
@ -40,7 +40,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vax1k_exec.c,v 1.18 2014/03/07 01:33:44 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: vax1k_exec.c,v 1.19 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -55,16 +55,11 @@ __KERNEL_RCSID(0, "$NetBSD: vax1k_exec.c,v 1.18 2014/03/07 01:33:44 christos Exp
#if defined(_KERNEL_OPT) #if defined(_KERNEL_OPT)
#include "opt_compat_43.h" #include "opt_compat_43.h"
#include "opt_coredump.h"
#else #else
#define COMPAT_43 /* enable 4.3BSD binaries for lkm */ #define COMPAT_43 /* enable 4.3BSD binaries for lkm */
#endif #endif
#ifdef COREDUMP
MODULE(MODULE_CLASS_EXEC, exec_vax1k, "coredump");
#else
MODULE(MODULE_CLASS_EXEC, exec_vax1k, NULL); MODULE(MODULE_CLASS_EXEC, exec_vax1k, NULL);
#endif
int exec_vax1k_prep_anymagic(struct lwp *, struct exec_package *, int exec_vax1k_prep_anymagic(struct lwp *, struct exec_package *,
size_t, bool); size_t, bool);

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_stub.c,v 1.18 2019/11/16 03:26:19 pgoyette Exp $ */ /* $NetBSD: compat_stub.c,v 1.19 2019/11/20 19:37:53 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2018 The NetBSD Foundation, Inc. * Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -274,6 +274,13 @@ struct netbsd32_reg_validate_hook_t netbsd32_reg_validate_hook;
struct sendsig_sigcontext_16_hook_t sendsig_sigcontext_16_hook; struct sendsig_sigcontext_16_hook_t sendsig_sigcontext_16_hook;
/* /*
* Hook for coredumps * Hooks for coredumps
*/ */
struct coredump_hook_t coredump_hook; struct coredump_hook_t coredump_hook;
struct coredump_offset_hook_t coredump_offset_hook;
struct coredump_write_hook_t coredump_write_hook;
struct coredump_netbsd_hook_t coredump_netbsd_hook;
struct uvm_coredump_walkmap_hook_t uvm_coredump_walkmap_hook;
struct uvm_coredump_count_segs_hook_t uvm_coredump_count_segs_hook;

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_elf32.c,v 1.58 2019/01/22 03:44:44 kamil Exp $ */ /* $NetBSD: core_elf32.c,v 1.59 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 2001 Wasabi Systems, Inc. * Copyright (c) 2001 Wasabi Systems, Inc.
@ -40,10 +40,9 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.58 2019/01/22 03:44:44 kamil Exp $"); __KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.59 2019/11/20 19:37:53 pgoyette Exp $");
#ifdef _KERNEL_OPT #ifdef _KERNEL_OPT
#include "opt_coredump.h"
#include "opt_compat_netbsd32.h" #include "opt_compat_netbsd32.h"
#endif #endif
@ -60,13 +59,12 @@ __KERNEL_RCSID(1, "$NetBSD: core_elf32.c,v 1.58 2019/01/22 03:44:44 kamil Exp $"
#include <sys/ptrace.h> #include <sys/ptrace.h>
#include <sys/kmem.h> #include <sys/kmem.h>
#include <sys/kauth.h> #include <sys/kauth.h>
#include <sys/compat_stub.h>
#include <machine/reg.h> #include <machine/reg.h>
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
#ifdef COREDUMP
struct writesegs_state { struct writesegs_state {
Elf_Phdr *psections; Elf_Phdr *psections;
proc_t *p; proc_t *p;
@ -115,6 +113,9 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
off_t notestart; off_t notestart;
size_t notesize; size_t notesize;
int error, i; int error, i;
#ifdef DIAGNOSTIC
off_t offset;
#endif
struct note_state ns; struct note_state ns;
struct note_buf *nb; struct note_buf *nb;
@ -144,7 +145,8 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
*/ */
/* Pass 1: count the entries. */ /* Pass 1: count the entries. */
npsections = uvm_coredump_count_segs(l->l_proc); MODULE_HOOK_CALL(uvm_coredump_count_segs_hook,
(l->l_proc), 0, npsections);
/* Allow for the PT_NOTE section. */ /* Allow for the PT_NOTE section. */
npsections++; npsections++;
@ -193,7 +195,8 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
#endif #endif
/* Write out the ELF header. */ /* Write out the ELF header. */
error = coredump_write(cookie, UIO_SYSSPACE, &ehdr, sizeof(ehdr)); MODULE_HOOK_CALL(coredump_write_hook, (cookie, UIO_SYSSPACE, &ehdr,
sizeof(ehdr)), ENOSYS, error);
if (error) if (error)
goto out; goto out;
@ -202,8 +205,8 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
memset(&shdr, 0, sizeof(shdr)); memset(&shdr, 0, sizeof(shdr));
shdr.sh_type = SHT_NULL; shdr.sh_type = SHT_NULL;
shdr.sh_info = npsections; shdr.sh_info = npsections;
error = coredump_write(cookie, UIO_SYSSPACE, &shdr, MODULE_HOOK_CALL(coredump_write_hook, (cookie, UIO_SYSSPACE,
sizeof(shdr)); &shdr, sizeof(shdr)), ENOSYS, error);
if (error) if (error)
goto out; goto out;
} }
@ -218,8 +221,8 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
ws.psections = psections; ws.psections = psections;
ws.npsections = npsections - 1; ws.npsections = npsections - 1;
ws.p = l->l_proc; ws.p = l->l_proc;
error = uvm_coredump_walkmap(l->l_proc, ELFNAMEEND(coredump_getseghdrs), MODULE_HOOK_CALL(uvm_coredump_walkmap_hook,
&ws); (l->l_proc, ELFNAMEEND(coredump_getseghdrs), &ws), ENOSYS, error);
if (error) if (error)
goto out; goto out;
if (ws.npsections != 0) { if (ws.npsections != 0) {
@ -239,21 +242,25 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
ws.psections->p_align = ELFROUNDSIZE; ws.psections->p_align = ELFROUNDSIZE;
/* Write the P-section headers followed by the PT_NOTE header */ /* Write the P-section headers followed by the PT_NOTE header */
error = coredump_write(cookie, UIO_SYSSPACE, psections, psectionssize); MODULE_HOOK_CALL(coredump_write_hook, (cookie, UIO_SYSSPACE, psections,
psectionssize), ENOSYS, error);
if (error) if (error)
goto out; goto out;
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (coredump_offset(cookie) != notestart) MODULE_HOOK_CALL(coredump_offset_hook, (cookie), 0, offset);
if (offset != notestart)
panic("coredump: offset %lld != notestart %lld", panic("coredump: offset %lld != notestart %lld",
(long long) coredump_offset(cookie), (long long) offset,
(long long) notestart); (long long) notestart);
#endif #endif
/* Write out the notes. */ /* Write out the notes. */
for (nb = ns.ns_first; nb != NULL; nb = nb->nb_next) { for (nb = ns.ns_first; nb != NULL; nb = nb->nb_next) {
error = coredump_write(cookie, UIO_SYSSPACE, nb->nb_data, MODULE_HOOK_CALL(coredump_write_hook, (cookie, UIO_SYSSPACE,
nb->nb_next == NULL ? ns.ns_offset : sizeof nb->nb_data); nb->nb_data,
nb->nb_next == NULL ? ns.ns_offset : sizeof nb->nb_data),
ENOSYS, error);
if (error) if (error)
goto out; goto out;
} }
@ -264,15 +271,16 @@ ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
continue; continue;
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (coredump_offset(cookie) != psections[i].p_offset) MODULE_HOOK_CALL(coredump_offset_hook, (cookie), 0, offset);
if (offset != psections[i].p_offset)
panic("coredump: offset %lld != p_offset[%d] %lld", panic("coredump: offset %lld != p_offset[%d] %lld",
(long long) coredump_offset(cookie), i, (long long) offset, i,
(long long) psections[i].p_filesz); (long long) psections[i].p_filesz);
#endif #endif
error = coredump_write(cookie, UIO_USERSPACE, MODULE_HOOK_CALL(coredump_write_hook, (cookie, UIO_USERSPACE,
(void *)(vaddr_t)psections[i].p_vaddr, (void *)(vaddr_t)psections[i].p_vaddr,
psections[i].p_filesz); psections[i].p_filesz), ENOSYS, error);
if (error) if (error)
goto out; goto out;
} }
@ -551,14 +559,3 @@ ELFNAMEEND(coredump_savenote)(struct note_state *ns, unsigned int type,
save_note_bytes(ns, name, nhdr.n_namesz); save_note_bytes(ns, name, nhdr.n_namesz);
save_note_bytes(ns, data, data_len); save_note_bytes(ns, data, data_len);
} }
#else /* COREDUMP */
int
ELFNAMEEND(coredump)(struct lwp *l, struct coredump_iostate *cookie)
{
return ENOSYS;
}
#endif /* COREDUMP */

View File

@ -1,4 +1,4 @@
/* $NetBSD: core_netbsd.c,v 1.23 2017/01/06 22:53:17 kamil Exp $ */ /* $NetBSD: core_netbsd.c,v 1.24 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1997 Charles D. Cranor and Washington University. * Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -45,11 +45,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.23 2017/01/06 22:53:17 kamil Exp $"); __KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.24 2019/11/20 19:37:53 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_coredump.h"
#endif
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -57,6 +53,9 @@ __KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.23 2017/01/06 22:53:17 kamil Exp $
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/vnode.h> #include <sys/vnode.h>
#include <sys/core.h> #include <sys/core.h>
#include <sys/module.h>
#include <sys/compat_stub.h>
#include <sys/signalvar.h>
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
@ -67,8 +66,6 @@ __KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.23 2017/01/06 22:53:17 kamil Exp $
#include COREINC #include COREINC
#endif #endif
#ifdef COREDUMP
struct coredump_state { struct coredump_state {
struct coredump_iostate *iocookie; struct coredump_iostate *iocookie;
struct CORENAME(core) core; struct CORENAME(core) core;
@ -77,7 +74,7 @@ struct coredump_state {
static int CORENAME(coredump_writesegs_netbsd)(struct uvm_coredump_state *); static int CORENAME(coredump_writesegs_netbsd)(struct uvm_coredump_state *);
int int
CORENAME(coredump_netbsd)(struct lwp *l, struct coredump_iostate *iocookie) CORENAME(real_coredump_netbsd)(struct lwp *l, struct coredump_iostate *iocookie)
{ {
struct coredump_state cs; struct coredump_state cs;
struct proc *p = l->l_proc; struct proc *p = l->l_proc;
@ -98,11 +95,11 @@ CORENAME(coredump_netbsd)(struct lwp *l, struct coredump_iostate *iocookie)
error = CORENAME(cpu_coredump)(l, NULL, &cs.core); error = CORENAME(cpu_coredump)(l, NULL, &cs.core);
if (error) if (error)
return (error); return (error);
cs.core.c_nseg = uvm_coredump_count_segs(p); MODULE_HOOK_CALL(uvm_coredump_count_segs_hook, (p), 0, cs.core.c_nseg);
/* First write out the core header. */ /* First write out the core header. */
error = coredump_write(iocookie, UIO_SYSSPACE, &cs.core, MODULE_HOOK_CALL(coredump_write_hook, (iocookie, UIO_SYSSPACE, &cs.core,
cs.core.c_hdrsize); cs.core.c_hdrsize), ENOSYS, error);
if (error) if (error)
return (error); return (error);
@ -112,8 +109,10 @@ CORENAME(coredump_netbsd)(struct lwp *l, struct coredump_iostate *iocookie)
return (error); return (error);
/* Finally, the address space dump */ /* Finally, the address space dump */
return uvm_coredump_walkmap(p, CORENAME(coredump_writesegs_netbsd), MODULE_HOOK_CALL(uvm_coredump_walkmap_hook,
&cs); (p, CORENAME(coredump_writesegs_netbsd), &cs), ENOSYS, error);
return error;
} }
static int static int
@ -140,22 +139,13 @@ CORENAME(coredump_writesegs_netbsd)(struct uvm_coredump_state *us)
else else
cseg.c_size = us->end - us->start; cseg.c_size = us->end - us->start;
error = coredump_write(cs->iocookie, UIO_SYSSPACE, MODULE_HOOK_CALL(coredump_write_hook, (cs->iocookie, UIO_SYSSPACE,
&cseg, cs->core.c_seghdrsize); &cseg, cs->core.c_seghdrsize), ENOSYS, error);
if (error) if (error)
return (error); return (error);
return coredump_write(cs->iocookie, UIO_USERSPACE, MODULE_HOOK_CALL(coredump_write_hook, (cs->iocookie, UIO_USERSPACE,
(void *)(vaddr_t)us->start, cseg.c_size); (void *)(vaddr_t)us->start, cseg.c_size), ENOSYS, error);
return error;
} }
#else /* COREDUMP */
int
CORENAME(coredump_netbsd)(struct lwp *l, struct coredump_iostate *cookie)
{
return ENOSYS;
}
#endif /* COREDUMP */

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_aout.c,v 1.40 2014/03/07 01:55:01 matt Exp $ */ /* $NetBSD: exec_aout.c,v 1.41 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1993, 1994 Christopher G. Demetriou * Copyright (c) 1993, 1994 Christopher G. Demetriou
@ -31,11 +31,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.40 2014/03/07 01:55:01 matt Exp $"); __KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.41 2019/11/20 19:37:53 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_coredump.h"
#endif
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -48,13 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_aout.c,v 1.40 2014/03/07 01:55:01 matt Exp $");
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
#ifdef COREDUMP MODULE(MODULE_CLASS_EXEC, exec_aout, NULL);
#define DEP "coredump"
#else
#define DEP NULL
#endif
MODULE(MODULE_CLASS_EXEC, exec_aout, DEP);
static struct execsw exec_aout_execsw = { static struct execsw exec_aout_execsw = {
.es_hdrsz = sizeof(struct exec), .es_hdrsz = sizeof(struct exec),

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_ecoff.c,v 1.31 2014/03/07 01:34:29 christos Exp $ */ /* $NetBSD: exec_ecoff.c,v 1.32 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1994 Adam Glass * Copyright (c) 1994 Adam Glass
@ -33,11 +33,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.31 2014/03/07 01:34:29 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.32 2019/11/20 19:37:53 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_coredump.h"
#endif
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -49,13 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_ecoff.c,v 1.31 2014/03/07 01:34:29 christos Exp
#include <sys/exec.h> #include <sys/exec.h>
#include <sys/exec_ecoff.h> #include <sys/exec_ecoff.h>
#ifdef COREDUMP MODULE(MODULE_CLASS_EXEC, exec_ecoff, NULL);
#define DEP "coredump"
#else
#define DEP NULL
#endif
MODULE(MODULE_CLASS_EXEC, exec_ecoff, DEP)
static struct execsw exec_ecoff_execsw = { static struct execsw exec_ecoff_execsw = {
.es_hdrsz = ECOFF_HDR_SIZE, .es_hdrsz = ECOFF_HDR_SIZE,

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_elf32.c,v 1.142 2017/01/25 17:56:45 christos Exp $ */ /* $NetBSD: exec_elf32.c,v 1.143 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1996 Christopher G. Demetriou * Copyright (c) 1996 Christopher G. Demetriou
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exec_elf32.c,v 1.142 2017/01/25 17:56:45 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: exec_elf32.c,v 1.143 2019/11/20 19:37:53 pgoyette Exp $");
#define ELFSIZE 32 #define ELFSIZE 32
@ -43,13 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_elf32.c,v 1.142 2017/01/25 17:56:45 christos Ex
#define ELF32_AUXSIZE (ELF_AUX_ENTRIES * sizeof(Aux32Info) \ #define ELF32_AUXSIZE (ELF_AUX_ENTRIES * sizeof(Aux32Info) \
+ MAXPATHLEN + ALIGN(1)) + MAXPATHLEN + ALIGN(1))
#ifdef COREDUMP MODULE(MODULE_CLASS_EXEC, exec_elf32, NULL);
#define DEP "coredump"
#else
#define DEP NULL
#endif
MODULE(MODULE_CLASS_EXEC, exec_elf32, DEP);
static struct execsw exec_elf32_execsw[] = { static struct execsw exec_elf32_execsw[] = {
{ {

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_elf64.c,v 1.7 2017/01/25 17:56:45 christos Exp $ */ /* $NetBSD: exec_elf64.c,v 1.8 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1996 Christopher G. Demetriou * Copyright (c) 1996 Christopher G. Demetriou
@ -32,7 +32,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exec_elf64.c,v 1.7 2017/01/25 17:56:45 christos Exp $"); __KERNEL_RCSID(0, "$NetBSD: exec_elf64.c,v 1.8 2019/11/20 19:37:53 pgoyette Exp $");
#define ELFSIZE 64 #define ELFSIZE 64
@ -43,13 +43,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_elf64.c,v 1.7 2017/01/25 17:56:45 christos Exp
#define ELF64_AUXSIZE (ELF_AUX_ENTRIES * sizeof(Aux64Info) \ #define ELF64_AUXSIZE (ELF_AUX_ENTRIES * sizeof(Aux64Info) \
+ MAXPATHLEN + ALIGN(1)) + MAXPATHLEN + ALIGN(1))
#ifdef COREDUMP MODULE(MODULE_CLASS_EXEC, exec_elf64, NULL);
#define DEP "coredump"
#else
#define DEP NULL
#endif
MODULE(MODULE_CLASS_EXEC, exec_elf64, DEP);
static struct execsw exec_elf64_execsw[] = { static struct execsw exec_elf64_execsw[] = {
/* Native Elf64 */ /* Native Elf64 */

View File

@ -1,4 +1,4 @@
# $NetBSD: files.kern,v 1.37 2019/11/14 16:23:52 maxv Exp $ # $NetBSD: files.kern,v 1.38 2019/11/20 19:37:53 pgoyette Exp $
# #
# kernel sources # kernel sources
@ -16,7 +16,7 @@ file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy
file kern/compat_stub.c kern file kern/compat_stub.c kern
file kern/core_elf32.c exec_elf32 file kern/core_elf32.c exec_elf32
file kern/core_elf64.c exec_elf64 file kern/core_elf64.c exec_elf64
file kern/core_netbsd.c exec_aout | exec_coff | exec_ecoff file kern/core_netbsd.c coredump
file kern/cnmagic.c kern file kern/cnmagic.c kern
file kern/exec_aout.c exec_aout file kern/exec_aout.c exec_aout
file kern/exec_ecoff.c exec_ecoff file kern/exec_ecoff.c exec_ecoff

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_core.c,v 1.27 2019/11/10 14:20:50 pgoyette Exp $ */ /* $NetBSD: kern_core.c,v 1.28 2019/11/20 19:37:53 pgoyette Exp $ */
/* /*
* Copyright (c) 1982, 1986, 1989, 1991, 1993 * Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -37,7 +37,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.27 2019/11/10 14:20:50 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_core.c,v 1.28 2019/11/20 19:37:53 pgoyette Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/vnode.h> #include <sys/vnode.h>
@ -63,6 +63,9 @@ struct coredump_iostate {
static int coredump(struct lwp *, const char *); static int coredump(struct lwp *, const char *);
static int coredump_buildname(struct proc *, char *, const char *, size_t); static int coredump_buildname(struct proc *, char *, const char *, size_t);
static int coredump_write(struct coredump_iostate *, enum uio_seg segflg,
const void *, size_t);
static off_t coredump_offset(struct coredump_iostate *);
static int static int
coredump_modcmd(modcmd_t cmd, void *arg) coredump_modcmd(modcmd_t cmd, void *arg)
@ -71,15 +74,23 @@ coredump_modcmd(modcmd_t cmd, void *arg)
switch (cmd) { switch (cmd) {
case MODULE_CMD_INIT: case MODULE_CMD_INIT:
MODULE_HOOK_SET(coredump_hook, "coredump", coredump); MODULE_HOOK_SET(coredump_hook, "coredump", coredump);
MODULE_HOOK_SET(coredump_write_hook, "coredump",
coredump_write);
MODULE_HOOK_SET(coredump_offset_hook, "coredump",
coredump_offset);
MODULE_HOOK_SET(coredump_netbsd_hook, "coredump",
real_coredump_netbsd);
MODULE_HOOK_SET(uvm_coredump_walkmap_hook, "coredump",
uvm_coredump_walkmap);
MODULE_HOOK_SET(uvm_coredump_count_segs_hook, "coredump",
uvm_coredump_count_segs);
return 0; return 0;
case MODULE_CMD_FINI: case MODULE_CMD_FINI:
/* MODULE_HOOK_UNSET(uvm_coredump_count_segs_hook);
* In theory we don't need to UNSET this, as the various MODULE_HOOK_UNSET(uvm_coredump_walkmap_hook);
* exec formats depend on this module. If this module has MODULE_HOOK_UNSET(coredump_netbsd_hook);
* no references, and so can be unloaded, no user programs MODULE_HOOK_UNSET(coredump_offset_hook);
* can be running and so nothing can call *coredump_vec. MODULE_HOOK_UNSET(coredump_write_hook);
*/
MODULE_HOOK_UNSET(coredump_hook); MODULE_HOOK_UNSET(coredump_hook);
return 0; return 0;
default: default:
@ -310,7 +321,7 @@ coredump_buildname(struct proc *p, char *dst, const char *src, size_t len)
return 0; return 0;
} }
int static int
coredump_write(struct coredump_iostate *io, enum uio_seg segflg, coredump_write(struct coredump_iostate *io, enum uio_seg segflg,
const void *data, size_t len) const void *data, size_t len)
{ {
@ -332,7 +343,7 @@ coredump_write(struct coredump_iostate *io, enum uio_seg segflg,
return (0); return (0);
} }
off_t static off_t
coredump_offset(struct coredump_iostate *io) coredump_offset(struct coredump_iostate *io)
{ {
return io->io_offset; return io->io_offset;

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.378 2019/11/10 14:20:50 pgoyette Exp $ */ /* $NetBSD: kern_sig.c,v 1.379 2019/11/20 19:37:53 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.378 2019/11/10 14:20:50 pgoyette Exp $"); __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.379 2019/11/20 19:37:53 pgoyette Exp $");
#include "opt_ptrace.h" #include "opt_ptrace.h"
#include "opt_dtrace.h" #include "opt_dtrace.h"
@ -2316,6 +2316,22 @@ sigexit(struct lwp *l, int signo)
/* NOTREACHED */ /* NOTREACHED */
} }
/*
* Many emulations have a common coredump_netbsd() established as their
* dump routine. Since the "real" code may (or may not) be present in
* loadable module, we provide a routine here which calls the module
* hook.
*/
int
coredump_netbsd(struct lwp *l, struct coredump_iostate *iocookie)
{
int retval;
MODULE_HOOK_CALL(coredump_netbsd_hook, (l, iocookie), ENOSYS, retval);
return retval;
}
/* /*
* Put process 'p' into the stopped state and optionally, notify the parent. * Put process 'p' into the stopped state and optionally, notify the parent.
*/ */

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.2 2019/06/18 01:39:39 christos Exp $ # $NetBSD: Makefile,v 1.3 2019/11/20 19:37:54 pgoyette Exp $
.include "../Makefile.inc" .include "../Makefile.inc"
KMOD= compat_aoutm68k KMOD= compat_aoutm68k
CPPFLAGS+= -DEXEC_AOUT -DCOREDUMP CPPFLAGS+= -DEXEC_AOUT
CPPFLAGS+= -DSYSVSHM -DSYSVSEM -DSYSVMSG -DKTRACE CPPFLAGS+= -DSYSVSHM -DSYSVSEM -DSYSVMSG -DKTRACE
CPPFLAGS+= -DCOMPAT_43 -DCOMPAT_12 -DCOMPAT_13 -DCOMPAT_14 CPPFLAGS+= -DCOMPAT_43 -DCOMPAT_12 -DCOMPAT_13 -DCOMPAT_14
CPPFLAGS+= -DCOMPAT_AOUT_M68K -DQUOTA CPPFLAGS+= -DCOMPAT_AOUT_M68K -DQUOTA

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.29 2019/09/28 15:15:09 christos Exp $ # $NetBSD: Makefile,v 1.30 2019/11/20 19:37:54 pgoyette Exp $
.include "../Makefile.inc" .include "../Makefile.inc"
.include "../Makefile.assym" .include "../Makefile.assym"
@ -11,7 +11,7 @@ NETBSD32_DRMKMS?=yes
CPPFLAGS+= -DCOMPAT_NETBSD32 CPPFLAGS+= -DCOMPAT_NETBSD32
CPPFLAGS+= -DEXEC_ELF32 -DEXEC_ELF64 CPPFLAGS+= -DEXEC_ELF32 -DEXEC_ELF64
CPPFLAGS+= -DCOREDUMP -DNTP -DVMSWAP CPPFLAGS+= -DNTP -DVMSWAP
CPPFLAGS+= -DKTRACE -DMODULAR -DQUOTA CPPFLAGS+= -DKTRACE -DMODULAR -DQUOTA
CPPFLAGS+= -I${NETBSDSRCDIR}/sys/external/bsd/libnv/dist CPPFLAGS+= -I${NETBSDSRCDIR}/sys/external/bsd/libnv/dist

View File

@ -1,11 +1,9 @@
# $NetBSD: Makefile,v 1.5 2019/10/13 07:28:13 mrg Exp $ # $NetBSD: Makefile,v 1.6 2019/11/20 19:37:54 pgoyette Exp $
.include "../Makefile.inc" .include "../Makefile.inc"
KMOD= coredump KMOD= coredump
CPPFLAGS+= -DCOREDUMP
.PATH: ${S}/kern .PATH: ${S}/kern
SRCS= kern_core.c core_netbsd.c SRCS= kern_core.c core_netbsd.c

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.3 2008/11/20 11:01:54 ad Exp $ # $NetBSD: Makefile,v 1.4 2019/11/20 19:37:54 pgoyette Exp $
.include "../Makefile.inc" .include "../Makefile.inc"
KMOD= exec_aout KMOD= exec_aout
CPPFLAGS+= -DEXEC_AOUT -DCOREDUMP -DCOMPAT_NOMID CPPFLAGS+= -DEXEC_AOUT -DCOMPAT_NOMID
.PATH: ${S}/kern .PATH: ${S}/kern
SRCS= exec_aout.c SRCS= exec_aout.c

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.4 2019/02/17 13:21:55 rin Exp $ # $NetBSD: Makefile,v 1.5 2019/11/20 19:37:54 pgoyette Exp $
.include "../Makefile.inc" .include "../Makefile.inc"
KMOD= exec_elf32 KMOD= exec_elf32
CPPFLAGS+= -DEXEC_ELF32 -DCOREDUMP CPPFLAGS+= -DEXEC_ELF32
.if ${MACHINE_ARCH} != "arm" && \ .if ${MACHINE_ARCH} != "arm" && \
${MACHINE_ARCH} != "armeb" && \ ${MACHINE_ARCH} != "armeb" && \
${MACHINE_ARCH} != "m68000" && \ ${MACHINE_ARCH} != "m68000" && \

View File

@ -1,10 +1,10 @@
# $NetBSD: Makefile,v 1.3 2019/02/17 04:05:49 rin Exp $ # $NetBSD: Makefile,v 1.4 2019/11/20 19:37:54 pgoyette Exp $
.include "../Makefile.inc" .include "../Makefile.inc"
KMOD= exec_elf64 KMOD= exec_elf64
CPPFLAGS+= -DEXEC_ELF64 -DCOREDUMP CPPFLAGS+= -DEXEC_ELF64
.if ${MACHINE_ARCH} != "powerpc64" && \ .if ${MACHINE_ARCH} != "powerpc64" && \
${MACHINE_ARCH} != "sparc64" ${MACHINE_ARCH} != "sparc64"
CPPFLAGS+= -DPAX_ASLR CPPFLAGS+= -DPAX_ASLR

View File

@ -1,4 +1,4 @@
/* $NetBSD: compat_stub.h,v 1.21 2019/11/10 14:20:50 pgoyette Exp $ */ /* $NetBSD: compat_stub.h,v 1.22 2019/11/20 19:37:54 pgoyette Exp $ */
/*- /*-
* Copyright (c) 2018 The NetBSD Foundation, Inc. * Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -367,8 +367,18 @@ MODULE_HOOK(sendsig_sigcontext_16_hook, void,
(const struct ksiginfo *, const sigset_t *)); (const struct ksiginfo *, const sigset_t *));
/* /*
* Hook for coredumps * Hooks for coredumps
*/ */
struct uvm_coredump_state;
MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *)); MODULE_HOOK(coredump_hook, int, (struct lwp *, const char *));
MODULE_HOOK(coredump_offset_hook, off_t, (struct coredump_iostate *));
MODULE_HOOK(coredump_write_hook, int,
(struct coredump_iostate *, enum uio_seg, const void *, size_t));
MODULE_HOOK(coredump_netbsd_hook, int,
(struct lwp *, struct coredump_iostate *));
MODULE_HOOK(uvm_coredump_walkmap_hook, int,
(struct proc *, int (*)(struct uvm_coredump_state *), void *));
MODULE_HOOK(uvm_coredump_count_segs_hook, int, (struct proc *));
#endif /* _SYS_COMPAT_STUB_H */ #endif /* _SYS_COMPAT_STUB_H */

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.h,v 1.156 2019/09/17 15:19:27 christos Exp $ */ /* $NetBSD: exec.h,v 1.157 2019/11/20 19:37:54 pgoyette Exp $ */
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
@ -275,10 +275,6 @@ int exec_read_from (struct lwp *, struct vnode *, u_long off,
void *, size_t); void *, size_t);
int exec_setup_stack (struct lwp *, struct exec_package *); int exec_setup_stack (struct lwp *, struct exec_package *);
int coredump_write (struct coredump_iostate *, enum uio_seg,
const void *, size_t);
off_t coredump_offset (struct coredump_iostate *);
void exec_free_emul_arg (struct exec_package *); void exec_free_emul_arg (struct exec_package *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: param.h,v 1.618 2019/10/12 19:59:57 kamil Exp $ */ /* $NetBSD: param.h,v 1.619 2019/11/20 19:37:54 pgoyette Exp $ */
/*- /*-
* Copyright (c) 1982, 1986, 1989, 1993 * Copyright (c) 1982, 1986, 1989, 1993
@ -67,7 +67,7 @@
* 2.99.9 (299000900) * 2.99.9 (299000900)
*/ */
#define __NetBSD_Version__ 999001700 /* NetBSD 9.99.17 */ #define __NetBSD_Version__ 999001800 /* NetBSD 9.99.18 */
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__) (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)

View File

@ -1,4 +1,4 @@
/* $NetBSD: signalvar.h,v 1.99 2019/11/10 14:20:50 pgoyette Exp $ */ /* $NetBSD: signalvar.h,v 1.100 2019/11/20 19:37:54 pgoyette Exp $ */
/* /*
* Copyright (c) 1991, 1993 * Copyright (c) 1991, 1993
@ -137,6 +137,7 @@ struct coredump_iostate;
* Machine-independent functions: * Machine-independent functions:
*/ */
int coredump_netbsd(struct lwp *, struct coredump_iostate *); int coredump_netbsd(struct lwp *, struct coredump_iostate *);
int real_coredump_netbsd(struct lwp *, struct coredump_iostate *);
void execsigs(struct proc *); void execsigs(struct proc *);
int issignal(struct lwp *); int issignal(struct lwp *);
void pgsignal(struct pgrp *, int, int); void pgsignal(struct pgrp *, int, int);

View File

@ -1,4 +1,4 @@
# $NetBSD: files.uvm,v 1.29 2018/05/19 11:39:37 jdolecek Exp $ # $NetBSD: files.uvm,v 1.30 2019/11/20 19:37:54 pgoyette Exp $
# #
# UVM options # UVM options
@ -23,7 +23,7 @@ file uvm/uvm_amap.c uvm
file uvm/uvm_anon.c uvm file uvm/uvm_anon.c uvm
file uvm/uvm_aobj.c uvm file uvm/uvm_aobj.c uvm
file uvm/uvm_bio.c uvm file uvm/uvm_bio.c uvm
file uvm/uvm_coredump.c coredump file uvm/uvm_coredump.c uvm & coredump
file uvm/uvm_device.c uvm file uvm/uvm_device.c uvm
file uvm/uvm_fault.c uvm file uvm/uvm_fault.c uvm
file uvm/uvm_glue.c uvm file uvm/uvm_glue.c uvm