xref: /netbsd-src/share/man/man5/core.5 (revision 4472dbe5e3bd91ef2540bada7a7ca7384627ff9b)
1.\"	$NetBSD: core.5,v 1.11 1999/10/10 15:17:43 jdolecek Exp $
2.\"
3.\" Copyright (c) 1980, 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\"     @(#)core.5	8.3 (Berkeley) 12/11/93
35.\"
36.Dd December 11, 1993
37.Dt CORE 5
38.Os
39.Sh NAME
40.Nm core
41.Nd memory image file format
42.Sh SYNOPSIS
43.Fd #include <sys/param.h>
44.Sh DESCRIPTION
45A small number of signals which cause abnormal termination of a process
46also cause a record of the process's in-core state to be written
47to disk for later examination by one of the available debuggers
48(see
49.Xr signal 7 ).
50This memory image is written to a file named from a per-process template;
51provided the terminated process had write permission, and provided the
52abnormality did not cause a system crash.
53(In this event, the decision to save the core file is arbitrary, see
54.Xr savecore 8 . )
55The file is named from a per-process template, mapped to the sysctl
56variable
57.Em proc.<pid>.corename
58(where <pid> has to be replaced by the pid in decimal format of the
59process).
60This template is either an absolute or relative path name, in which format
61characters can be used, preceeded by the percent character (``%'').
62The following characters are recognised as format and subsitued:
63.Bl -column "cAA" "The process's creation date (in seconds)xxx" -offset indent
64.It Li n        The process's name
65.It Li p        The PID of the process (in decimal)
66.It Li t        The process's creation date (a la
67.Xr time 3 ,
68in decimal)
69.It Li u        The login name, as returned by
70.Xr getlogin 2
71.El
72.Pp
73By default, the per-process template string points to the default core name
74template, which is mapped to the sysctl variable
75.Em kern.defcorename .
76Changing this value on a live system will change the core name template for
77all processes which didn't have a per-process template set.
78The default value of the default core name template is
79.Nm %n.core
80and can be changed at compile-time with the kernel configuration option
81.Cd options DEFCORENAME
82(see
83.Xr options 4 )
84.Pp
85The per-process template string is inherited on process creation, but is reset
86to point to the default core name template on execution of a set-id binary.
87.Pp
88The maximum size of a core file is limited by
89.Xr setrlimit 2 .
90Files which would be larger than the limit are not created.
91.Pp
92The core file consists of the
93.Fa u. area ,
94whose size (in pages) is defined by the
95.Dv UPAGES
96manifest in the
97.Aq Pa sys/param.h
98file.  The
99.Fa u. area
100starts with a
101.Fa user
102structure as given in
103.Aq Pa sys/user.h .
104The remainder of the core file consists of the data pages followed by
105the stack pages of the process image.
106The amount of data space image in the core file is given (in pages) by the
107variable
108.Fa u_dsize
109in the
110.Fa u. area .
111The amount of stack image in the core file is given (in pages) by the
112variable
113.Fa u_ssize
114in the
115.Fa u. area .
116The size of a ``page'' is given by the constant
117.Dv NBPG
118(also from
119.Aq Pa sys/param.h ) .
120.Sh SEE ALSO
121.Xr gdb 1 ,
122.Xr setrlimit 2 ,
123.Xr sysctl 3 ,
124.Xr signal 7 ,
125.Xr sysctl 8
126.Sh HISTORY
127A
128.Nm core
129file format appeared in
130.At v6 .
131