xref: /netbsd-src/lib/libkvm/kvm_dump.3 (revision 2a399c6883d870daece976daec6ffa7bb7f934ce)
1.\"	$NetBSD: kvm_dump.3,v 1.2 1996/06/23 20:28:12 leo Exp $
2.\"
3.\" Copyright (c) 1996 Leo Weppelman
4.\" 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 Leo Weppelman.
17.\" 4. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
32.\"
33.Dd March 17, 1996
34.Dt KVM_DUMP 3
35.Os
36.Sh NAME
37.Nm kvm_dump_mkheader ,
38.Nm kvm_dump_wrtheader ,
39.Nm kvm_dump_inval
40.Nd crash-dump support functions
41.Sh SYNOPSIS
42.Fd #include <kvm.h>
43.br
44.Ft int
45.Fn kvm_dump_mkheader "kvm_t *kd" "off_t dump_off"
46.Ft int
47.Fn kvm_dump_wrtheader "kvm_t *kd" "FILE *fp" "int dumpsize"
48.Ft int
49.Fn kvm_dump_inval "kvm_t *kd"
50.Sh DESCRIPTION
51First note that the functions described here were designed to be used by
52.Xr savecore 8 .
53.Pp
54The function
55.Fn kvm_dump_mkheader
56checks if the physical memory file associated with
57.Fa kd
58contains a valid crash-dump header as generated by a dumping kernel. When a
59valid header is found,
60.Fn kvm_dump_mkheader
61initializes the internal kvm data structures as if a crash-dump generated by
62the
63.Xr savecore 8
64program was opened. This has the intentional side effect of enabling the
65address translation machinery.
66.Pp
67A call to
68.Fn kvm_dump_mkheader
69will most likely be followed by a call to
70.Fn kvm_dump_wrtheader .
71This function takes care of generating the generic header, the CORE_CPU
72section and the section header of the CORE_DATA section. The data is written
73to the file pointed at by
74.Fa fp .
75The
76.Fa dumpsize
77argument is only used to properly the set the segment size of the CORE_DATA
78section. Note that this function assumes that
79.Fa fp
80is positioned at file location 0. This function will not seek and therefore
81allows
82.Fa fp
83to be a file pointer obtained by
84.Fn zopen .
85.Pp
86The
87.Fn kvm_dump_inval
88function clears the magic number in the physical memory file associated with
89.Fa kd .
90The address translations must be enabled for this to work (thus assuming
91that
92.Fn kvm_dump_mkheader
93was called earlier in the sequence).
94.Sh RETURN VALUES
95All functions except
96.Fn kvm_dump_mkheader
97return 0 on success, -1 on failure. The function
98.Fn kvm_dump_mkheader
99returns the size of the headers present before the actual dumpdata starts. If
100no valid headers were found but no fatal errors occured, 0 is returned. On
101fatal errors the return value is -1.
102.Pp
103In the case of failure,
104.Xr kvm_geterr 3
105can be used to retrieve the cause of the error.
106.Sh HISTORY
107These functions first appeared in NetBSD 1.1A.
108.Sh BUGS
109There probably are...
110.Sh SEE ALSO
111.Xr kvm 3
112