update from LBL (Chris, Craig and Steve)
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 30 Apr 1992 02:52:12 +0000 (18:52 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Thu, 30 Apr 1992 02:52:12 +0000 (18:52 -0800)
SCCS-vsn: lib/libkvm/kvm.3 5.2
SCCS-vsn: lib/libkvm/kvm.c 5.25
SCCS-vsn: lib/libkvm/kvm_geterr.3 5.2
SCCS-vsn: lib/libkvm/kvm_getprocs.3 5.2
SCCS-vsn: lib/libkvm/kvm_hp300.c 5.24
SCCS-vsn: lib/libkvm/kvm_nlist.3 5.4
SCCS-vsn: lib/libkvm/kvm_open.3 5.2
SCCS-vsn: lib/libkvm/kvm_sparc.c 5.2

usr/src/lib/libkvm/kvm.3
usr/src/lib/libkvm/kvm.c
usr/src/lib/libkvm/kvm_geterr.3
usr/src/lib/libkvm/kvm_getprocs.3
usr/src/lib/libkvm/kvm_hp300.c
usr/src/lib/libkvm/kvm_nlist.3
usr/src/lib/libkvm/kvm_open.3
usr/src/lib/libkvm/kvm_sparc.c

index 8eabaff..dbe5907 100644 (file)
@@ -3,53 +3,25 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)kvm.3      5.1 (Berkeley) %G%
+.\"     @(#)kvm.3      5.2 (Berkeley) %G%
 .\"
 .Dd 
 .Dt KVM 3
 .Os
 .Sh NAME
 .\"
 .Dd 
 .Dt KVM 3
 .Os
 .Sh NAME
-.Nm kvm_open ,
-.Nm kvm_openfiles ,
-.Nm kvm_close ,
-.Nm kvm_read ,
-.Nm kvm_write ,
-.Nm kvm_nlist ,
-.Nm kvm_getprocs ,
-.Nm kvm_getargv ,
-.Nm kvm_getenvv ,
-.Nm kvm_geterr
+.Nm kvm
 .Nd kernel memory interface
 .Nd kernel memory interface
-.Sh SYNOPSIS
-.Fd #include <kvm.h>
-.br
-.Ft kvm_t *
-.Fn kvm_open "const char *execfile" "const char *corefile" "char *swapfile" "int flag" "const char *errstr"
-.Ft void
-.Fn kvm_close "kvm_t *kd"
-.Ft ssize_t
-.Fn kvm_read "const kvm_t *kd" "u_long addr" "char *buf" "size_t nbytes"
-.Ft ssize_t
-.Fn kvm_write "const kvm_t *kd" "u_long addr" "char *buf" "size_t nbytes"
-.Ft int
-.Fn kvm_nlist "kvm_t *kd" "struct nlist *nl"
-.Ft struct kinfo_proc *
-.Fn kvm_getprocs "kvm_t *kd" int int "int *"
-.Ft char **
-.Fn kvm_getargv "kvm_t *kd" "const struct proc *p" "int strspc"
-.Ft void
-.Fn kvm_geterr "const kvm_t *kd"
 .Sh DESCRIPTION
 .Sh DESCRIPTION
-The 
+The
 .Xr kvm 3
 .Xr kvm 3
-library provides a uniform interface for accessing kernel virtual mememory
+library provides a uniform interface for accessing kernel virtual memory
 images, including live systems and crashdumps.
 Access to live systems is via
 /dev/mem
 while crashdumps can be examined via the core file generated by
 .Xr savecore 8 .
 The interface behaves identically in both cases.
 images, including live systems and crashdumps.
 Access to live systems is via
 /dev/mem
 while crashdumps can be examined via the core file generated by
 .Xr savecore 8 .
 The interface behaves identically in both cases.
