In message <[EMAIL PROTECTED]>, Tabor Kelly writes:
>Now that that is taken care of, would somebody mind explaining to me
>what n_value represents? Is it an offset in kernel memory to retrieve
>the actual data?
It is the kernel virtual address of the symbol that you specified
in n_name, which will be the same as an in-kernel pointer value
(e.g. something like 0xc0123456). This address has no meaning in
userland, but libkvm provides a kvm_read() function that does all
the magic necessary to read from the kernel memory at this address.
There are lots of examples of code using the libkvm interface in
the FreeBSD source tree (fstat, ps, vmstat, pstat etc.) although
many of these now use sysctl to retrieve values instead. Briefly,
you just kvm_read the value of the variable whose symbol address
you have found, e.g. something like the code below, but you'll want
to add code to deal with any errors that the kvm_* calls might
return.
struct nlist nl[] = {
{"nextpid"},
{NULL},
};
int nextpid;
kd = kvm_openfiles(...);
kvm_nlist(kd, nl);
kvm_read(kd, nl[0].n_value, &nextpid, sizeof(nextpid));
printf("nextpid is %d\n", nextpid);
Ian
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message