xref: /netbsd-src/lib/libkvm/kvm_dump.3 (revision 4988388746341ac3fc72e21abd79958515e8ad78)
1*49883887Ssnj.\"	$NetBSD: kvm_dump.3,v 1.15 2009/10/20 19:10:09 snj Exp $
2c458aad2Sleo.\"
3c458aad2Sleo.\" Copyright (c) 1996 Leo Weppelman
4c458aad2Sleo.\" All rights reserved.
5c458aad2Sleo.\"
6c458aad2Sleo.\" Redistribution and use in source and binary forms, with or without
7c458aad2Sleo.\" modification, are permitted provided that the following conditions
8c458aad2Sleo.\" are met:
9c458aad2Sleo.\" 1. Redistributions of source code must retain the above copyright
10c458aad2Sleo.\"    notice, this list of conditions and the following disclaimer.
11c458aad2Sleo.\" 2. Redistributions in binary form must reproduce the above copyright
12c458aad2Sleo.\"    notice, this list of conditions and the following disclaimer in the
13c458aad2Sleo.\"    documentation and/or other materials provided with the distribution.
14c458aad2Sleo.\"
15c458aad2Sleo.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16c458aad2Sleo.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17c458aad2Sleo.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18c458aad2Sleo.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19c458aad2Sleo.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20c458aad2Sleo.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21c458aad2Sleo.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22c458aad2Sleo.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23c458aad2Sleo.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24c458aad2Sleo.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25c458aad2Sleo.\"
26c458aad2Sleo.\"
27c458aad2Sleo.Dd March 17, 1996
28c458aad2Sleo.Dt KVM_DUMP 3
29c458aad2Sleo.Os
30c458aad2Sleo.Sh NAME
31c458aad2Sleo.Nm kvm_dump_mkheader ,
32c458aad2Sleo.Nm kvm_dump_wrtheader ,
33c458aad2Sleo.Nm kvm_dump_inval
34b976c559Swiz.Nd crash dump support functions
35312aca53Sperry.Sh LIBRARY
36312aca53Sperry.Lb libkvm
37c458aad2Sleo.Sh SYNOPSIS
38472351e1Swiz.In kvm.h
39c458aad2Sleo.Ft int
40c458aad2Sleo.Fn kvm_dump_mkheader "kvm_t *kd" "off_t dump_off"
41c458aad2Sleo.Ft int
42c458aad2Sleo.Fn kvm_dump_wrtheader "kvm_t *kd" "FILE *fp" "int dumpsize"
43c458aad2Sleo.Ft int
44c458aad2Sleo.Fn kvm_dump_inval "kvm_t *kd"
45c458aad2Sleo.Sh DESCRIPTION
46c458aad2SleoFirst note that the functions described here were designed to be used by
47c458aad2Sleo.Xr savecore 8 .
48c458aad2Sleo.Pp
49c458aad2SleoThe function
50c458aad2Sleo.Fn kvm_dump_mkheader
51c458aad2Sleochecks if the physical memory file associated with
52c458aad2Sleo.Fa kd
53b976c559Swizcontains a valid crash dump header as generated by a dumping kernel.
54bec910b3SwizWhen a valid header is found,
55c458aad2Sleo.Fn kvm_dump_mkheader
56b976c559Swizinitializes the internal kvm data structures as if a crash dump generated by
57c458aad2Sleothe
58c458aad2Sleo.Xr savecore 8
59bec910b3Swizprogram was opened.
60bec910b3SwizThis has the intentional side effect of enabling the
61c458aad2Sleoaddress translation machinery.
62c458aad2Sleo.Pp
63c458aad2SleoA call to
64c458aad2Sleo.Fn kvm_dump_mkheader
65c458aad2Sleowill most likely be followed by a call to
66c458aad2Sleo.Fn kvm_dump_wrtheader .
67c458aad2SleoThis function takes care of generating the generic header, the CORE_CPU
68bec910b3Swizsection and the section header of the CORE_DATA section.
69bec910b3SwizThe data is written to the file pointed at by
70c458aad2Sleo.Fa fp .
71c458aad2SleoThe
72c458aad2Sleo.Fa dumpsize
73c458aad2Sleoargument is only used to properly the set the segment size of the CORE_DATA
74bec910b3Swizsection.
75bec910b3SwizNote that this function assumes that
76c458aad2Sleo.Fa fp
77bec910b3Swizis positioned at file location 0.
78bec910b3SwizThis function will not seek and therefore allows
79c458aad2Sleo.Fa fp
80c458aad2Sleoto be a file pointer obtained by
81c458aad2Sleo.Fn zopen .
82c458aad2Sleo.Pp
83c458aad2SleoThe
84c458aad2Sleo.Fn kvm_dump_inval
85c458aad2Sleofunction clears the magic number in the physical memory file associated with
86c458aad2Sleo.Fa kd .
87c458aad2SleoThe address translations must be enabled for this to work (thus assuming
88c458aad2Sleothat
89fa721903Sleo.Fn kvm_dump_mkheader
90c458aad2Sleowas called earlier in the sequence).
91c458aad2Sleo.Sh RETURN VALUES
92fa721903SleoAll functions except
93fa721903Sleo.Fn kvm_dump_mkheader
94bec910b3Swizreturn 0 on success, -1 on failure.
95bec910b3SwizThe function
96fa721903Sleo.Fn kvm_dump_mkheader
97bec910b3Swizreturns the size of the headers present before the actual dumpdata starts.
98bec910b3SwizIf no valid headers were found but no fatal errors occurred, 0 is returned.
99bec910b3SwizOn fatal errors the return value is -1.
100fa721903Sleo.Pp
101fa721903SleoIn the case of failure,
102c458aad2Sleo.Xr kvm_geterr 3
103c458aad2Sleocan be used to retrieve the cause of the error.
104c458aad2Sleo.Sh SEE ALSO
105ea5c1879Ssimonb.Xr kvm 3 ,
106ea5c1879Ssimonb.Xr kvm_open 3
107f6254de6Swiz.Sh HISTORY
108f6254de6SwizThese functions first appeared in
109f6254de6Swiz.Nx 1.2 .
110