-Memory can be read and written, kernel symbol addresses can be 
+Memory can be read and written, kernel symbol addresses can be
 looked up efficiently, and information about user processes can
 be gathered.
 .Pp
 looked up efficiently, and information about user processes can
 be gathered.
 .Pp
@@ -59,20 +31,20 @@ is first called to obtain a descriptor for all subsequent calls.
 The kvm interface was first introduced in SunOS.  A considerable
 number of programs have been developed that use this interface,
 making backward compatibility highly desirable.
 The kvm interface was first introduced in SunOS.  A considerable
 number of programs have been developed that use this interface,
 making backward compatibility highly desirable.
-In most respects, the Sun kvm inteface is consistent and clean.
+In most respects, the Sun kvm interface is consistent and clean.
 Accordingly, the generic portion of the interface (i.e.,
 Accordingly, the generic portion of the interface (i.e.,
-.Fn kvm_open,
-.Fn kvm_close,
-.Fn kvm_read,
-.Fn kvm_write,
+.Fn kvm_open ,
+.Fn kvm_close ,
+.Fn kvm_read ,
+.Fn kvm_write ,
 and
 and
-.Fn kvm_nlist
-.) has been incorportated into the BSD interface.  Indeed, many kvm
-applications (i.e., debuggers and statistical monitors) use only 
+.Fn 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.
 .Pp
 The process interface was not kept.  This is not a portability
 this subset of the interface.
 .Pp
 The process interface was not kept.  This is not a portability
-issue since any code that manipulates processes is inherenly
+issue since any code that manipulates processes is inherently
 machine dependent.
 .Pp
 Finally, the Sun kvm error reporting semantics are poorly defined.
 machine dependent.
 .Pp
 Finally, the Sun kvm error reporting semantics are poorly defined.
@@ -86,13 +58,13 @@ to return (not print out) the error message
 corresponding to the most recent error condition on the
 given descriptor.
 .Sh SEE ALSO
 corresponding to the most recent error condition on the
 given descriptor.
 .Sh SEE ALSO
-.Xr kvm_open 3,
-.Xr kvm_openfiles 3,
-.Xr kvm_close 3,
-.Xr kvm_read 3,
-.Xr kvm_write 3,
-.Xr kvm_nlist 3,
-.Xr kvm_getprocs 3,
-.Xr kvm_getargv 3,
-.Xr kvm_getenvv 3,
-.Xr kvm_geterr 3
+.Xr kvm_close 3 ,
+.Xr kvm_getargv 3 ,
+.Xr kvm_getenvv 3 ,
+.Xr kvm_geterr 3 ,
+.Xr kvm_getprocs 3 ,
+.Xr kvm_nlist 3 ,
+.Xr kvm_open 3 ,
+.Xr kvm_openfiles 3 ,
+.Xr kvm_read 3 ,
+.Xr kvm_write 3
index 3df3668..c27fd9e 100644 (file)
@@ -18,7 +18,7 @@ static char sccsid[] = "@(#)kvm.c     5.25 (Berkeley) %G%";
 #include <fcntl.h>
 #include <nlist.h>
 #include <kvm.h>
 #include <fcntl.h>
 #include <nlist.h>
 #include <kvm.h>
-#include <ndbm.h>
+#include <db.h>
 #include <paths.h>
 #include <stdio.h>
 #include <string.h>
 #include <paths.h>
 #include <stdio.h>
 #include <string.h>
@@ -252,7 +252,7 @@ kvm_close(kd)
        if (kd->swfd >= 0)
                error |= close(kd->swfd);
        if (kd->db != 0)
        if (kd->swfd >= 0)
                error |= close(kd->swfd);
        if (kd->db != 0)
-               dbm_close(kd->db);
+               error |= (kd->db->close)(kd->db);
        if (kd->vmst)
                _kvm_freevtop(kd);
        if (kd->procbase != 0)
        if (kd->vmst)
                _kvm_freevtop(kd);
        if (kd->procbase != 0)
@@ -276,7 +276,7 @@ kvm_dbopen(kd, uf)
        const char *uf;
 {
        char *cp;
        const char *uf;
 {
        char *cp;
-       datum rec;
+       DBT rec;
        int dbversionlen;
        struct nlist nitem;
        char dbversion[_POSIX2_LINE_MAX];
        int dbversionlen;
        struct nlist nitem;
        char dbversion[_POSIX2_LINE_MAX];
@@ -286,32 +286,34 @@ kvm_dbopen(kd, uf)
        if ((cp = rindex(uf, '/')) != 0)
                uf = cp + 1;
 
        if ((cp = rindex(uf, '/')) != 0)
                uf = cp + 1;
 
-       sprintf(dbname, "%skvm_%s", _PATH_VARRUN, uf);
-       kd->db = dbm_open(dbname, O_RDONLY, 0);
+       (void)snprintf(dbname, sizeof(dbname), "%skvm_%s.db", _PATH_VARDB, uf);
+       kd->db = dbopen(dbname, O_RDONLY, 0, DB_HASH, NULL);
        if (kd->db == 0)
                return (-1);
        /*
         * read version out of database
         */
        if (kd->db == 0)
                return (-1);
        /*
         * read version out of database
         */
-       rec.dptr = VRS_KEY;
-       rec.dsize = sizeof(VRS_KEY) - 1;
-       rec = dbm_fetch(kd->db, rec);
-       if (rec.dptr == 0 || rec.dsize > sizeof(dbversion))
+       rec.data = VRS_KEY;
+       rec.size = sizeof(VRS_KEY) - 1;
+       if ((kd->db->get)(kd->db, (DBT *)&rec, (DBT *)&rec, 0))
+               goto close;
+       if (rec.data == 0 || rec.size > sizeof(dbversion))
                goto close;
 
                goto close;
 
-       bcopy(rec.dptr, dbversion, rec.dsize);
-       dbversionlen = rec.dsize;
+       bcopy(rec.data, dbversion, rec.size);
+       dbversionlen = rec.size;
        /*
         * Read version string from kernel memory.
         * Since we are dealing with a live kernel, we can call kvm_read()
         * at this point.
         */
        /*
         * Read version string from kernel memory.
         * Since we are dealing with a live kernel, we can call kvm_read()
         * at this point.
         */
-       rec.dptr = VRS_SYM;
-       rec.dsize = sizeof(VRS_SYM) - 1;
-       rec = dbm_fetch(kd->db, rec);
-       if (rec.dptr == 0 || rec.dsize != sizeof(struct nlist))
+       rec.data = VRS_SYM;
+       rec.size = sizeof(VRS_SYM) - 1;
+       if ((kd->db->get)(kd->db, (DBT *)&rec, (DBT *)&rec, 0))
+               goto close;
+       if (rec.data == 0 || rec.size != sizeof(struct nlist))
                goto close;
                goto close;
-       bcopy((char *)rec.dptr, (char *)&nitem, sizeof(nitem));
+       bcopy((char *)rec.data, (char *)&nitem, sizeof(nitem));
        if (kvm_read(kd, (u_long)nitem.n_value, kversion, dbversionlen) != 
            dbversionlen)
                goto close;
        if (kvm_read(kd, (u_long)nitem.n_value, kversion, dbversionlen) != 
            dbversionlen)
                goto close;
@@ -322,7 +324,7 @@ kvm_dbopen(kd, uf)
        if (bcmp(dbversion, kversion, dbversionlen) == 0)
                return (0);
 close:
        if (bcmp(dbversion, kversion, dbversionlen) == 0)
                return (0);
 close:
-       dbm_close(kd->db);
+       (void)(kd->db->close)(kd->db);
        kd->db = 0;
 
        return (-1);
        kd->db = 0;
 
        return (-1);
@@ -345,31 +347,32 @@ kvm_nlist(kd, nl)
 
        /*
         * We can use the kvm data base.  Go through each nlist entry
 
        /*
         * We can use the kvm data base.  Go through each nlist entry
-        * and look it up with a dbm query.
+        * and look it up with a db query.
         */
        nvalid = 0;
        for (p = nl; p->n_name && p->n_name[0]; ++p) {
                register int len;
         */
        nvalid = 0;
        for (p = nl; p->n_name && p->n_name[0]; ++p) {
                register int len;
-               datum rec;
+               DBT rec;
 
                if ((len = strlen(p->n_name)) > 4096) {
                        /* sanity */
                        _kvm_err(kd, kd->program, "symbol too large");
                        return (-1);
                }
 
                if ((len = strlen(p->n_name)) > 4096) {
                        /* sanity */
                        _kvm_err(kd, kd->program, "symbol too large");
                        return (-1);
                }
-               rec.dptr = p->n_name;
-               rec.dsize = len;
-               rec = dbm_fetch(kd->db, rec);
-               if (rec.dptr == 0 || rec.dsize != sizeof(struct nlist))
+               rec.data = p->n_name;
+               rec.size = len;
+               if ((kd->db->get)(kd->db, (DBT *)&rec, (DBT *)&rec, 0))
+                       continue;
+               if (rec.data == 0 || rec.size != sizeof(struct nlist))
                        continue;
                ++nvalid;
                /*
                 * Avoid alignment issues.
                 */
                        continue;
                ++nvalid;
                /*
                 * Avoid alignment issues.
                 */
-               bcopy((char *)&((struct nlist *)rec.dptr)->n_type,
+               bcopy((char *)&((struct nlist *)rec.data)->n_type,
                      (char *)&p->n_type, 
                      sizeof(p->n_type));
                      (char *)&p->n_type, 
                      sizeof(p->n_type));
-               bcopy((char *)&((struct nlist *)rec.dptr)->n_value,
+               bcopy((char *)&((struct nlist *)rec.data)->n_value,
                      (char *)&p->n_value, 
                      sizeof(p->n_value));
        }
                      (char *)&p->n_value, 
                      sizeof(p->n_value));
        }
index 3aa41ea..be39c8a 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)kvm_geterr.3       5.1 (Berkeley) %G%
+.\"     @(#)kvm_geterr.3       5.2 (Berkeley) %G%
 .\"
 .Dd 
 .Dt KVM_GETERR 3
 .\"
 .Dd 
 .Dt KVM_GETERR 3
@@ -27,13 +27,24 @@ The string returned is stored in memory owned by
 .Xr kvm 3
 so the message should be copied out and saved elsewhere if necessary.
 .Sh BUGS
 .Xr kvm 3
 so the message should be copied out and saved elsewhere if necessary.
 .Sh BUGS
-This routine cannot be used to access error conditions do to a failed
+This routine cannot be used to access error conditions due to a failed
 .Fn kvm_openfiles
 .Fn kvm_openfiles
-call, since failure is indicated by returning a NULL descriptor.
+call, since failure is indicated by returning a
+.Dv NULL
+descriptor.
 Therefore, errors on open are output to the special error buffer
 passed to 
 .Fn kvm_openfiles .
 This option is not available to
 .Fn kvm_open .
 .Sh SEE ALSO
 Therefore, errors on open are output to the special error buffer
 passed to 
 .Fn kvm_openfiles .
 This option is not available to
 .Fn kvm_open .
 .Sh SEE ALSO
-.Xr kvm 3
+.Xr kvm 3 ,
+.Xr kvm_close 3 ,
+.Xr kvm_getargv 3 ,
+.Xr kvm_getenvv 3 ,
+.Xr kvm_getprocs 3 ,
+.Xr kvm_nlist 3 ,
+.Xr kvm_open 3 ,
+.Xr kvm_openfiles 3 ,
+.Xr kvm_read 3 ,
+.Xr kvm_write 3
index f09d8d8..0d3ea30 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)kvm_getprocs.3     5.1 (Berkeley) %G%
+.\"     @(#)kvm_getprocs.3     5.2 (Berkeley) %G%
 .\"
 .Dd 
 .Dt KVM_GETPROCS 3
 .\"
 .Dd 
 .Dt KVM_GETPROCS 3
@@ -24,7 +24,7 @@
 .Ft char **
 .Fn kvm_getargv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
 .Ft char **
 .Ft char **
 .Fn kvm_getargv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
 .Ft char **
-.Fn kvm_getargv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
+.Fn kvm_getenvv "kvm_t *kd" "const struct kinfo_proc *p" "int nchr"
 .Sh DESCRIPTION
 .Fn kvm_getprocs
 returns a (sub-)set of active processes in the kernel indicated by
 .Sh DESCRIPTION
 .Fn kvm_getprocs
 returns a (sub-)set of active processes in the kernel indicated by
@@ -69,14 +69,14 @@ subsequent kvm library calls.  Data should be copied out if it needs to be
 saved.
 .Pp
 .Fn kvm_getargv
 saved.
 .Pp
 .Fn kvm_getargv
-returns an null-terminated argument vector that corresponds to the 
+returns a null-terminated argument vector that corresponds to the 
 command line arguments passed to process indicated by
 .Fa p .
 Most likely, these arguments correspond to the values passed to
 .Xr exec 3
 command line arguments passed to process indicated by
 .Fa p .
 Most likely, these arguments correspond to the values passed to
 .Xr exec 3
-on process creation.  However, this information exists only the
-process address space, and is therefore alterable by the process
-itself.   Note that the original command name can be found, unaltered,
+on process creation.  This information is, however,
+deliberately under control of the process itself.
+Note that the original command name can be found, unaltered,
 in the p_comm field of the process structure returned by
 .Fn kvm_getprocs .
 .Pp
 in the p_comm field of the process structure returned by
 .Fn kvm_getprocs .
 .Pp
@@ -88,13 +88,17 @@ causing the overflow is truncated and the partial result is returned.
 This is handy for programs like
 .Xr ps 1
 and
 This is handy for programs like
 .Xr ps 1
 and
-.Xr w
-that print only a one line summary of a command and should copy
-out large numbers arguments that will not be printed.
+.Xr w 1
+that print only a one line summary of a command and should not copy
+out large amounts of text only to ignore it.
+If
+.Fa nchr
+is zero, no limit is imposed and all argument strings are returned in 
+their entirety.
 .Pp
 .Pp
-The memory allocated to the argv pointers as well as the string storage
-are owned by the kvm library.  Data must be copied out of this
-structure before calling another kvm function.
+The memory allocated to the argv pointers and string storage
+is owned by the kvm library.  Since subsequent kvm calls may clobber
+this storage, data must be copied out if it needs to be saved.
 .Pp
 The
 .Fn kvm_getenvv
 .Pp
 The
 .Fn kvm_getenvv
@@ -107,16 +111,18 @@ also alterable by the process.
 .Fn kvm_getargv ,
 and
 .Fn kvm_getenvv ,
 .Fn kvm_getargv ,
 and
 .Fn kvm_getenvv ,
-all return NULL on failure.
+all return
+.Dv NULL
+on failure.
 .Pp
 .Sh BUGS
 These routines do not belong in the kvm interface.
 .Sh SEE ALSO
 .Xr kvm 3 ,
 .Pp
 .Sh BUGS
 These routines do not belong in the kvm interface.
 .Sh SEE ALSO
 .Xr kvm 3 ,
+.Xr kvm_close 3 ,
+.Xr kvm_geterr 3 ,
+.Xr kvm_nlist 3 ,
 .Xr kvm_open 3 ,
 .Xr kvm_openfiles 3 ,
 .Xr kvm_open 3 ,
 .Xr kvm_openfiles 3 ,
-.Xr kvm_close 3 ,
 .Xr kvm_read 3 ,
 .Xr kvm_read 3 ,
-.Xr kvm_write 3 ,
-.Xr kvm_nlist 3 ,
-.Xr kvm_geterr 3
+.Xr kvm_write 3
index 51a8966..fe9998e 100644 (file)
@@ -6,11 +6,11 @@
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)kvm_hp300.c        5.23 (Berkeley) %G%";
+static char sccsid[] = "@(#)kvm_hp300.c        5.24 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 /*
 #endif /* LIBC_SCCS and not lint */
 
 /*
- * hp300 machine depedent routines for kvm.  Hopefully, the forthcoming 
+ * Hp300 machine depedent routines for kvm.  Hopefully, the forthcoming 
  * vm code will one day obsolete this module.
  */
 
  * vm code will one day obsolete this module.
  */
 
@@ -25,7 +25,7 @@ static char sccsid[] = "@(#)kvm_hp300.c       5.23 (Berkeley) %G%";
 #include <vm/vm_param.h>
 
 #include <limits.h>
 #include <vm/vm_param.h>
 
 #include <limits.h>
-#include <ndbm.h>
+#include <db.h>
 
 #include "kvm_private.h"
 
 
 #include "kvm_private.h"
 
index 962c508..da6a98f 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)kvm_nlist.3        5.3 (Berkeley) %G%
+.\"     @(#)kvm_nlist.3        5.4 (Berkeley) %G%
 .\"
 .Dd 
 .Dt KVM_NLIST 3
 .\"
 .Dd 
 .Dt KVM_NLIST 3
@@ -25,19 +25,20 @@ an entry whose n_name field is
 .Dv NULL
 (see
 .Xr nlist 3 ) .
 .Dv NULL
 (see
 .Xr nlist 3 ) .
-For each symbol is looked up using the n_name field, and if found, the
+Each symbol is looked up using the n_name field, and if found, the
 corresponding n_type and n_value fields are filled in.  These fields are set
 to 0 if the symbol is not found.
 .Pp
 The program
 corresponding n_type and n_value fields are filled in.  These fields are set
 to 0 if the symbol is not found.
 .Pp
 The program
-.Fn kvm_mkdb
+.Xr kvm_mkdb 8
 builds a database from the running kernel's namelist.
 If the database matches the opened kernel,
 .Fn kvm_nlist
 builds a database from the running kernel's namelist.
 If the database matches the opened kernel,
 .Fn kvm_nlist
-uses it to speed name to value calculations.
+uses it to speed lookups.
 .Sh RETURN VALUES
 .Sh RETURN VALUES
+The
 .Fn kvm_nlist
 .Fn kvm_nlist
-returns the number of invalid entries found.
+function returns the number of invalid entries found.
 If the kernel symbol table was unreadable, -1 is returned.
 .Sh FILES
 .Bl -tag -width /var/db/kvm_vmunix.db -compact
 If the kernel symbol table was unreadable, -1 is returned.
 .Sh FILES
 .Bl -tag -width /var/db/kvm_vmunix.db -compact
@@ -45,4 +46,13 @@ If the kernel symbol table was unreadable, -1 is returned.
 .El
 .Sh SEE ALSO
 .Xr kvm 3 ,
 .El
 .Sh SEE ALSO
 .Xr kvm 3 ,
+.Xr kvm_close 3 ,
+.Xr kvm_getargv 3 ,
+.Xr kvm_getenvv 3 ,
+.Xr kvm_geterr 3 ,
+.Xr kvm_getprocs 3 ,
+.Xr kvm_open 3 ,
+.Xr kvm_openfiles 3 ,
+.Xr kvm_read 3 ,
+.Xr kvm_write 3 ,
 .Xr kvm_mkdb 8
 .Xr kvm_mkdb 8
