Skip to content

Instantly share code, notes, and snippets.

@kinichiro
Created August 13, 2014 08:33
Show Gist options
  • Save kinichiro/f32ad6ddc7908c137f80 to your computer and use it in GitHub Desktop.
Save kinichiro/f32ad6ddc7908c137f80 to your computer and use it in GitHub Desktop.
sample code for pstat_getprocvm()
/* test_pstat_getprocvm.c */
#include <stdio.h>
#include <sys/pstat.h>
int main() {
struct pst_vm_status buf;
if(pstat_getprocvm(&buf, sizeof(buf), 0, 0) != 1) {
perror("pstat_getprocvm()");
return -1;
}
printf("++++++++++----------++++++++++----------++++++++++----------\n");
printf("virtual space for this object = 0x%8.8x\n", buf.pst_space);
printf("virtual offset for this object = %d\n", buf.pst_vaddr);
printf("number of pages mapped by this object = %d\n", buf.pst_length);
printf("number of incore pages for this object = %d\n", buf.pst_phys_pages);
printf("disposition of this object = %d\n", buf.pst_flags);
printf("type of data managed by this object = %d\n", buf.pst_type);
printf("access permissions to this object = %d\n", buf.pst_permission);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment