|Main index||Section 3||Options|
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 permitted.
The kvm library provides two different error reporting mechanisms. One provides backward compatibility with the SunOS kvm library, while the other provides an improved error reporting framework. The mechanism used by a descriptor is determined by the function used to open the descriptor.
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_open2() and kvm_openfiles() functions provide 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_open2() and kvm_openfiles() will place any error message in the errbuf argument. This buffer should be _POSIX2_LINE_MAX characters large (from <limits.h>).
The resolver argument points to a function used by the kvm library to map symbol names to kernel virtual addresses. When the resolver function is called, name specifies the requested symbol name. If the function is able to resolve the name to an address, the address should be set in addr and the function should return zero. If the function is not able to resolve the name to an address, it should return a non-zero value. When opening a native kernel image, resolver may be set to NULL to use an internal function to resolve symbol names. Non-native kernel images (such as when cross-debugging a crash dump) require a valid resolver.
The kvm_close function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.
The kvm_close() function may also fail and set errno if:
|The value passed via kd was NULL.|
|KVM_OPEN (3)||March 20, 2017|
|Main index||Section 3||Options|
|“||Unix is a junk OS designed by a committee of PhDs.||”|
|— Dave Cutler|