index 4ac31bd..971a8b7 100644 (file)
@@ -3,13 +3,14 @@
 .\"
 .\" %sccs.include.redist.man%
 .\"
 .\"
 .\" %sccs.include.redist.man%
 .\"
-.\"     @(#)kvm_open.3 5.1 (Berkeley) %G%
+.\"     @(#)kvm_open.3 5.2 (Berkeley) %G%
 .\"
 .Dd 
 .Dt KVM_OPEN 3
 .Os
 .Sh NAME
 .Nm kvm_open ,
 .\"
 .Dd 
 .Dt KVM_OPEN 3
 .Os
 .Sh NAME
 .Nm kvm_open ,
+.Nm kvm_openfiles ,
 .Nm kvm_close
 .Nd initialize kernel virtual memory access
 .Sh SYNOPSIS
 .Nm kvm_close
 .Nd initialize kernel virtual memory access
 .Sh SYNOPSIS
@@ -23,6 +24,7 @@
 .Ft int
 .Fn kvm_close "kvm_t *kd"
 .Sh DESCRIPTION
 .Ft int
 .Fn kvm_close "kvm_t *kd"
 .Sh DESCRIPTION
+The functions
 .Fn kvm_open
 and 
 .Fn kvm_openfiles
 .Fn kvm_open
 and 
 .Fn kvm_openfiles
