1afe61c15SRodney W. Grimes.\" Copyright (c) 1980, 1991, 1993 2afe61c15SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 3afe61c15SRodney W. Grimes.\" 4afe61c15SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 5afe61c15SRodney W. Grimes.\" modification, are permitted provided that the following conditions 6afe61c15SRodney W. Grimes.\" are met: 7afe61c15SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 8afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 9afe61c15SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 10afe61c15SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 11afe61c15SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 12dda5b397SEitan Adler.\" 3. Neither the name of the University nor the names of its contributors 13afe61c15SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 14afe61c15SRodney W. Grimes.\" without specific prior written permission. 15afe61c15SRodney W. Grimes.\" 16afe61c15SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17afe61c15SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18afe61c15SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19afe61c15SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20afe61c15SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21afe61c15SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22afe61c15SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23afe61c15SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24afe61c15SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25afe61c15SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26afe61c15SRodney W. Grimes.\" SUCH DAMAGE. 27afe61c15SRodney W. Grimes.\" 28afe61c15SRodney W. Grimes.\" @(#)core.5 8.3 (Berkeley) 12/11/93 297f3dea24SPeter Wemm.\" $FreeBSD$ 30afe61c15SRodney W. Grimes.\" 316026dcd7SMark Johnston.Dd February 13, 2018 32afe61c15SRodney W. Grimes.Dt CORE 5 333d45e180SRuslan Ermilov.Os 34afe61c15SRodney W. Grimes.Sh NAME 35afe61c15SRodney W. Grimes.Nm core 36afe61c15SRodney W. Grimes.Nd memory image file format 37afe61c15SRodney W. Grimes.Sh SYNOPSIS 3832eef9aeSRuslan Ermilov.In sys/param.h 39afe61c15SRodney W. Grimes.Sh DESCRIPTION 40afe61c15SRodney W. GrimesA small number of signals which cause abnormal termination of a process 41afe61c15SRodney W. Grimesalso cause a record of the process's in-core state to be written 42afe61c15SRodney W. Grimesto disk for later examination by one of the available debuggers. 43afe61c15SRodney W. Grimes(See 44afe61c15SRodney W. Grimes.Xr sigaction 2 . ) 45aa81f3a9SJoerg WunschThis memory image is written to a file named by default 46afe61c15SRodney W. Grimes.Nm programname.core 47afe61c15SRodney W. Grimesin the working directory; 48afe61c15SRodney W. Grimesprovided the terminated process had write permission in the directory, 49afe61c15SRodney W. Grimesand provided the abnormality did not cause 50afe61c15SRodney W. Grimesa system crash. 51afe61c15SRodney W. Grimes(In this event, the decision to save the core file is arbitrary, see 52afe61c15SRodney W. Grimes.Xr savecore 8 . ) 53afe61c15SRodney W. Grimes.Pp 54aa81f3a9SJoerg WunschThe maximum size of a core file is limited by 55afe61c15SRodney W. Grimes.Xr setrlimit 2 . 56afe61c15SRodney W. GrimesFiles which would be larger than the limit are not created. 57afe61c15SRodney W. Grimes.Pp 58aa81f3a9SJoerg WunschThe name of the file is controlled via the 59aa81f3a9SJoerg Wunsch.Xr sysctl 8 60aa81f3a9SJoerg Wunschvariable 61aa81f3a9SJoerg Wunsch.Va kern.corefile . 62aa81f3a9SJoerg WunschThe contents of this variable describes a filename to store 630f3ac37eSRuslan Ermilovthe core image to. 640f3ac37eSRuslan ErmilovThis filename can be absolute, or relative (which 65aa81f3a9SJoerg Wunschwill resolve to the current working directory of the program 660f3ac37eSRuslan Ermilovgenerating it). 670dce12b8SAlfred Perlstein.Pp 680dce12b8SAlfred PerlsteinThe following format specifiers may be used in the 690dce12b8SAlfred Perlstein.Va kern.corefile 7078f57a9cSMark Johnstonsysctl to insert additional information into the resulting core 7178f57a9cSMark Johnstonfilename: 720dce12b8SAlfred Perlstein.Bl -tag -width "1234567890" -compact -offset "12345" 730dce12b8SAlfred Perlstein.It Em \&%H 740dce12b8SAlfred PerlsteinMachine hostname. 750dce12b8SAlfred Perlstein.It Em \&%I 760dce12b8SAlfred PerlsteinAn index starting at zero until the sysctl 77df4193e7SSergey Kandaurov.Em debug.ncores 78da9782daSSergey Kandaurovis reached. 79da9782daSSergey KandaurovThis can be useful for limiting the number of corefiles 800dce12b8SAlfred Perlsteingenerated by a particular process. 810dce12b8SAlfred Perlstein.It Em \&%N 820dce12b8SAlfred Perlsteinprocess name. 830dce12b8SAlfred Perlstein.It Em \&%P 840dce12b8SAlfred Perlsteinprocesses PID. 85*9d3ecb7eSEric van Gyzen.It Em \&%S 86*9d3ecb7eSEric van Gyzensignal during core. 870dce12b8SAlfred Perlstein.It Em \&%U 880dce12b8SAlfred Perlsteinprocess UID. 890dce12b8SAlfred Perlstein.El 900dce12b8SAlfred Perlstein.Pp 910f3ac37eSRuslan ErmilovThe name defaults to 92aa81f3a9SJoerg Wunsch.Em \&%N.core , 93b5c508fbSRuslan Ermilovyielding the traditional 94b5c508fbSRuslan Ermilov.Fx 95b5c508fbSRuslan Ermilovbehaviour. 96aa81f3a9SJoerg Wunsch.Pp 9753d3620bSNik ClaytonBy default, a process that changes user or group credentials whether 980f3ac37eSRuslan Ermilovreal or effective will not create a corefile. 990f3ac37eSRuslan ErmilovThis behaviour can be 10053d3620bSNik Claytonchanged to generate a core dump by setting the 10153d3620bSNik Clayton.Xr sysctl 8 10253d3620bSNik Claytonvariable 10353d3620bSNik Clayton.Va kern.sugid_coredump 10453d3620bSNik Claytonto 1. 1050dce12b8SAlfred Perlstein.Pp 106aa14e9b7SMark JohnstonCorefiles can be compressed by the kernel if the following item 107aa14e9b7SMark Johnstonis included in the kernel configuration file: 1080dce12b8SAlfred Perlstein.Bl -tag -width "1234567890" -compact -offset "12345" 1090dce12b8SAlfred Perlstein.It options 110aa14e9b7SMark JohnstonGZIO 1110dce12b8SAlfred Perlstein.El 1120dce12b8SAlfred Perlstein.Pp 11378f57a9cSMark JohnstonThe following sysctl control core file compression: 11478f57a9cSMark Johnston.Bl -tag -width "kern.compress_user_cores_level" -compact -offset "12345" 1150dce12b8SAlfred Perlstein.It Em kern.compress_user_cores 11678f57a9cSMark JohnstonEnable compression of user cores. 1176026dcd7SMark JohnstonA value of 1 configures 1186026dcd7SMark Johnston.Xr gzip 1 1196026dcd7SMark Johnstoncompression, 1206026dcd7SMark Johnstonand a value of 2 configures 1216026dcd7SMark Johnston.Xr zstd 1 1226026dcd7SMark Johnstoncompression. 1236026dcd7SMark JohnstonCompressed core files will have a suffix of 124aa14e9b7SMark Johnston.Ql .gz 1256026dcd7SMark Johnstonor 1266026dcd7SMark Johnston.Ql .zst 1276026dcd7SMark Johnstonappended to their filenames depending on the selected format. 12878f57a9cSMark Johnston.It Em kern.compress_user_cores_level 12978f57a9cSMark JohnstonCompression level. 13078f57a9cSMark JohnstonDefaults to 6. 1310dce12b8SAlfred Perlstein.El 13214bdbaf2SConrad Meyer.Sh NOTES 13314bdbaf2SConrad MeyerCorefiles are written with open file descriptor information as an ELF note. 13414bdbaf2SConrad MeyerBy default, file paths are packed to only use as much space as needed. 13514bdbaf2SConrad MeyerHowever, file paths can change at any time, including during core dump, 13614bdbaf2SConrad Meyerand this can result in truncated file descriptor data. 13714bdbaf2SConrad Meyer.Pp 13814bdbaf2SConrad MeyerAll file descriptor information can be preserved by disabling packing. 13914bdbaf2SConrad MeyerThis potentially wastes up to PATH_MAX bytes per open fd. 14014bdbaf2SConrad MeyerPacking is disabled with 14114bdbaf2SConrad Meyer.Dl sysctl kern.coredump_pack_fileinfo=0 . 142e6b95927SConrad Meyer.Pp 143e6b95927SConrad MeyerSimilarly, corefiles are written with vmmap information as an ELF note, which 144e6b95927SConrad Meyercontains file paths. 145e6b95927SConrad MeyerBy default, they are packed to only use as much space as 146e6b95927SConrad Meyerneeded. 147e6b95927SConrad MeyerBy the same mechanism as for the open files note, these paths can also 148e6b95927SConrad Meyerchange at any time and result in a truncated note. 149e6b95927SConrad Meyer.Pp 150e6b95927SConrad MeyerAll vmmap information can be preserved by disabling packing. 151e6b95927SConrad MeyerLike the file information, this potentially wastes up to PATH_MAX bytes per 152e6b95927SConrad Meyermapped object. 153e6b95927SConrad MeyerPacking is disabled with 154e6b95927SConrad Meyer.Dl sysctl kern.coredump_pack_vmmapinfo=0 . 155aa81f3a9SJoerg Wunsch.Sh EXAMPLES 156aa81f3a9SJoerg WunschIn order to store all core images in per-user private areas under 157aa81f3a9SJoerg Wunsch.Pa /var/coredumps , 158aa81f3a9SJoerg Wunschthe following 159aa81f3a9SJoerg Wunsch.Xr sysctl 8 160aa81f3a9SJoerg Wunschcommand can be used: 161aa81f3a9SJoerg Wunsch.Pp 16207d6dffaSEdward Tomasz Napierala.Dl sysctl kern.corefile=/var/coredumps/\&%U/\&%N.core 163afe61c15SRodney W. Grimes.Sh SEE ALSO 164afe61c15SRodney W. Grimes.Xr gdb 1 , 16578f57a9cSMark Johnston.Xr gzip 1 , 166afe61c15SRodney W. Grimes.Xr kgdb 1 , 167c69a537cSWolfram Schneider.Xr setrlimit 2 , 168aa81f3a9SJoerg Wunsch.Xr sigaction 2 , 169aa81f3a9SJoerg Wunsch.Xr sysctl 8 170afe61c15SRodney W. Grimes.Sh HISTORY 171afe61c15SRodney W. GrimesA 1724b66483fSRuslan Ermilov.Nm 173afe61c15SRodney W. Grimesfile format appeared in 174afe61c15SRodney W. Grimes.At v6 . 175