Make the coredump routine exec-format/emulation specific. Split

out traditional NetBSD coredump routines into core_netbsd.c and
netbsd32_core.c (for COMPAT_NETBSD32).
This commit is contained in:
thorpej 2001-12-08 00:35:25 +00:00
parent c59d1f8772
commit 205c159f0e
17 changed files with 576 additions and 414 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_machdep.c,v 1.18 2001/09/21 17:12:22 thorpej Exp $ */
/* $NetBSD: netbsd32_machdep.c,v 1.19 2001/12/08 00:35:25 thorpej Exp $ */
/*
* Copyright (c) 1998 Matthew R. Green
@ -81,9 +81,7 @@ netbsd32_setregs(p, pack, stack)
/* Mark this as a 32-bit emulation */
p->p_flag |= P_32;
/* Setup the coredump32 and ev_out32 hook's */
if (coredump32_hook == NULL)
coredump32_hook = coredump32;
/* Setup the ev_out32 hook */
if (ev_out32_hook == NULL)
ev_out32_hook = ev_out32;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sunos32_machdep.c,v 1.5 2001/09/21 17:12:22 thorpej Exp $ */
/* $NetBSD: sunos32_machdep.c,v 1.6 2001/12/08 00:35:25 thorpej Exp $ */
/* from: NetBSD: sunos_machdep.c,v 1.14 2001/01/29 01:37:56 mrg Exp */
/*
@ -111,9 +111,7 @@ sunos32_setregs(p, pack, stack)
/* Mark this as a 32-bit emulation */
p->p_flag |= P_32;
/* Setup the coredump32 and ev_out32 hook's */
if (coredump32_hook == NULL)
coredump32_hook = coredump32;
/* Setup the ev_out32 hook */
if (ev_out32_hook == NULL)
ev_out32_hook = ev_out32;

View File