@@ -35,8 +37,12 @@ through this interface.
 .Fa execfile
 is the executable image of the kernel being examined.
 This file must contain a symbol table.
 .Fa execfile
 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,
-which is indicated by _PATH_UNIX in <paths.h>.
+If this argument is
+.Dv NULL ,
+the currently running system is assumed,
+which is indicated by
+.Dv _PATH_UNIX
+in <paths.h>.
 .Pp
 .Fa corefile 
 is the kernel memory device file.  It can be either /dev/mem
 .Pp
 .Fa corefile 
 is the kernel memory device file.  It can be either /dev/mem
@@ -44,18 +50,29 @@ or a crash dump core generated by
 .Xr savecore 8 .
 If
 .Fa corefile
 .Xr savecore 8 .
 If
 .Fa corefile
-is null, the default indicated by _PATH_MEM is used.
+is
+.Dv NULL ,
+the default indicated by
+.Dv _PATH_MEM
+from <paths.h> is used.
 .Pp
 .Fa swapfile
 .Pp
 .Fa swapfile
-should indicate the swap device.  If NULL, _PATH_DRUM from <paths.h>
-is used.
+should indicate the swap device.  If
+.Dv NULL ,
+.Dv _PATH_DRUM
+from <paths.h> is used.
 .Pp
 The
 .Fa flags 
 .Pp
 The
 .Fa flags 
