2001-06-19 16:34:26 +04:00
|
|
|
.\" $NetBSD: core.5,v 1.14 2001/06/19 12:34:26 wiz Exp $
|
1994-11-30 22:31:07 +03:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1980, 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
1994-11-30 22:31:07 +03:00
|
|
|
.\" @(#)core.5 8.3 (Berkeley) 12/11/93
|
1993-03-21 12:45:37 +03:00
|
|
|
.\"
|
2000-10-07 21:45:26 +04:00
|
|
|
.Dd October 7, 2000
|
1993-03-21 12:45:37 +03:00
|
|
|
.Dt CORE 5
|
1999-03-17 23:19:44 +03:00
|
|
|
.Os
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh NAME
|
|
|
|
.Nm core
|
|
|
|
.Nd memory image file format
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Fd #include <sys/param.h>
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
A small number of signals which cause abnormal termination of a process
|
|
|
|
also cause a record of the process's in-core state to be written
|
1999-10-10 19:17:43 +04:00
|
|
|
to disk for later examination by one of the available debuggers
|
|
|
|
(see
|
2001-06-19 16:34:26 +04:00
|
|
|
.Xr signal 7 ) .
|
2000-11-17 13:14:16 +03:00
|
|
|
.Pp
|
1999-09-28 18:52:32 +04:00
|
|
|
This memory image is written to a file named from a per-process template;
|
|
|
|
provided the terminated process had write permission, and provided the
|
|
|
|
abnormality did not cause a system crash.
|
1993-03-21 12:45:37 +03:00
|
|
|
(In this event, the decision to save the core file is arbitrary, see
|
|
|
|
.Xr savecore 8 . )
|
1999-09-28 18:52:32 +04:00
|
|
|
The file is named from a per-process template, mapped to the sysctl
|
|
|
|
variable
|
|
|
|
.Em proc.<pid>.corename
|
1999-10-10 19:04:47 +04:00
|
|
|
(where <pid> has to be replaced by the pid in decimal format of the
|
1999-09-28 18:52:32 +04:00
|
|
|
process).
|
|
|
|
This template is either an absolute or relative path name, in which format
|
2001-06-19 16:34:26 +04:00
|
|
|
characters can be used, preceded by the percent character
|
2000-11-17 13:14:16 +03:00
|
|
|
.Pq Dq \&% .
|
2001-06-19 16:34:26 +04:00
|
|
|
The following characters are recognised as format and substituted:
|
2000-11-17 13:14:16 +03:00
|
|
|
.Bl -tag -width 4n -offset indent -compact
|
|
|
|
.It Sy n
|
|
|
|
The process's name
|
|
|
|
.It Sy p
|
2001-06-19 16:34:26 +04:00
|
|
|
The PID of the process (in decimal)
|
2000-11-17 13:14:16 +03:00
|
|
|
.It Sy t
|
|
|
|
The process's creation date (a la
|
1999-09-28 18:52:32 +04:00
|
|
|
.Xr time 3 ,
|
|
|
|
in decimal)
|
2000-11-17 13:14:16 +03:00
|
|
|
.It Sy u
|
|
|
|
The login name, as returned by
|
1999-09-28 18:52:32 +04:00
|
|
|
.Xr getlogin 2
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
By default, the per-process template string points to the default core name
|
|
|
|
template, which is mapped to the sysctl variable
|
|
|
|
.Em kern.defcorename .
|
|
|
|
Changing this value on a live system will change the core name template for
|
|
|
|
all processes which didn't have a per-process template set.
|
|
|
|
The default value of the default core name template is
|
|
|
|
.Nm %n.core
|
|
|
|
and can be changed at compile-time with the kernel configuration option
|
|
|
|
.Cd options DEFCORENAME
|
|
|
|
(see
|
|
|
|
.Xr options 4 )
|
|
|
|
.Pp
|
|
|
|
The per-process template string is inherited on process creation, but is reset
|
|
|
|
to point to the default core name template on execution of a set-id binary.
|
1993-03-21 12:45:37 +03:00
|
|
|
.Pp
|
1999-09-28 18:52:32 +04:00
|
|
|
The maximum size of a core file is limited by
|
1993-03-21 12:45:37 +03:00
|
|
|
.Xr setrlimit 2 .
|
|
|
|
Files which would be larger than the limit are not created.
|
|
|
|
.Pp
|
2000-10-07 21:45:26 +04:00
|
|
|
The core file contains of a core header followed by a number of
|
2001-06-19 16:34:26 +04:00
|
|
|
segments. Each segment is preceded by a core segment header.
|
2000-10-07 21:45:26 +04:00
|
|
|
Both the core header and core segment header are defined in
|
|
|
|
.Aq Pa sys/core.h .
|
|
|
|
|
2001-06-19 16:34:26 +04:00
|
|
|
The core header,
|
2000-10-07 21:45:26 +04:00
|
|
|
.Fa struct core ,
|
|
|
|
specifies the lengths of the core header itself and
|
|
|
|
each of the following core segment headers to allow for any machine
|
|
|
|
dependent alignment requirements.
|
|
|
|
.Bd -literal
|
|
|
|
struct core {
|
|
|
|
u_int32_t c_midmag; /* magic, id, flags */
|
|
|
|
u_int16_t c_hdrsize; /* Size of this header (machdep algn) */
|
|
|
|
u_int16_t c_seghdrsize; /* Size of a segment header */
|
|
|
|
u_int32_t c_nseg; /* # of core segments */
|
|
|
|
char c_name[MAXCOMLEN+1]; /* Copy of p->p_comm */
|
|
|
|
u_int32_t c_signo; /* Killing signal */
|
|
|
|
u_long c_ucode; /* Signal code */
|
|
|
|
u_long c_cpusize; /* Size of machine dependent segment */
|
|
|
|
u_long c_tsize; /* Size of traditional text segment */
|
|
|
|
u_long c_dsize; /* Size of traditional data segment */
|
|
|
|
u_long c_ssize; /* Size of traditional stack segment */
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The fields of
|
|
|
|
.Fa struct core
|
|
|
|
are as follows:
|
|
|
|
.Bl -tag -width XXXc_seghdrsize
|
|
|
|
.It c_midmag
|
2001-06-19 16:34:26 +04:00
|
|
|
Core file machine ID, magic value, and flags.
|
|
|
|
These values may be extracted with the
|
2000-10-07 21:45:26 +04:00
|
|
|
.Fn CORE_GETMID ,
|
|
|
|
.Fn CORE_GETMAGIC ,
|
|
|
|
and
|
|
|
|
.Fn CORE_GETFLAG
|
2001-06-19 16:34:26 +04:00
|
|
|
macros. The machine ID values are listed in
|
2000-10-07 21:45:26 +04:00
|
|
|
.Aq Pa sys/exec_aout.h .
|
|
|
|
For a valid core file, the magic value in the header must be
|
2001-06-19 16:34:26 +04:00
|
|
|
.Dv COREMAGIC .
|
2000-10-07 21:45:26 +04:00
|
|
|
No flags are defined for the core header.
|
|
|
|
.It c_hdrsize
|
|
|
|
Size of this data structure.
|
|
|
|
.It c_seghdrsize
|
|
|
|
Size of a segment header.
|
|
|
|
.It c_nseg
|
|
|
|
Number of segments that follow this header.
|
|
|
|
.It c_name
|
2001-06-19 16:34:26 +04:00
|
|
|
Process name, copied from the p_comm field of
|
2000-10-07 21:45:26 +04:00
|
|
|
.Fa struct proc .
|
|
|
|
.It c_signo
|
|
|
|
Signal that caused the process to dump core.
|
|
|
|
.It c_ucode
|
|
|
|
Code associated with the signal.
|
|
|
|
.It c_cpusize
|
2001-06-19 16:34:26 +04:00
|
|
|
Size of the segment containing CPU-specific information.
|
2000-10-07 21:45:26 +04:00
|
|
|
This segment will have the
|
|
|
|
.Dv CORE_CPU
|
|
|
|
flag set.
|
|
|
|
.It c_tsize
|
|
|
|
Size of the segment containing the program text.
|
|
|
|
.It c_dsize
|
|
|
|
Size of the segment containing the program's traditional data area.
|
|
|
|
.It c_ssize
|
|
|
|
Size of the segment containing the program's traditional stack area.
|
|
|
|
This segment will have the
|
|
|
|
.Dv CORE_STACK
|
|
|
|
flag set.
|
|
|
|
.El
|
|
|
|
The header is followed by
|
|
|
|
.Fa c_nseg
|
|
|
|
segments, each of which is preceded with a segment header,
|
|
|
|
.Fa struct coreseg :
|
|
|
|
.Bd -literal
|
|
|
|
struct coreseg {
|
|
|
|
u_int32_t c_midmag; /* magic, id, flags */
|
|
|
|
u_long c_addr; /* Virtual address of segment */
|
|
|
|
u_long c_size; /* Size of this segment */
|
|
|
|
};
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The fields of
|
|
|
|
.Fa struct coreseg
|
|
|
|
are as follows:
|
|
|
|
.Bl -tag -width XXXc_midmag
|
|
|
|
.It c_midmag
|
|
|
|
Core segment magic value and flags.
|
2001-06-19 16:34:26 +04:00
|
|
|
These values may be extracted with the
|
2000-10-07 21:45:26 +04:00
|
|
|
.Fn CORE_GETMAGIC
|
|
|
|
and
|
|
|
|
.Fn CORE_GETFLAG
|
2001-06-19 16:34:26 +04:00
|
|
|
macros.
|
2000-10-07 21:45:26 +04:00
|
|
|
The magic value in the segment header must be
|
2001-06-19 16:34:26 +04:00
|
|
|
.Dv CORESEGMAGIC .
|
2000-10-07 21:45:26 +04:00
|
|
|
Exactly one of of the flags
|
|
|
|
.Dv CORE_CPU ,
|
2001-06-19 16:34:26 +04:00
|
|
|
.Dv CORE_DATA ,
|
2000-10-07 21:45:26 +04:00
|
|
|
or
|
|
|
|
.Dv CORE_STACK
|
|
|
|
will be set to indicate the segment type.
|
|
|
|
.It c_addr
|
2001-06-19 16:34:26 +04:00
|
|
|
Virtual address of the segment in the program image.
|
2000-10-07 21:45:26 +04:00
|
|
|
Meaningless if the segment type is
|
|
|
|
.Dv CORE_CPU .
|
|
|
|
.It c_size
|
|
|
|
Size of the segment, not including this header.
|
|
|
|
.El
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr gdb 1 ,
|
1999-10-10 19:17:43 +04:00
|
|
|
.Xr setrlimit 2 ,
|
1999-09-28 18:52:32 +04:00
|
|
|
.Xr sysctl 3 ,
|
1999-10-10 19:17:43 +04:00
|
|
|
.Xr signal 7 ,
|
1999-09-28 18:52:32 +04:00
|
|
|
.Xr sysctl 8
|
1993-03-21 12:45:37 +03:00
|
|
|
.Sh HISTORY
|
|
|
|
A
|
1994-11-30 22:31:07 +03:00
|
|
|
.Nm core
|
1993-03-21 12:45:37 +03:00
|
|
|
file format appeared in
|
|
|
|
.At v6 .
|
2000-10-07 21:45:26 +04:00
|
|
|
.Sh BUGS
|
|
|
|
There is no standard location or name for the
|
2001-06-19 16:34:26 +04:00
|
|
|
CPU-dependent data structure stored in the
|
2000-10-07 21:45:26 +04:00
|
|
|
.Dv CORE_CPU
|
|
|
|
segment.
|