@ -1,4 +1,4 @@
# $NetBSD: files.netbsd32,v 1.10 2001/06/06 21:30:28 mrg Exp $
# $NetBSD: files.netbsd32,v 1.11 2001/12/08 00:35:26 thorpej Exp $
#
# config file description for machine-independent netbsd32 compat code.
# included by ports that need it.
@ -6,6 +6,7 @@
# ports should define any machine-specific files they need in their
# own file lists.
file compat/netbsd32/netbsd32_core.c compat_netbsd32
file compat/netbsd32/netbsd32_exec_elf32.c compat_netbsd32 & exec_elf32
file compat/netbsd32/netbsd32_exec_aout.c compat_netbsd32 & exec_aout
file compat/netbsd32/netbsd32_netbsd.c compat_netbsd32
@ -19,8 +20,6 @@ file compat/netbsd32/netbsd32_socket.c compat_netbsd32
file compat/netbsd32/netbsd32_sysctl.c compat_netbsd32
file compat/netbsd32/netbsd32_time.c compat_netbsd32
file compat/netbsd32/netbsd32_wait.c compat_netbsd32
file compat/netbsd32/netbsd32_kern_sig.c compat_netbsd32
file compat/netbsd32/netbsd32_uvm_unix.c compat_netbsd32
file compat/netbsd32/netbsd32_sysent.c compat_netbsd32
file compat/netbsd32/netbsd32_compat_09.c compat_netbsd32 & (compat_09 | compat_sunos)
file compat/netbsd32/netbsd32_compat_10.c compat_netbsd32 & compat_10

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32.h,v 1.20 2001/08/25 15:06:02 mrg Exp $ */
/* $NetBSD: netbsd32.h,v 1.21 2001/12/08 00:35:27 thorpej Exp $ */
/*
* Copyright (c) 1998, 2001 Matthew R. Green
@ -533,8 +533,7 @@ typedef struct firm_event32 {
#define NETBSD32TOX_UAP(name, type) NETBSD32TOX(uap, &ua, name, type);
#define NETBSD32TOX64_UAP(name, type) NETBSD32TOX64(uap, &ua, name, type);
/* hook for coredump */
extern int coredump32(struct proc *, struct vnode *);
int coredump_netbsd32(struct proc *, struct vnode *, struct ucred *);
/*
* random other stuff

View File

@ -1,4 +1,4 @@
/* $NetBSD: netbsd32_uvm_unix.c,v 1.3 2001/11/13 02:09:10 lukem Exp $ */
/* $NetBSD: netbsd32_core.c,v 1.1 2001/12/08 00:35:27 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -42,56 +42,70 @@
*
* from: Utah $Hdr: vm_unix.c 1.1 89/11/07$
* @(#)vm_unix.c 8.1 (Berkeley) 6/11/93
* from: Id: uvm_unix.c,v 1.1.2.2 1997/08/25 18:52:30 chuck Exp
* from: NetBSD: uvm_unix.c,v 1.22 2001/05/25 04:06:18 chs Exp
* from: NetBSD: uvm_unix.c,v 1.25 2001/11/10 07:37:01 lukem Exp
*/
/*
* netbsd32_core.c: Support for the historic NetBSD core file format,
* 32-bit version.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_uvm_unix.c,v 1.3 2001/11/13 02:09:10 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: netbsd32_core.c,v 1.1 2001/12/08 00:35:27 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/vnode.h>
#include <sys/core.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
#include <uvm/uvm.h>
/*
* uvm_coredump32: dump 32-bit core!
*/
int
uvm_coredump32(p, vp, cred, chdr)
struct proc *p;
struct vnode *vp;
struct ucred *cred;
struct core32 *chdr;
coredump_netbsd32(struct proc *p, struct vnode *vp, struct ucred *cred)
{
struct core32 core;
struct coreseg32 cseg;
struct vmspace *vm = p->p_vmspace;
struct vm_map *map = &vm->vm_map;
struct vm_map_entry *entry;
vaddr_t start, end, maxstack;
struct coreseg32 cseg;
off_t offset;
int flag, error = 0;
int flag, error;
offset = chdr->c_hdrsize + chdr->c_seghdrsize + chdr->c_cpusize;
core.c_midmag = 0;
strncpy(core.c_name, p->p_comm, MAXCOMLEN);
core.c_nseg = 0;
core.c_signo = p->p_sigctx.ps_sig;
core.c_ucode = p->p_sigctx.ps_code;
core.c_cpusize = 0;
core.c_tsize = (u_long)ctob(vm->vm_tsize);
core.c_dsize = (u_long)ctob(vm->vm_dsize);
core.c_ssize = (u_long)round_page(ctob(vm->vm_ssize));
error = cpu_coredump(p, vp, cred, &core);
if (error)
return (error);
#if 0
/*
* XXX
* It would be nice if we at least dumped the signal state (and made it
* available at run time to the debugger, as well), but this code
* hasn't actually had any effect for a long time, since we don't dump
* the user area. For now, it's dead.
*/
#endif
offset = core.c_hdrsize + core.c_seghdrsize + core.c_cpusize;
maxstack = trunc_page(USRSTACK - ctob(vm->vm_ssize));
for (entry = map->header.next; entry != &map->header;
entry = entry->next) {
entry = entry->next) {
/* Should never happen for a user process. */
if (UVM_ET_ISSUBMAP(entry))
panic("coredump_netbsd: user process with submap?");
/* should never happen for a user process */
if (UVM_ET_ISSUBMAP(entry)) {
panic("uvm_coredump: user process with submap?");
}
if (!(entry->protection & VM_PROT_WRITE))
if ((entry->protection & VM_PROT_WRITE) == 0)
continue;
start = entry->start;
@ -106,7 +120,8 @@ uvm_coredump32(p, vp, cred, chdr)
if (start >= (vaddr_t)vm->vm_maxsaddr) {
if (end <= maxstack)
continue;
if (start < maxstack) start = maxstack;
if (start < maxstack)
start = maxstack;
flag = CORE_STACK;
} else
flag = CORE_DATA;
@ -114,28 +129,33 @@ uvm_coredump32(p, vp, cred, chdr)
/*
* Set up a new core file segment.
*/
CORE_SETMAGIC(cseg, CORESEGMAGIC, CORE_GETMID(*chdr), flag);
CORE_SETMAGIC(cseg, CORESEGMAGIC, CORE_GETMID(core), flag);
cseg.c_addr = start;
cseg.c_size = end - start;
error = vn_rdwr(UIO_WRITE, vp,
(caddr_t)&cseg, chdr->c_seghdrsize,
(caddr_t)&cseg, core.c_seghdrsize,
offset, UIO_SYSSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
break;
return (error);
offset += chdr->c_seghdrsize;
offset += core.c_seghdrsize;
error = vn_rdwr(UIO_WRITE, vp,
(caddr_t)(u_long)cseg.c_addr, (int)cseg.c_size,
(caddr_t)cseg.c_addr, (int)cseg.c_size,
offset, UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
break;
return (error);
offset += cseg.c_size;
chdr->c_nseg++;
core.c_nseg++;
}
/* Now write out the core header. */
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&core,
(int)core.c_hdrsize, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p);
return (error);
}

View File

@ -1,111 +0,0 @@
/* $NetBSD: netbsd32_kern_sig.c,v 1.2 2001/11/13 02:09:06 lukem Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
* All or some portions of this file are derived from material licensed
* to the University of California by American Telephone and Telegraph
* Co. or Unix System Laboratories, Inc. and are reproduced herein with
* the permission of UNIX System Laboratories, Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)kern_sig.c 8.14 (Berkeley) 5/14/95
* from: NetBSD: kern_sig.c,v 1.112 2001/02/26 21:58:30 lukem Exp
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: netbsd32_kern_sig.c,v 1.2 2001/11/13 02:09:06 lukem Exp $");
#include <sys/param.h>
#include <sys/namei.h>
#include <sys/vnode.h>
#include <sys/proc.h>
#include <sys/core.h>
#include <sys/fcntl.h>
#include <uvm/uvm_extern.h>
#include <compat/netbsd32/netbsd32.h>
/*
* Same as coredump, but generates a 32-bit image.
*/
int
coredump32(struct proc *p, struct vnode *vp)
{
struct vmspace *vm;
struct ucred *cred;
int error, error1;
struct core32 core;
vm = p->p_vmspace;
cred = p->p_cred->pc_ucred;
#if 0
/*
* XXX
* It would be nice if we at least dumped the signal state (and made it
* available at run time to the debugger, as well), but this code
* hasn't actually had any effect for a long time, since we don't dump
* the user area. For now, it's dead.
*/
memcpy(&p->p_addr->u_kproc.kp_proc, p, sizeof(struct proc));
fill_eproc(p, &p->p_addr->u_kproc.kp_eproc);
#endif
core.c_midmag = 0;
strncpy(core.c_name, p->p_comm, MAXCOMLEN);
core.c_nseg = 0;
core.c_signo = p->p_sigctx.ps_sig;
core.c_ucode = p->p_sigctx.ps_code;
core.c_cpusize = 0;
core.c_tsize = (u_long)ctob(vm->vm_tsize);
core.c_dsize = (u_long)ctob(vm->vm_dsize);
core.c_ssize = (u_long)round_page(ctob(vm->vm_ssize));
error = cpu_coredump32(p, vp, cred, &core);
if (error)
goto out;
/*
* uvm_coredump() spits out all appropriate segments.
* All that's left to do is to write the core header.
*/
error = uvm_coredump32(p, vp, cred, &core);
if (error)
goto out;
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&core,
(int)core.c_hdrsize, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p);
out:
VOP_UNLOCK(vp, 0);
error1 = vn_close(vp, FWRITE, cred, p);
if (error == 0)
error = error1;
return (error);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files,v 1.480 2001/12/05 14:50:13 augustss Exp $
# $NetBSD: files,v 1.481 2001/12/08 00:35:28 thorpej Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@ -1010,6 +1010,7 @@ file isofs/cd9660/cd9660_rrip.c cd9660
file isofs/cd9660/cd9660_util.c cd9660
file isofs/cd9660/cd9660_vfsops.c cd9660
file isofs/cd9660/cd9660_vnops.c cd9660
file kern/core_netbsd.c
file kern/cnmagic.c
file kern/exec_aout.c exec_aout
file kern/exec_conf.c

162
sys/kern/core_netbsd.c Normal file
View File

@ -0,0 +1,162 @@
/* $NetBSD: core_netbsd.c,v 1.1 2001/12/08 00:35:29 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
* Copyright (c) 1991, 1993 The Regents of the University of California.
* Copyright (c) 1988 University of Utah.
*
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Charles D. Cranor,
* Washington University, the University of California, Berkeley and
* its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah $Hdr: vm_unix.c 1.1 89/11/07$
* @(#)vm_unix.c 8.1 (Berkeley) 6/11/93
* from: NetBSD: uvm_unix.c,v 1.25 2001/11/10 07:37:01 lukem Exp
*/
/*
* core_netbsd.c: Support for the historic NetBSD core file format.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: core_netbsd.c,v 1.1 2001/12/08 00:35:29 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <sys/core.h>
#include <uvm/uvm.h>
int
coredump_netbsd(struct proc *p, struct vnode *vp, struct ucred *cred)
{
struct core core;
struct coreseg cseg;
struct vmspace *vm = p->p_vmspace;
struct vm_map *map = &vm->vm_map;
struct vm_map_entry *entry;
vaddr_t start, end, maxstack;
off_t offset;
int flag, error;
core.c_midmag = 0;
strncpy(core.c_name, p->p_comm, MAXCOMLEN);
core.c_nseg = 0;
core.c_signo = p->p_sigctx.ps_sig;
core.c_ucode = p->p_sigctx.ps_code;
core.c_cpusize = 0;
core.c_tsize = (u_long)ctob(vm->vm_tsize);
core.c_dsize = (u_long)ctob(vm->vm_dsize);
core.c_ssize = (u_long)round_page(ctob(vm->vm_ssize));
error = cpu_coredump(p, vp, cred, &core);
if (error)
return (error);
#if 0
/*
* XXX
* It would be nice if we at least dumped the signal state (and made it
* available at run time to the debugger, as well), but this code
* hasn't actually had any effect for a long time, since we don't dump
* the user area. For now, it's dead.
*/
memcpy(&p->p_addr->u_kproc.kp_proc, p, sizeof(struct proc));
fill_eproc(p, &p->p_addr->u_kproc.kp_eproc);
#endif
offset = core.c_hdrsize + core.c_seghdrsize + core.c_cpusize;
maxstack = trunc_page(USRSTACK - ctob(vm->vm_ssize));
for (entry = map->header.next; entry != &map->header;
entry = entry->next) {
/* Should never happen for a user process. */
if (UVM_ET_ISSUBMAP(entry))
panic("coredump_netbsd: user process with submap?");
if ((entry->protection & VM_PROT_WRITE) == 0)
continue;
start = entry->start;
end = entry->end;
if (start >= VM_MAXUSER_ADDRESS)
continue;
if (end > VM_MAXUSER_ADDRESS)
end = VM_MAXUSER_ADDRESS;
if (start >= (vaddr_t)vm->vm_maxsaddr) {
if (end <= maxstack)
continue;
if (start < maxstack)
start = maxstack;
flag = CORE_STACK;
} else
flag = CORE_DATA;
/*
* Set up a new core file segment.
*/
CORE_SETMAGIC(cseg, CORESEGMAGIC, CORE_GETMID(core), flag);
cseg.c_addr = start;
cseg.c_size = end - start;
error = vn_rdwr(UIO_WRITE, vp,
(caddr_t)&cseg, core.c_seghdrsize,
offset, UIO_SYSSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
return (error);
offset += core.c_seghdrsize;
error = vn_rdwr(UIO_WRITE, vp,
(caddr_t)cseg.c_addr, (int)cseg.c_size,
offset, UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
return (error);
offset += cseg.c_size;
core.c_nseg++;
}
/* Now write out the core header. */
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&core,
(int)core.c_hdrsize, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec_conf.c,v 1.62 2001/11/28 11:45:36 manu Exp $ */
/* $NetBSD: exec_conf.c,v 1.63 2001/12/08 00:35:30 thorpej Exp $ */
/*
* Copyright (c) 1993, 1994 Christopher G. Demetriou
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: exec_conf.c,v 1.62 2001/11/28 11:45:36 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: exec_conf.c,v 1.63 2001/12/08 00:35:30 thorpej Exp $");
#include "opt_execfmt.h"
#include "opt_compat_freebsd.h"
@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: exec_conf.c,v 1.62 2001/11/28 11:45:36 manu Exp $");
#include <sys/param.h>
#include <sys/exec.h>
#include <sys/signalvar.h>
#ifdef EXEC_SCRIPT
#include <sys/exec_script.h>
@ -168,199 +169,411 @@ extern const struct emul emul_netbsd_aoutm68k;
const struct execsw execsw_builtin[] = {
#ifdef EXEC_SCRIPT
{ MAXINTERP, exec_script_makecmds, { NULL },
NULL, EXECSW_PRIO_ANY, }, /* shell scripts */
#endif
/* Shell scripts */
{ MAXINTERP,
exec_script_makecmds,
{ NULL },
NULL,
EXECSW_PRIO_ANY, },
#endif /* EXEC_SCRIPT */
#ifdef EXEC_AOUT
#ifdef COMPAT_NETBSD32
{ sizeof(struct netbsd32_exec), exec_netbsd32_makecmds, { NULL },
&emul_netbsd32, EXECSW_PRIO_FIRST,
0, netbsd32_copyargs, NULL }, /* sparc 32 bit */
/* 32-bit NetBSD a.out on 64-bit */
{ sizeof(struct netbsd32_exec),
exec_netbsd32_makecmds,
{ NULL },
&emul_netbsd32,
EXECSW_PRIO_FIRST,
0,
netbsd32_copyargs,
NULL,
coredump_netbsd32 },
#endif
{ sizeof(struct exec), exec_aout_makecmds, { NULL },
/* Native a.out */
{ sizeof(struct exec),
exec_aout_makecmds,
{ NULL },
#ifdef COMPAT_AOUT
&emul_netbsd_aout,
#elif defined(COMPAT_AOUT_M68K)
&emul_netbsd_aoutm68k,
#else
&emul_netbsd,
#endif /* COMPAT_AOUT */
#endif
EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* a.out binaries */
#endif
0,
copyargs,
NULL,
coredump_netbsd },
#endif /* EXEC_AOUT */
#ifdef EXEC_COFF
{ COFF_HDR_SIZE, exec_coff_makecmds, { NULL },
&emul_netbsd, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* coff binaries */
#endif
/* Native COFF */
{ COFF_HDR_SIZE,
exec_coff_makecmds,
{ NULL },
&emul_netbsd,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif /* EXEC_COFF */
#ifdef EXEC_ECOFF
#ifdef COMPAT_OSF1
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds,
/* OSF/1 (Digital Unix) ECOFF */
{ ECOFF_HDR_SIZE,
exec_ecoff_makecmds,
{ .ecoff_probe_func = osf1_exec_ecoff_probe },
&emul_osf1, EXECSW_PRIO_ANY,
&emul_osf1,
EXECSW_PRIO_ANY,
howmany(OSF1_MAX_AUX_ENTRIES * sizeof (struct osf1_auxv) +
2 * (MAXPATHLEN + 1), sizeof (char *)), /* exec & loader names */
osf1_copyargs, cpu_exec_ecoff_setregs }, /* OSF1 ecoff binaries */
#endif /* COMPAT_OSF1 */
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds,
osf1_copyargs,
cpu_exec_ecoff_setregs,
coredump_netbsd },
#endif
/* Native ECOFF */
{ ECOFF_HDR_SIZE,
exec_ecoff_makecmds,
{ .ecoff_probe_func = cpu_exec_ecoff_probe },
&emul_netbsd, EXECSW_PRIO_ANY,
0, copyargs, cpu_exec_ecoff_setregs }, /* ecoff binaries */
&emul_netbsd,
EXECSW_PRIO_ANY,
0,
copyargs,
cpu_exec_ecoff_setregs,
coredump_netbsd},
#ifdef COMPAT_ULTRIX
{ ECOFF_HDR_SIZE, exec_ecoff_makecmds,
/* Ultrix ECOFF */
{ ECOFF_HDR_SIZE,
exec_ecoff_makecmds,
{ .ecoff_probe_func = ultrix_exec_ecoff_probe },
&emul_ultrix, EXECSW_PRIO_LAST, /* XXX probe func alw. succeeds */
0, copyargs, cpu_exec_ecoff_setregs }, /* Ultrix ecoff binaries */
#endif /* COMPAT_ULTRIX */
&emul_ultrix,
EXECSW_PRIO_LAST, /* XXX probe func alw. succeeds */
0,
copyargs,
cpu_exec_ecoff_setregs,
coredump_netbsd },
#endif
#endif /* EXEC_ECOFF */
#ifdef EXEC_ELF32
/* 32bit ELF bins */
#ifdef COMPAT_NETBSD32
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* Elf32 NetBSD on 64-bit */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(netbsd32,probe) },
&emul_netbsd32, EXECSW_PRIO_FIRST,
&emul_netbsd32,
EXECSW_PRIO_FIRST,
howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
netbsd32_elf32_copyargs, NULL }, /* NetBSD32 32bit ELF bins */
/* This one should go first so it matches instead of netbsd */
netbsd32_elf32_copyargs,
NULL,
coredump_netbsd32 },
/* This one should go first so it matches instead of native */
#endif
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* Native Elf32 */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(netbsd,probe) },
&emul_netbsd, EXECSW_PRIO_ANY,
&emul_netbsd,
EXECSW_PRIO_ANY,
howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
elf32_copyargs, NULL }, /* NetBSD 32bit ELF bins */
elf32_copyargs,
NULL,
coredump_netbsd },
#ifdef COMPAT_FREEBSD
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* FreeBSD Elf32 (probe not 64-bit safe) */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(freebsd,probe) },
&emul_freebsd, EXECSW_PRIO_ANY,
&emul_freebsd,
EXECSW_PRIO_ANY,
FREEBSD_ELF_AUX_ARGSIZ,
elf32_copyargs, NULL }, /* FreeBSD 32bit ELF bins (not 64bit safe )*/
elf32_copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_LINUX
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* Linux Elf32 */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(linux,probe) },
&emul_linux, EXECSW_PRIO_ANY,
&emul_linux,
EXECSW_PRIO_ANY,
LINUX_ELF_AUX_ARGSIZ,
LINUX_COPYARGS_FUNCTION, NULL }, /* Linux 32bit ELF bins */
#endif
#if defined(EXEC_MACHO) && defined(COMPAT_MACH)
{ sizeof (struct exec_macho_fat_header), exec_macho_makecmds,
{ .mach_probe_func = exec_mach_probe },
&emul_mach, EXECSW_PRIO_ANY,
MAXPATHLEN + 1,
exec_mach_copyargs, NULL }, /* Mach 32bit MACH-O bins */
LINUX_COPYARGS_FUNCTION,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_IRIX
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* IRIX Elf32 (o32 ABI) */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(irix,probe) },
&emul_irix, EXECSW_PRIO_ANY,
&emul_irix,
EXECSW_PRIO_ANY,
IRIX_AUX_ARGSIZ,
irix_elf32_copyargs, NULL }, /* IRIX o32 ELF bins */
irix_elf32_copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_SVR4_32
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* SVR4 Elf32 on 64-bit */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(svr4_32,probe) },
&emul_svr4_32, EXECSW_PRIO_ANY,
&emul_svr4_32,
EXECSW_PRIO_ANY,
SVR4_32_AUX_ARGSIZ,
svr4_32_copyargs, NULL }, /* SVR4 32bit ELF bins (not 64bit safe) */
svr4_32_copyargs,
NULL,
coredump_netbsd32 },
/* This one should go first so it matches instead of native */
#endif
#ifdef COMPAT_SVR4
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* SVR4 Elf32 */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(svr4,probe) },
&emul_svr4, EXECSW_PRIO_ANY,
&emul_svr4,
EXECSW_PRIO_ANY,
SVR4_AUX_ARGSIZ,
svr4_copyargs, NULL }, /* SVR4 32bit ELF bins (not 64bit safe) */
svr4_copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_IBCS2
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds,
/* SCO Elf32 */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ ELF32NAME2(ibcs2,probe) },
&emul_ibcs2, EXECSW_PRIO_ANY,
IBCS2_ELF_AUX_ARGSIZ, elf32_copyargs, NULL },
/* SCO 32bit ELF bins (not 64bit safe) */
&emul_ibcs2,
EXECSW_PRIO_ANY,
IBCS2_ELF_AUX_ARGSIZ,
elf32_copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef EXEC_ELF_CATCHALL
{ sizeof (Elf32_Ehdr), exec_elf32_makecmds, { NULL },
&emul_netbsd, EXECSW_PRIO_LAST,
/* Generic Elf32 -- run at NetBSD Elf32 */
{ sizeof (Elf32_Ehdr),
exec_elf32_makecmds,
{ NULL },
&emul_netbsd,
EXECSW_PRIO_LAST,
howmany(ELF_AUX_ENTRIES * sizeof(Aux32Info), sizeof (Elf32_Addr)),
elf32_copyargs, NULL }, /* catch all - run as NetBSD 32bit ELF */
elf32_copyargs,
NULL,
coredump_netbsd },
#endif
#endif /* EXEC_ELF32 */
#ifdef EXEC_ELF64
/* 64bit ELF bins */
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds,
/* Native Elf64 */
{ sizeof (Elf64_Ehdr),
exec_elf64_makecmds,
{ ELF64NAME2(netbsd,probe) },
&emul_netbsd, EXECSW_PRIO_ANY,
&emul_netbsd,
EXECSW_PRIO_ANY,
howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), sizeof (Elf64_Addr)),
elf64_copyargs, NULL }, /* NetBSD 64bit ELF bins */
elf64_copyargs,
NULL,
coredump_netbsd },
#ifdef COMPAT_LINUX
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds,
/* Linux Elf64 */
{ sizeof (Elf64_Ehdr),
exec_elf64_makecmds,
{ ELF64NAME2(linux,probe) },
&emul_linux, EXECSW_PRIO_ANY,
&emul_linux,
EXECSW_PRIO_ANY,
LINUX_ELF_AUX_ARGSIZ,
linux_elf64_copyargs, NULL }, /* Linux 64bit ELF bins */
linux_elf64_copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_SVR4
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds,
/* SVR4 Elf64 */
{ sizeof (Elf64_Ehdr),
exec_elf64_makecmds,
{ ELF64NAME2(svr4,probe) },
&emul_svr4, EXECSW_PRIO_ANY,
&emul_svr4,
EXECSW_PRIO_ANY,
SVR4_AUX_ARGSIZ64,
svr4_copyargs64, NULL }, /* SVR4 64bit ELF bins (not 64bit safe) */
svr4_copyargs64,
NULL,
coredump_netbsd },
#endif
#ifdef EXEC_ELF_CATCHALL
{ sizeof (Elf64_Ehdr), exec_elf64_makecmds, { NULL },
&emul_netbsd, EXECSW_PRIO_ANY,
/* Generic Elf64 -- run at NetBSD Elf64 */
{ sizeof (Elf64_Ehdr),
exec_elf64_makecmds,
{ NULL },
&emul_netbsd,
EXECSW_PRIO_ANY,
howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), sizeof (Elf64_Addr)),
elf64_copyargs, NULL }, /* catch all - run as NetBSD 64bit ELF */
elf64_copyargs,
NULL,
coredump_netbsd },
#endif
#endif /* EXEC_ELF64 */
#if defined(EXEC_MACHO)
#ifdef COMPAT_MACH
/* Mach MACH-O (native word size) */
{ sizeof (struct exec_macho_fat_header),
exec_macho_makecmds,
{ .mach_probe_func = exec_mach_probe },
&emul_mach,
EXECSW_PRIO_ANY,
MAXPATHLEN + 1,
exec_mach_copyargs,
NULL,
coredump_netbsd },
#endif
#endif /* EXEC_MACHO */
#ifdef COMPAT_SUNOS
#ifdef COMPAT_NETBSD32
{ SUNOS32_AOUT_HDR_SIZE, exec_sunos32_aout_makecmds, { NULL },
&emul_sunos, EXECSW_PRIO_ANY,
0, netbsd32_copyargs, NULL }, /* SunOS a.out, 64-bit kernel */
/* 32-bit SunOS a.out on 64-bit */
{ SUNOS32_AOUT_HDR_SIZE,
exec_sunos32_aout_makecmds,
{ NULL },
&emul_sunos,
EXECSW_PRIO_ANY,
0,
netbsd32_copyargs,
NULL,
coredump_netbsd },
#else
{ SUNOS_AOUT_HDR_SIZE, exec_sunos_aout_makecmds, { NULL },
&emul_sunos, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* SunOS a.out */
#endif
/* SunOS a.out (native word size) */
{ SUNOS_AOUT_HDR_SIZE,
exec_sunos_aout_makecmds,
{ NULL },
&emul_sunos,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif
#endif /* COMPAT_SUNOS */
#if defined(COMPAT_LINUX) && defined(EXEC_AOUT)
{ LINUX_AOUT_HDR_SIZE, exec_linux_aout_makecmds, { NULL },
&emul_linux, EXECSW_PRIO_ANY,
LINUX_AOUT_AUX_ARGSIZ, linux_aout_copyargs, NULL }, /* linux a.out */
/* Linux a.out (native word size) */
{ LINUX_AOUT_HDR_SIZE,
exec_linux_aout_makecmds,
{ NULL },
&emul_linux,
EXECSW_PRIO_ANY,
LINUX_AOUT_AUX_ARGSIZ,
linux_aout_copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_IBCS2
{ COFF_HDR_SIZE, exec_ibcs2_coff_makecmds, { NULL },
&emul_ibcs2, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* coff binaries */
{ XOUT_HDR_SIZE, exec_ibcs2_xout_makecmds, { NULL },
&emul_ibcs2, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* x.out binaries */
/* iBCS2 COFF (native word size) */
{ COFF_HDR_SIZE,
exec_ibcs2_coff_makecmds,
{ NULL },
&emul_ibcs2,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
/* iBCS2 x.out (native word size) */
{ XOUT_HDR_SIZE,
exec_ibcs2_xout_makecmds,
{ NULL },
&emul_ibcs2,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif
#if defined(COMPAT_FREEBSD) && defined(EXEC_AOUT)
{ FREEBSD_AOUT_HDR_SIZE, exec_freebsd_aout_makecmds, { NULL },
&emul_freebsd, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* a.out */
/* FreeBSD a.out (native word size) */
{ FREEBSD_AOUT_HDR_SIZE,
exec_freebsd_aout_makecmds,
{ NULL },
&emul_freebsd,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_HPUX
{ HPUX_EXEC_HDR_SIZE, exec_hpux_makecmds, { NULL },
&emul_hpux, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* HP-UX a.out */
/* HP-UX a.out for m68k (native word size) */
{ HPUX_EXEC_HDR_SIZE,
exec_hpux_makecmds,
{ NULL },
&emul_hpux,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_M68K4K
{ sizeof(struct exec), exec_m68k4k_makecmds, { NULL },
&emul_netbsd, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* m68k4k a.out */
/* NetBSD a.out for m68k4k */
{ sizeof(struct exec),
exec_m68k4k_makecmds,
{ NULL },
&emul_netbsd,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_VAX1K
{ sizeof(struct exec), exec_vax1k_makecmds, { NULL },
&emul_netbsd, EXECSW_PRIO_ANY,
0, copyargs, NULL }, /* vax1k a.out */
/* NetBSD vax1k a.out */
{ sizeof(struct exec),
exec_vax1k_makecmds,
{ NULL },
&emul_netbsd,
EXECSW_PRIO_ANY,
0,
copyargs,
NULL,
coredump_netbsd },
#endif
#ifdef COMPAT_PECOFF
{ sizeof(struct exec), exec_pecoff_makecmds, { NULL },
&emul_netbsd, EXECSW_PRIO_ANY, /* XXX emul_pecoff once it's different */
/* Win32/WinCE PE/COFF (native word size) */
{ sizeof(struct exec),
exec_pecoff_makecmds,
{ NULL },
&emul_netbsd, /* XXX emul_pecoff once it's different */
EXECSW_PRIO_ANY,
howmany(sizeof(struct pecoff_args), sizeof(char *)),
pecoff_copyargs, NULL }, /* Win32/CE PE/COFF */
pecoff_copyargs,
NULL,
coredump_netbsd },
#endif
};
int nexecs_builtin = (sizeof(execsw_builtin) / sizeof(struct execsw));

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_exec.c,v 1.147 2001/11/23 22:02:39 jdolecek Exp $ */
/* $NetBSD: kern_exec.c,v 1.148 2001/12/08 00:35:30 thorpej Exp $ */
/*-
* Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.147 2001/11/23 22:02:39 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.148 2001/12/08 00:35:30 thorpej Exp $");
#include "opt_ktrace.h"
#include "opt_syscall_debug.h"
@ -677,6 +677,10 @@ sys_execve(struct proc *p, void *v, register_t *retval)
/* update p_emul, the old value is no longer needed */
p->p_emul = pack.ep_es->es_emul;
/* ...and the same for p_execsw */
p->p_execsw = pack.ep_es;
#ifdef __HAVE_SYSCALL_INTERN
(*p->p_emul->e_syscall_intern)(p);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_fork.c,v 1.87 2001/11/12 15:25:09 lukem Exp $ */
/* $NetBSD: kern_fork.c,v 1.88 2001/12/08 00:35:30 thorpej Exp $ */
/*-
* Copyright (c) 1999, 2001 The NetBSD Foundation, Inc.
@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.87 2001/11/12 15:25:09 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.88 2001/12/08 00:35:30 thorpej Exp $");
#include "opt_ktrace.h"
#include "opt_multiprocessor.h"
@ -283,6 +283,7 @@ fork1(struct proc *p1, int flags, int exitsig, void *stack, size_t stacksize,
*/
p2->p_flag = P_INMEM | (p1->p_flag & P_SUGID);
p2->p_emul = p1->p_emul;
p2->p_execsw = p1->p_execsw;
if (p1->p_flag & P_PROFIL)
startprofclock(p2);

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_sig.c,v 1.117 2001/12/05 07:32:24 enami Exp $ */
/* $NetBSD: kern_sig.c,v 1.118 2001/12/08 00:35:31 thorpej Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.117 2001/12/05 07:32:24 enami Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.118 2001/12/08 00:35:31 thorpej Exp $");
#include "opt_ktrace.h"
#include "opt_compat_sunos.h"
@ -69,6 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.117 2001/12/05 07:32:24 enami Exp $")
#include <sys/filedesc.h>
#include <sys/malloc.h>
#include <sys/pool.h>
#include <sys/exec.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
@ -86,8 +87,6 @@ sigset_t contsigmask, stopsigmask, sigcantmask;
struct pool sigacts_pool; /* memory pool for sigacts structures */
int (*coredump32_hook)(struct proc *p, struct vnode *vp);
/*
* Can process p, with pcred pc, send the signal signum to process q?
*/
@ -1322,7 +1321,6 @@ coredump(struct proc *p)
struct vattr vattr;
int error, error1;
char name[MAXPATHLEN];
struct core core;
vm = p->p_vmspace;
cred = p->p_cred->pc_ucred;
@ -1374,42 +1372,8 @@ coredump(struct proc *p)
VOP_SETATTR(vp, &vattr, cred, p);
p->p_acflag |= ACORE;
if ((p->p_flag & P_32) && coredump32_hook != NULL)
return (*coredump32_hook)(p, vp);
#if 0
/*
* XXX
* It would be nice if we at least dumped the signal state (and made it
* available at run time to the debugger, as well), but this code
* hasn't actually had any effect for a long time, since we don't dump
* the user area. For now, it's dead.
*/
memcpy(&p->p_addr->u_kproc.kp_proc, p, sizeof(struct proc));
fill_eproc(p, &p->p_addr->u_kproc.kp_eproc);
#endif
core.c_midmag = 0;
strncpy(core.c_name, p->p_comm, MAXCOMLEN);
core.c_nseg = 0;
core.c_signo = p->p_sigctx.ps_sig;
core.c_ucode = p->p_sigctx.ps_code;
core.c_cpusize = 0;
core.c_tsize = (u_long)ctob(vm->vm_tsize);
core.c_dsize = (u_long)ctob(vm->vm_dsize);
core.c_ssize = (u_long)round_page(ctob(vm->vm_ssize));
error = cpu_coredump(p, vp, cred, &core);
if (error)
goto out;
/*
* uvm_coredump() spits out all appropriate segments.
* All that's left to do is to write the core header.
*/
error = uvm_coredump(p, vp, cred, &core);
if (error)
goto out;
error = vn_rdwr(UIO_WRITE, vp, (caddr_t)&core,
(int)core.c_hdrsize, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, NULL, p);
/* Now dump the actual core file. */
error = (*p->p_execsw->es_coredump)(p, vp, cred);
out:
VOP_UNLOCK(vp, 0);
error1 = vn_close(vp, FWRITE, cred, p);

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.h,v 1.81 2001/07/29 21:23:19 christos Exp $ */
/* $NetBSD: exec.h,v 1.82 2001/12/08 00:35:32 thorpej Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@ -101,6 +101,8 @@ struct ps_strings {
struct proc;
struct exec_package;
struct vnode;
struct ucred;
typedef int (*exec_makecmds_fcn) __P((struct proc *, struct exec_package *));
@ -123,6 +125,8 @@ struct execsw {
/* Set registers before execution */
void (*es_setregs) __P((struct proc *, struct exec_package *,
u_long));
int (*es_coredump) __P((struct proc *, struct vnode *,
struct ucred *));
};
#define EXECSW_PRIO_ANY 0x000 /* default, no preference */

View File

@ -1,4 +1,4 @@
/* $NetBSD: proc.h,v 1.134 2001/09/18 19:36:32 jdolecek Exp $ */
/* $NetBSD: proc.h,v 1.135 2001/12/08 00:35:32 thorpej Exp $ */
/*-
* Copyright (c) 1986, 1989, 1991, 1993
@ -208,6 +208,7 @@ struct proc {
* Per-process emulation data, or NULL.
* Malloc type M_EMULDATA
*/
const struct execsw *p_execsw; /* Exec package information */
/*
* End area that is zeroed on creation

View File

@ -1,4 +1,4 @@
/* $NetBSD: signalvar.h,v 1.30 2001/06/06 21:46:59 mrg Exp $ */
/* $NetBSD: signalvar.h,v 1.31 2001/12/08 00:35:33 thorpej Exp $ */
/*
* Copyright (c) 1991, 1993
@ -163,17 +163,15 @@ const int sigprop[NSIG] = {
extern sigset_t contsigmask, stopsigmask, sigcantmask;
/*
* Set if we need to short-cut coredump() with the 32-bit version
* on a 64-bit platform.
*/
struct vnode;
extern int (*coredump32_hook)(struct proc *p, struct vnode *vp);
struct ucred;
/*
* Machine-independent functions:
*/
int coredump __P((struct proc *p));
int coredump_netbsd __P((struct proc *p, struct vnode *vp,
struct ucred *cred));
void execsigs __P((struct proc *p));
void gsignal __P((int pgid, int sig));
int issignal __P((struct proc *p));
@ -210,8 +208,6 @@ void sigactsfree __P((struct proc *));
void sendsig __P((sig_t action, int sig, sigset_t *returnmask, u_long code));
struct core;
struct core32;
struct vnode;
struct ucred;
int cpu_coredump __P((struct proc *, struct vnode *, struct ucred *,
struct core *));
int cpu_coredump32 __P((struct proc *, struct vnode *, struct ucred *,

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_extern.h,v 1.67 2001/09/15 20:36:45 chs Exp $ */
/* $NetBSD: uvm_extern.h,v 1.68 2001/12/08 00:35:33 thorpej Exp $ */
/*
*
@ -647,13 +647,7 @@ void uvm_pglistfree __P((struct pglist *));
void uvm_swap_init __P((void));
/* uvm_unix.c */
int uvm_coredump __P((struct proc *, struct vnode *,
struct ucred *, struct core *));
int uvm_grow __P((struct proc *, vaddr_t));
/* should only be needed if COMPAT_NETBSD32 is defined */
struct core32;
int uvm_coredump32 __P((struct proc *, struct vnode *,
struct ucred *, struct core32 *));
/* uvm_user.c */
void uvm_deallocate __P((struct vm_map *, vaddr_t, vsize_t));

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_unix.c,v 1.25 2001/11/10 07:37:01 lukem Exp $ */
/* $NetBSD: uvm_unix.c,v 1.26 2001/12/08 00:35:34 thorpej Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -50,14 +50,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_unix.c,v 1.25 2001/11/10 07:37:01 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_unix.c,v 1.26 2001/12/08 00:35:34 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
#include <sys/vnode.h>
#include <sys/core.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
@ -166,83 +165,3 @@ sys_ovadvise(p, v, retval)
return (EINVAL);
}
/*
* uvm_coredump: dump core!
*/
int
uvm_coredump(p, vp, cred, chdr)
struct proc *p;
struct vnode *vp;
struct ucred *cred;
struct core *chdr;
{
struct vmspace *vm = p->p_vmspace;
struct vm_map *map = &vm->vm_map;
struct vm_map_entry *entry;
vaddr_t start, end, maxstack;
struct coreseg cseg;
off_t offset;
int flag, error = 0;
offset = chdr->c_hdrsize + chdr->c_seghdrsize + chdr->c_cpusize;
maxstack = trunc_page(USRSTACK - ctob(vm->vm_ssize));
for (entry = map->header.next; entry != &map->header;
entry = entry->next) {
/* should never happen for a user process */
if (UVM_ET_ISSUBMAP(entry)) {
panic("uvm_coredump: user process with submap?");
}
if (!(entry->protection & VM_PROT_WRITE))
continue;
start = entry->start;
end = entry->end;
if (start >= VM_MAXUSER_ADDRESS)
continue;
if (end > VM_MAXUSER_ADDRESS)
end = VM_MAXUSER_ADDRESS;
if (start >= (vaddr_t)vm->vm_maxsaddr) {
if (end <= maxstack)
continue;
if (start < maxstack)
start = maxstack;
flag = CORE_STACK;
} else
flag = CORE_DATA;
/*
* Set up a new core file segment.
*/
CORE_SETMAGIC(cseg, CORESEGMAGIC, CORE_GETMID(*chdr), flag);
cseg.c_addr = start;
cseg.c_size = end - start;
error = vn_rdwr(UIO_WRITE, vp,
(caddr_t)&cseg, chdr->c_seghdrsize,
offset, UIO_SYSSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
break;
offset += chdr->c_seghdrsize;
error = vn_rdwr(UIO_WRITE, vp,
(caddr_t)cseg.c_addr, (int)cseg.c_size,
offset, UIO_USERSPACE,
IO_NODELOCKED|IO_UNIT, cred, NULL, p);
if (error)
break;
offset += cseg.c_size;
chdr->c_nseg++;
}
return (error);
}