# kvm_t fields



## monono (Aug 10, 2013)

Hi, I am new to FreeBSD development (or any non-Linux Unix-like development), and am having trouble tracking down what exactly are the constituent parts of the kvm_t type.  If anyone has it on hand, or perhaps better yet, has a resource where I could find the definition of this struct and others like it, that would be great.


----------



## tmw (Aug 10, 2013)

Hello,

Download FreeBSD sources and check files /usr/src/lib/libkvm/kvm.h and /usr/src/lib/libkvm/kvm_private.h.


----------



## monono (Aug 12, 2013)

Thank you.  Posting the struct definition in case someone ends up here via a search:


```
struct __kvm {
    /*
     * a string to be prepended to error messages
     * provided for compatibility with sun's interface
     * if this value is null, errors are saved in errbuf[]
     */
    const char *program;
    char    *errp;        /* XXX this can probably go away */
    char    errbuf[_POSIX2_LINE_MAX];
#define ISALIVE(kd) ((kd)->vmfd >= 0)
    int    pmfd;        /* physical memory file (or crashdump) */
    int    vmfd;        /* virtual memory file (-1 if crashdump) */
    int    unused;        /* was: swap file (e.g., /dev/drum) */
    int    nlfd;        /* namelist file (e.g., /kernel) */
    struct kinfo_proc *procbase;
    char    *argspc;    /* (dynamic) storage for argv strings */
    int    arglen;        /* length of the above */
    char    **argv;        /* (dynamic) storage for argv pointers */
    int    argc;        /* length of above (not actual # present) */
    char    *argbuf;    /* (dynamic) temporary storage */
    /*
     * Kernel virtual address translation state.  This only gets filled
     * in for dead kernels; otherwise, the running kernel (i.e. kmem)
     * will do the translations for us.  It could be big, so we
     * only allocate it if necessary.
     */
    struct vmstate *vmst;
    int    rawdump;    /* raw dump format */
};
```


----------



## expl (Aug 13, 2013)

monono said:
			
		

> Hi, I am new to FreeBSD development (or any non-Linux Unix-like development), and am having trouble tracking down what exactly are the constituent parts of the kvm_t type.  If anyone has it on hand, or perhaps better yet, has a resource where I could find the definition of this struct and others like it, that would be great.



If you are dealing with tracking definition on regular basis, perhaps using an IDE would be a good solution. Most IDEs support definition tracking and will parse/search headers for you.


----------



## kpa (Aug 13, 2013)

No need to download the sources. You can browse them via the SVN browser at http://svnweb.freebsd.org/. For example, this is the lib/libkvm/kvm.h from HEAD as known as 10-CURRENT: http://svnweb.freebsd.org/base/head/lib/libkvm/kvm.h?view=markup


----------