-argument indicates the read/write access as in
+argument indicates read/write access as in
 .Xr open 2
 and applies to only the core file.
 .Xr open 2
 and applies to only the core file.
-Only O_RDONLY, O_WRONLY, and O_RDWR are permitted.
+Only
+.Dv O_RDONLY ,
+.Dv O_WRONLY ,
+and
+.Dv O_RDWR
+are permitted.
 .Pp
 There are two open routines which differ only with respect to 
 the error mechanism.
 .Pp
 There are two open routines which differ only with respect to 
 the error mechanism.
@@ -66,15 +83,20 @@ The
 .Fn kvm_open
 function is the Sun kvm compatible open call.  Here, the
 .Fa errstr
 .Fn kvm_open
 function is the Sun kvm compatible open call.  Here, the
 .Fa errstr
-argument indicates how errors should be handled.  If it is NULL,
-then no errors are reporting and the application cannot know the 
+argument indicates how errors should be handled.  If it is
+.Dv NULL ,
+no errors are reported and the application cannot know the 
 specific nature of the failed kvm call.
 specific nature of the failed kvm call.
-If it is not NULL, then errors are printed to stderr with 
+If it is not
+.Dv NULL ,
+errors are printed to stderr with 
 .Fa errstr
 prepended to the message, as in
 .Xr perror 3 .
 Normally, the name of the program is used here.
 .Fa errstr
 prepended to the message, as in
 .Xr perror 3 .
 Normally, the name of the program is used here.
