Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

kvm(3) [netbsd man page]

KVM(3)							   BSD Library Functions Manual 						    KVM(3)

NAME
kvm -- kernel memory interface LIBRARY
Kernel Data Access Library (libkvm, -lkvm) DESCRIPTION
The kvm library provides a uniform interface for accessing kernel virtual memory images, including live systems and crash dumps. Access to live systems is via /dev/mem while crash dumps can be examined via the core file generated by savecore(8). The interface behaves identically in both cases. Memory can be read and written, kernel symbol addresses can be looked up efficiently, and information about user processes can be gathered. kvm_open() is first called to obtain a descriptor for all subsequent calls. FILES
/dev/mem interface to physical memory COMPATIBILITY
The kvm interface was first introduced in SunOS. A considerable number of programs have been developed that use this interface, making back- ward compatibility highly desirable. In most respects, the Sun kvm interface is consistent and clean. Accordingly, the generic portion of the interface (i.e., kvm_open(), kvm_close(), kvm_read(), kvm_write(), and kvm_nlist()) has been incorporated into the BSD interface. Indeed, many kvm applications (i.e., debuggers and statistical monitors) use only this subset of the interface. The process interface was not kept. This is not a portability issue since any code that manipulates processes is inherently machine depen- dent. Finally, the Sun kvm error reporting semantics are poorly defined. The library can be configured either to print errors to stderr automati- cally, or to print no error messages at all. In the latter case, the nature of the error cannot be determined. To overcome this, the BSD interface includes a routine, kvm_geterr(3), to return (not print out) the error message corresponding to the most recent error condition on the given descriptor. SEE ALSO
kvm_close(3), kvm_getargv(3), kvm_getenvv(3), kvm_geterr(3), kvm_getkernelname(3), kvm_getloadavg(3), kvm_getlwps(3), kvm_getprocs(3), kvm_nlist(3), kvm_open(3), kvm_openfiles(3), kvm_read(3), kvm_write(3) BSD
September 14, 2011 BSD

Check Out this Related Man Page

KVM_OPEN(3)						   BSD Library Functions Manual 					       KVM_OPEN(3)

NAME
kvm_open, kvm_openfiles, kvm_close -- initialize kernel virtual memory access LIBRARY
Kernel Data Access Library (libkvm, -lkvm) SYNOPSIS
#include <fcntl.h> #include <kvm.h> kvm_t * kvm_open(const char *execfile, const char *corefile, const char *swapfile, int flags, const char *errstr); kvm_t * kvm_openfiles(const char *execfile, const char *corefile, const char *swapfile, int flags, char *errbuf); int kvm_close(kvm_t *kd); DESCRIPTION
The functions kvm_open() and kvm_openfiles() return a descriptor used to access kernel virtual memory via the kvm(3) library routines. Both active kernels and crash dumps are accessible through this interface. The execfile argument is the executable image of the kernel being examined. This file must contain a symbol table. If this argument is NULL, the currently running system is assumed, as determined from getbootfile(3). The corefile argument is the kernel memory device file. It can be either /dev/mem or a crash dump core generated by savecore(8). If corefile is NULL, the default indicated by _PATH_MEM from <paths.h> is used. It can also be set to a special value /dev/null by utilities like ps(1) that do not directly access kernel memory. The swapfile argument is currently unused. The flags argument indicates read/write access as in open(2) and applies only to the core file. Only O_RDONLY, O_WRONLY, and O_RDWR are per- mitted. There are two open routines which differ only with respect to the error mechanism. One provides backward compatibility with the SunOS kvm library, while the other provides an improved error reporting framework. The kvm_open() function is the Sun kvm compatible open call. Here, the errstr argument indicates how errors should be handled. If it is NULL, no errors are reported and the application cannot know the specific nature of the failed kvm call. If it is not NULL, errors are printed to stderr with errstr prepended to the message, as in perror(3). Normally, the name of the program is used here. The string is assumed to persist at least until the corresponding kvm_close() call. The kvm_openfiles() function provides BSD style error reporting. Here, error messages are not printed out by the library. Instead, the application obtains the error message corresponding to the most recent kvm library call using kvm_geterr() (see kvm_geterr(3)). The results are undefined if the most recent kvm call did not produce an error. Since kvm_geterr() requires a kvm descriptor, but the open routines return NULL on failure, kvm_geterr() cannot be used to get the error message if open fails. Thus, kvm_openfiles() will place any error mes- sage in the errbuf argument. This buffer should be _POSIX2_LINE_MAX characters large (from <limits.h>). RETURN VALUES
The kvm_open() and kvm_openfiles() functions both return a descriptor to be used in all subsequent kvm library calls. The library is fully re-entrant. On failure, NULL is returned, in which case kvm_openfiles() writes the error message into errbuf. The kvm_close() function returns 0 on success and -1 on failure. SEE ALSO
open(2), kvm(3), kvm_getargv(3), kvm_getenvv(3), kvm_geterr(3), kvm_getprocs(3), kvm_nlist(3), kvm_read(3), kvm_write(3), kmem(4), mem(4) BUGS
There should not be two open calls. The ill-defined error semantics of the Sun library and the desire to have a backward-compatible library for BSD left little choice. BSD
January 29, 2004 BSD
Man Page