1 .\" Copyright (c) 1992, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software developed by the Computer Systems
5 .\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
6 .\" BG 91-66 and contributed to Berkeley.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)kvm_open.3 8.3 (Berkeley) 4/19/94
42 .Nd initialize kernel virtual memory access
49 .Fn kvm_open "const char *execfile" "const char *corefile" "const char *swapfile" "int flags" "const char *errstr"
52 .Fa "const char *execfile"
53 .Fa "const char *corefile"
56 .Fa "int (*resolver)(const char *name, kvaddr_t *addr)"
59 .Fn kvm_openfiles "const char *execfile" "const char *corefile" "const char *swapfile" "int flags" "char *errbuf"
61 .Fn kvm_close "kvm_t *kd"
68 return a descriptor used to access kernel virtual memory
72 Both active kernels and crash dumps are accessible
73 through this interface.
77 argument is the executable image of the kernel being examined.
78 This file must contain a symbol table.
81 the currently running system is assumed,
87 argument is the kernel memory device file.
90 or a crash dump core generated by
96 the default indicated by
101 It can also be set to a special value
105 that do not directly access kernel memory.
109 argument is currently unused.
113 argument indicates read/write access as in
115 and applies only to the core file.
125 library provides two different error reporting mechanisms.
126 One provides backward compatibility with the SunOS kvm library, while the
127 other provides an improved error reporting framework.
128 The mechanism used by a descriptor is determined by the function used to
133 function is the Sun kvm compatible open call.
136 argument indicates how errors should be handled.
139 no errors are reported and the application cannot know the
140 specific nature of the failed kvm call.
143 errors are printed to
147 prepended to the message, as in
149 Normally, the name of the program is used here.
150 The string is assumed to persist at least until the corresponding
160 style error reporting.
161 Here, error messages are not printed out by the library.
162 Instead, the application obtains the error message
163 corresponding to the most recent kvm library call using
167 The results are undefined if the most recent kvm call did not produce
171 requires a kvm descriptor, but the open routines return
175 cannot be used to get the error message if open fails.
180 will place any error message in the
183 This buffer should be _POSIX2_LINE_MAX characters large (from
188 argument points to a function used by the
190 library to map symbol names to kernel virtual addresses.
195 specifies the requested symbol name.
196 If the function is able to resolve the name to an address,
197 the address should be set in
199 and the function should return zero.
200 If the function is not able to resolve the name to an address,
201 it should return a non-zero value.
202 When opening a native kernel image,
206 to use an internal function to resolve symbol names.
207 Non-native kernel images
208 .Pq such as when cross-debugging a crash dump
217 functions return a descriptor to be used
218 in all subsequent kvm library calls.
219 The library is fully re-entrant.
222 is returned, in which case
226 write the error message into
233 function may fail and set the global variable
235 for any of the errors specified for
240 function may also fail and set
265 There should not be three open calls.
266 The ill-defined error semantics
267 of the Sun library and the desire to have a backward-compatible library
274 function first appeared in