-The string is assumed to be persistent.
+The string is assumed to persist at least until the corresponding
+.Fn kvm_close
+call.
 .Pp
 The
 .Fn kvm_openfiles
 .Pp
 The
 .Fn kvm_openfiles
@@ -89,31 +111,46 @@ The results are undefined if the most recent kvm call did not produce
 an error.
 Since
 .Fn kvm_geterr
 an error.
 Since
 .Fn kvm_geterr
-requires a kvm descriptor, but the open routines return NULL on failure,
+requires a kvm descriptor, but the open routines return
+.Dv NULL
+on failure,
 .Fn kvm_geterr
 cannot be used to get the error message if open fails.
 Thus,
 .Fn kvm_geterr
 cannot be used to get the error message if open fails.
 Thus,
-.Fn kvm_openfiles ,
+.Fn kvm_openfiles
 will place any error message in the
 .Fa errbuf
 argument.  This buffer should be _POSIX2_LINE_MAX characters large (from
 will place any error message in the
 .Fa errbuf
 argument.  This buffer should be _POSIX2_LINE_MAX characters large (from
-<limits.h>)
+<limits.h>).
 .Sh RETURN VALUES
 .Sh RETURN VALUES
+The
 .Fn kvm_open
 and 
 .Fn kvm_openfiles
 .Fn kvm_open
 and 
 .Fn kvm_openfiles
-both return a descriptor to be used in all subsequent kvm library calls.
+functions both return a descriptor to be used
+in all subsequent kvm library calls.
 The library is fully re-entrant.
 The library is fully re-entrant.
-On failure, NULL is returned, in which case
+On failure,
+.Dv NULL
+is returned, in which case
 .Fn kvm_openfiles
 writes the error message into 
 .Fa errbuf .
 .Pp
 .Fn kvm_openfiles
 writes the error message into 
 .Fa errbuf .
 .Pp
+The
 .Fn kvm_close
 .Fn kvm_close
-returns 0 on sucess and -1 on failure.
+function returns 0 on sucess and -1 on failure.
 .Sh 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.
 .Sh SEE ALSO
 .Sh 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.
 .Sh SEE ALSO
-.Xr kvm 3
+.Xr open 2 ,
+.Xr kvm 3 ,
+.Xr kvm_getargv 3 ,
+.Xr kvm_getenvv 3 ,
+.Xr kvm_geterr 3 ,
+.Xr kvm_getprocs 3 ,
+.Xr kvm_nlist 3 ,
+.Xr kvm_read 3 ,
+.Xr kvm_write 3
index bae63c4..10cd72c 100644 (file)
@@ -3,14 +3,14 @@
  * All rights reserved.
  *
  * This code is derived from software developed by the Computer Systems
  * All rights reserved.
  *
  * This code is derived from software developed by the Computer Systems
- * Engineering group at Lawrence Berkeley Laboratory under DARPA
- * contract BG 91-66 and contributed to Berkeley.
+ * Engineering group at Lawrence Berkeley Laboratory under DARPA contract
+ * BG 91-66 and contributed to Berkeley.
  *
  * %sccs.include.redist.c%
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  *
  * %sccs.include.redist.c%
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)kvm_sparc.c        5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)kvm_sparc.c        5.2 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 /*
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -29,7 +29,7 @@ static char sccsid[] = "@(#)kvm_sparc.c       5.1 (Berkeley) %G%";
 #include <vm/vm_param.h>
 
 #include <limits.h>
 #include <vm/vm_param.h>
 
 #include <limits.h>
-#include <ndbm.h>
+#include <db.h>
 
 #include "kvm_private.h"
 
 
 #include "kvm_private.h"