Example #1
0
void
scan_queues(kvm_t *kd, int cpu, struct bufpcpu *bqp)
{
	struct buf b, *tmp;
	int q;

	for (q = 0; q < BUFFER_QUEUES; q++) {
		if (bqp->bufqueues[q].tqh_first == NULL)
			continue;
		kkread(kd, (u_long)bqp->bufqueues[q].tqh_first, &b, sizeof(b), 1);
		tmp = bqp->bufqueues[q].tqh_first;
		if (tmp != NULL)
			qcounter[q]++;
		while (tmp != NULL) {
			if (verboseopt)
				printf("cpu=%d queue=%8s buf=%p", cpu, q2s(q), tmp);
			tmp = b.b_freelist.tqe_next;
			if (kkread(kd, (u_long)tmp, &b, sizeof(b), 0) == -1) {
				if (verboseopt)
					printf(" [F] ");
				failcount++;
			}
			if (verboseopt)
				printf("\n");
			qcounter[q]++;
			totalcount++;	/* All scanned bufs */
		}
	}
}
Example #2
0
static
void
dumpinpcontainerhead(kvm_t *kd, int index, void *kptr)
{
    struct inpcontainerhead head;
    struct inpcontainer node;
    struct inpcb pcb;

    kkread(kd, (intptr_t)kptr, &head, sizeof(head));
    if (head.lh_first == NULL)
	return;
    printf("\tinpcontainer list at index %d {\n", index);
    for (kptr = head.lh_first; kptr; kptr = node.ic_list.le_next)  {
	kkread(kd, (intptr_t)kptr, &node, sizeof(node));
	printf("\t    inpcontainer %p inpcb %p", kptr, node.ic_inp);
	if (node.ic_inp) {
		printf(" {\n");
		kkread(kd, (intptr_t)node.ic_inp, &pcb, sizeof(pcb));
		printf("\t\tlocal %s:%d foreign %s:%d\n", 
			inet_ntoa(pcb.inp_inc.inc_laddr),
			ntohs(pcb.inp_inc.inc_lport),
			inet_ntoa(pcb.inp_inc.inc_faddr), 
			ntohs(pcb.inp_inc.inc_fport));
		printf("\t    }");
	}
	printf("\n");
    }
    printf("\t}\n");
}
Example #3
0
static
char *
getncppath(kvm_t *kd, struct nchandle *nch, char *base, int bytes)
{
    struct mount mntinfo;
    struct namecache ncp;
    struct namecache *ncpptr;

    ncpptr = nch->ncp;
    while (ncpptr) {
	kkread(kd, (long)ncpptr, &ncp, sizeof(ncp));
	if (ncp.nc_nlen >= bytes)
	    break;
	kkread(kd, (long)ncp.nc_name, base + bytes - ncp.nc_nlen, ncp.nc_nlen);
	bytes -= ncp.nc_nlen;
	if (ncp.nc_parent) {
	    base[--bytes] = '/';
	}
	ncpptr = ncp.nc_parent;
    }
    if (nch->mount) {
	kkread(kd, (long)nch->mount, &mntinfo, sizeof(mntinfo));
	if (mntinfo.mnt_ncmounton.mount)
	    return(getncppath(kd, &mntinfo.mnt_ncmounton, base, bytes));
    } else if (base[bytes] == 0) {
	base[--bytes] = '/';
    }
    return(base + bytes);
}
Example #4
0
/*
 * A page with an object.
 */
void
checkpage(kvm_t *kd, vm_page_t mptr, vm_page_t m, struct vm_object *obj)
{
#if 0
    struct vm_page scan;
    vm_page_t scanptr;
    int hv;

    hv = ((uintptr_t)m->object + m->pindex) ^ obj->hash_rand;
    hv &= vm_page_hash_mask;
    kkread(kd, (u_long)&vm_page_buckets[hv], &scanptr, sizeof(scanptr));
    while (scanptr) {
	if (scanptr == mptr)
	    break;
	kkread(kd, (u_long)scanptr, &scan, sizeof(scan));
	scanptr = scan.hnext;
    }
    if (scanptr) {
	if (debugopt > 1)
	    printf("good checkpage %p bucket %d\n", mptr, hv);
    } else {
	printf("vm_page_buckets[%d] ((struct vm_page *)%p)"
		" page not found in bucket list\n", hv, mptr);
    }
#endif
}
Example #5
0
static void
mapscan(kvm_t *kd, vm_map_entry_t entryp, vm_offset_t *lastp)
{
    struct vm_map_entry entry;

    if (entryp == NULL)
	return;
    kkread(kd, (u_long)entryp, &entry, sizeof(entry));
    mapscan(kd, entry.rb_entry.rbe_left, lastp);
    if (*lastp != entry.start) {
	    printf("%4ldM %p %08lx-%08lx (%6ldK) EMPTY\n",
		total_used / 1024 / 1024,
		entryp,
		*lastp, entry.start,
		(entry.start - *lastp) / 1024);
	    total_empty += entry.start - *lastp;
    }
    printf("%4ldM %p %08lx-%08lx (%6ldK) type=%d object=%p\n",
	total_used / 1024 / 1024,
	entryp,
	entry.start, entry.end,
	(entry.end - entry.start) / 1024,
	entry.maptype,
	entry.object);
    total_used += entry.end - entry.start;
    *lastp = entry.end;
    mapscan(kd, entry.rb_entry.rbe_right, lastp);
}
Example #6
0
static struct mount *
dumpmount(kvm_t *kd, struct mount *mp)
{
    struct mount mnt;
    struct vnode *vp;

    kkread(kd, (u_long)mp, &mnt, sizeof(mnt));
    printf("MOUNTPOINT %s on %s {\n", 
	mnt.mnt_stat.f_mntfromname, mnt.mnt_stat.f_mntonname);
    printf("    lk_flags %08x count %08x holder = %p\n",
	mnt.mnt_lock.lk_flags, mnt.mnt_lock.lk_count,
	mnt.mnt_lock.lk_lockholder);
    printf("    mnt_flag %08x mnt_kern_flag %08x\n", 
	mnt.mnt_flag, mnt.mnt_kern_flag);
    printf("    mnt_nvnodelistsize %d\n", mnt.mnt_nvnodelistsize);
    printf("    mnt_stat.f_fsid %08x %08x\n", mnt.mnt_stat.f_fsid.val[0],
	mnt.mnt_stat.f_fsid.val[1]);
    vp = mnt.mnt_nvnodelist.tqh_first;
    while (vp)
	vp = dumpvp(kd, vp, 1);

    printf("}\n");

    return(mnt.mnt_list.tqe_next);
}
Example #7
0
static
void
printvfc(kvm_t *kd, struct vfsconf *vfc)
{
    struct vfsconf vfcinfo;

    kkread(kd, (long)vfc, &vfcinfo, sizeof(vfcinfo));
    printf("%s [type %d]", vfcinfo.vfc_name, vfcinfo.vfc_typenum);
}
Example #8
0
static
int
getobjpages(kvm_t *kd, struct vm_object *obj)
{
	struct vm_object vmobj;

	kkread(kd, (u_long)obj, &vmobj, sizeof(vmobj));
	return(vmobj.resident_page_count);
}
Example #9
0
static
int
getobjvnpsize(kvm_t *kd, struct vm_object *obj)
{
	struct vm_object vmobj;

	kkread(kd, (u_long)obj, &vmobj, sizeof(vmobj));
	return ((int)vmobj.size);
}
Example #10
0
static
void
dumptcb(kvm_t *kd, intptr_t tcbaddr)
{
    struct inpcbinfo info;
    struct inpcbportinfo pinfo;
    int i;

    kkread(kd, tcbaddr, &info, sizeof(info));
    kkread(kd, (intptr_t)info.portinfo, &pinfo, sizeof(pinfo));
    printf("    hashbase %p\n", info.hashbase);
    printf("    hashmask %ld\n", info.hashmask);
    printf("    porthashbase %p\n", pinfo.porthashbase);
    printf("    porthashmask %lu\n", pinfo.porthashcnt);
    printf("    wildcardhashbase %p\n", info.wildcardhashbase);
    printf("    wildcardhashmask %lu\n", info.wildcardhashmask);
    printf("    ipi_size %zu\n", info.ipi_size);
    printf("    ipi_count %d\n", (int)info.ipi_count);
    printf("    ipi_gencnt %lld\n", (long long)info.ipi_gencnt);
    printf("    cpu %d\n", info.cpu);
    for (i = 0; i <= info.wildcardhashmask; ++i)
	dumpinpcontainerhead(kd, i, info.wildcardhashbase + i);
}
Example #11
0
static void
dumplocks(kvm_t *kd, struct lockf *lockf)
{
	struct lockf_range item;
	struct lockf_range *scan;

	if ((scan = TAILQ_FIRST(&lockf->lf_range)) != NULL) {
		printf("\tLOCKS\n");
		do {
			kkread(kd, (u_long)scan, &item, sizeof(item));
			dumplockinfo(kd, &item);
		} while ((scan = TAILQ_NEXT(&item, lf_link)) != NULL);
		printf("\n");
	}
	if ((scan = TAILQ_FIRST(&lockf->lf_blocked)) != NULL) {
		printf("\tBLKED\n");
		do {
			kkread(kd, (u_long)scan, &item, sizeof(item));
			dumplockinfo(kd, &item);
		} while ((scan = TAILQ_NEXT(&item, lf_link)) != NULL);
		printf("\n");
	}

}
Example #12
0
int
slzonedump(kvm_t *kd, SLZone *kslz)
{
    SLZone slz;
    int count = 0;

    while (kslz) {
	kkread(kd, (u_long)kslz, &slz, sizeof(slz));
	printf("\t{ magic=%08x cpu=%d chunking=%d NFree=%d/%d RCnt=%d}\n",
		slz.z_Magic, slz.z_Cpu, slz.z_ChunkSize,
		slz.z_NFree, slz.z_NMax, slz.z_RCount);
	kslz = slz.z_Next;
	++count;
    }
    return(count);
}
Example #13
0
static void
dumplockinfo(kvm_t *kd, struct lockf_range *item)
{
	int ownerpid;

	if (item->lf_owner && (item->lf_flags & F_POSIX)) {
		kkread(kd, (u_long)&item->lf_owner->p_pid,
			&ownerpid, sizeof(ownerpid));
	} else {
		ownerpid = -1;
	}

	printf("\t    ty=%d flgs=%04x %lld-%lld owner=%d\n",
		item->lf_type, item->lf_flags,
		item->lf_start, item->lf_end,
		ownerpid
	);
}
Example #14
0
static void
dumpbufs(kvm_t *kd, void *bufp, const char *id)
{
	struct buf buf;

	kkread(kd, (u_long)bufp, &buf, sizeof(buf));
	printf("\t    %-8s %p loffset %012llx/%05x foffset %08llx",
		id, bufp,
		buf.b_bio1.bio_offset,
		buf.b_bufsize,
		buf.b_bio2.bio_offset);
	printf(" q=%d count=%08x flags=%08x refs=%08x dep=%p",
		buf.b_qindex, buf.b_lock.lk_count,
		buf.b_flags, buf.b_refs, buf.b_dep.lh_first);
	printf("\n");

	if (buf.b_rbnode.rbe_left)
	    dumpbufs(kd, buf.b_rbnode.rbe_left, "LEFT");
	if (buf.b_rbnode.rbe_right)
	    dumpbufs(kd, buf.b_rbnode.rbe_right, "RIGHT");
}
Example #15
0
int
main(int ac, char **av)
{
    kvm_t *kd;
    int i;
    int ch;
    int ncpus;
    const char *corefile = NULL;
    const char *sysfile = NULL;

    while ((ch = getopt(ac, av, "M:N:")) != -1) {
	switch(ch) {
	case 'M':
	    corefile = optarg;
	    break;
	case 'N':
	    sysfile = optarg;
	    break;
	default:
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }
    kkread(kd, Nl[0].n_value, &ncpus, sizeof(ncpus));
    for (i = 0; i < ncpus; ++i) {
	printf("CPU %d\n", i);
	dumptcb(kd, (intptr_t)Nl[1].n_value + i * sizeof(struct inpcbinfo));
    }
    return(0);
}
Example #16
0
int
main(int ac, char **av)
{
    struct nchandle nch;
    struct mount mntinfo;
    struct mount *mntptr;
    struct mntlist list;
    kvm_t *kd;
    const char *corefile = NULL;
    const char *sysfile = NULL;
    const char *path;
    int ch;
    int i;
    int n;
    char mntpath[1024];

    while ((ch = getopt(ac, av, "M:N:")) != -1) {
	switch(ch) {
	case 'M':
	    corefile = optarg;
	    break;
	case 'N':
	    sysfile = optarg;
	    break;
	default:
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }
    ac -= optind;
    av += optind;

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }
    kkread(kd, Nl[0].n_value, &nch, sizeof(nch));
    kkread(kd, Nl[1].n_value, &list, sizeof(list));

    mntptr = TAILQ_FIRST(&list);
    while (mntptr) {
	kkread(kd, (long)mntptr, &mntinfo, sizeof(mntinfo));
	printf("MOUNT %p ", mntptr);
	if (mntinfo.mnt_vfc) {
	    printvfc(kd, mntinfo.mnt_vfc);
	    printf(" ");
	}
	mntpath[sizeof(mntpath)-1] = 0;
	path = getncppath(kd, &mntinfo.mnt_ncmounton,
			  mntpath, sizeof(mntpath) - 1);
	printf("ON %s\n", path);
	if (ac == 0) {
	    dumpncp(kd, 0, mntinfo.mnt_ncmountpt.ncp, NULL);
	} else {
	    n = strlen(path);
	    for (i = 0; i < ac; ++i) {
		if (strncmp(path, av[i], n) == 0) {
		    dumpncp(kd, 0, mntinfo.mnt_ncmountpt.ncp, av[i] + n);
		}
	    }
	}
	mntptr = TAILQ_NEXT(&mntinfo, mnt_list);
    }
}
Example #17
0
int
main(int ac, char **av)
{
    const char *corefile = NULL;
    const char *sysfile = NULL;
    vm_page_t mptr;
    struct vm_page m;
    struct vm_object obj;
    kvm_t *kd;
    int ch;
    int hv;
    int i;
    const char *qstr;
    const char *ostr;

    while ((ch = getopt(ac, av, "M:N:dv")) != -1) {
	switch(ch) {
	case 'd':
	    ++debugopt;
	    break;
	case 'v':
	    ++verboseopt;
	    break;
	case 'M':
	    corefile = optarg;
	    break;
	case 'N':
	    sysfile = optarg;
	    break;
	default:
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }
    ac -= optind;
    av += optind;

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }

#if 0
    kkread(kd, Nl[0].n_value, &vm_page_buckets, sizeof(vm_page_buckets));
    kkread(kd, Nl[1].n_value, &vm_page_hash_mask, sizeof(vm_page_hash_mask));
#endif
    kkread(kd, Nl[0].n_value, &vm_page_array, sizeof(vm_page_array));
    kkread(kd, Nl[1].n_value, &vm_page_array_size, sizeof(vm_page_array_size));

    /*
     * Scan the vm_page_array validating all pages with associated objects
     */
    for (i = 0; i < vm_page_array_size; ++i) {
	if (debugopt) {
	    printf("page %d\r", i);
	    fflush(stdout);
	}
	kkread(kd, (u_long)&vm_page_array[i], &m, sizeof(m));
	if (m.object) {
	    kkread(kd, (u_long)m.object, &obj, sizeof(obj));
	    checkpage(kd, &vm_page_array[i], &m, &obj);
	}
	if (verboseopt) {
	    if (m.queue >= PQ_HOLD) {
		qstr = "HOLD";
	    } else if (m.queue >= PQ_CACHE) {
		qstr = "CACHE";
	    } else if (m.queue >= PQ_ACTIVE) {
		qstr = "ACTIVE";
	    } else if (m.queue >= PQ_INACTIVE) {
		qstr = "INACTIVE";
	    } else if (m.queue >= PQ_FREE) {
		qstr = "FREE";
	    } else {
		qstr = "NONE";
	    } 
	    printf("page %p obj %p/%-8jd val=%02x dty=%02x hold=%d "
		   "wire=%-2d act=%-3d busy=%d %8s",
		&vm_page_array[i],
		m.object,
		(intmax_t)m.pindex,
		m.valid,
		m.dirty,
		m.hold_count,
		m.wire_count,
		m.act_count,
		m.busy,
		qstr
	    );
	    switch(obj.type) {
	    case OBJT_DEFAULT:
		ostr = "default";
		break;
	    case OBJT_SWAP:
		ostr = "swap";
		break;
	    case OBJT_VNODE:
		ostr = "vnode";
		break;
	    case OBJT_DEVICE:
		ostr = "device";
		break;
	    case OBJT_PHYS:
		ostr = "phys";
		break;
	    case OBJT_DEAD:
		ostr = "dead";
		break;
	    default:
		ostr = "unknown";
		break;
	    }
	    printf(" %-7s", ostr);
	    if (m.flags & PG_BUSY)
		printf(" BUSY");
	    if (m.flags & PG_WANTED)
		printf(" WANTED");
	    if (m.flags & PG_WINATCFLS)
		printf(" WINATCFLS");
	    if (m.flags & PG_FICTITIOUS)
		printf(" FICTITIOUS");
	    if (m.flags & PG_WRITEABLE)
		printf(" WRITEABLE");
	    if (m.flags & PG_MAPPED)
		printf(" MAPPED");
	    if (m.flags & PG_ZERO)
		printf(" ZERO");
	    if (m.flags & PG_REFERENCED)
		printf(" REFERENCED");
	    if (m.flags & PG_CLEANCHK)
		printf(" CLEANCHK");
	    if (m.flags & PG_SWAPINPROG)
		printf(" SWAPINPROG");
	    if (m.flags & PG_NOSYNC)
		printf(" NOSYNC");
	    if (m.flags & PG_UNMANAGED)
		printf(" UNMANAGED");
	    if (m.flags & PG_MARKER)
		printf(" MARKER");
	    if (m.flags & PG_RAM)
		printf(" RAM");
	    if (m.flags & PG_SWAPPED)
		printf(" SWAPPED");
	    printf("\n");
	}
    }
    if (debugopt || verboseopt)
	printf("\n");

#if 0
    /*
     * Scan the vm_page_buckets array validating all pages found
     */
    for (i = 0; i <= vm_page_hash_mask; ++i) {
	if (debugopt) {
	    printf("index %d\r", i);
	    fflush(stdout);
	}
	kkread(kd, (u_long)&vm_page_buckets[i], &mptr, sizeof(mptr));
	while (mptr) {
	    kkread(kd, (u_long)mptr, &m, sizeof(m));
	    if (m.object) {
		kkread(kd, (u_long)m.object, &obj, sizeof(obj));
		hv = ((uintptr_t)m.object + m.pindex) ^ obj.hash_rand;
		hv &= vm_page_hash_mask;
		if (i != hv)
		    printf("vm_page_buckets[%d] ((struct vm_page *)%p)"
			" should be in bucket %d\n", i, mptr, hv);
		checkpage(kd, mptr, &m, &obj);
	    } else {
		printf("vm_page_buckets[%d] ((struct vm_page *)%p)"
			" has no object\n", i, mptr);
	    }
	    mptr = m.hnext;
	}
    }
#endif
    if (debugopt)
	printf("\n");
    return(0);
}
Example #18
0
static void
dumpncp(kvm_t *kd, int tab, struct namecache *ncptr, const char *path)
{
    struct namecache ncp;
    struct namecache *ncscan;
    const char *ptr;
    int haschildren;
    char name[256];

    kkread(kd, (u_long)ncptr, &ncp, sizeof(ncp));
    if (ncp.nc_nlen < sizeof(name)) {
	kkread(kd, (u_long)ncp.nc_name, name, ncp.nc_nlen);
	name[ncp.nc_nlen] = 0;
    } else {
	name[0] = 0;
    }
    if (tab == 0) {
	strcpy(name, "FSROOT");
	if (path && *path == '/')
	    ++path;
    } else if (name[0] == 0) {
	strcpy(name, "?");
	if (path)
	    return;
    } else if (path) {
	if ((ptr = strchr(path, '/')) == NULL)
	    ptr = path + strlen(path);
	if (strlen(name) != ptr - path ||
	    bcmp(name, path, ptr - path) != 0
	) {
	    return;
	}
	path = ptr;
	if (*path == '/')
	    ++path;
    }
    if (path && *path == 0)
	path = NULL;

    if (ncp.nc_list.tqh_first)
	haschildren = 1;
    else
	haschildren = 0;

    if (path)
	printf("ELM ");
    else
	printf("%*.*s%s ", tab, tab, "", name);
    printf("[ncp=%p par=%p %04x vp=%p", 
	    ncptr, ncp.nc_parent, ncp.nc_flag, ncp.nc_vp);
    if (ncp.nc_timeout)
	printf(" timo=%d", ncp.nc_timeout);
    if (ncp.nc_refs)
	printf(" refs=%d", ncp.nc_refs);
    if ((ncp.nc_flag & NCF_UNRESOLVED) == 0 && ncp.nc_error)
	printf(" error=%d", ncp.nc_error);
    if (ncp.nc_flag & NCF_ISMOUNTPT)
	printf(" MAYBEMOUNT");
    if (ncp.nc_lockstatus)
	printf(" LOCKSTATUS(%08x,td=%p)", ncp.nc_lockstatus, ncp.nc_locktd);
    printf("]");

    if (path) {
	printf(" %s\n", name);
    } else {
	printf("%s\n", haschildren ? " {" : "");
    }
    for (ncscan = ncp.nc_list.tqh_first; ncscan; ncscan = ncp.nc_entry.tqe_next) {
	kkread(kd, (u_long)ncscan, &ncp, sizeof(ncp));
	dumpncp(kd, (path ? (tab ? tab : 4) : tab + 4), ncscan, path);
    }
    if (haschildren && path == NULL)
	printf("%*.*s}\n", tab, tab, "");
}
Example #19
0
int
main(int ac, char **av)
{
    const char *corefile = NULL;
    const char *sysfile = NULL;
    kvm_t *kd;
    int ch;
    int i;
    int j;
    int ncpus;
    int totalzones;
    int totalfree;
    struct globaldata gd;

    while ((ch = getopt(ac, av, "M:N:dv")) != -1) {
	switch(ch) {
	case 'd':
	    ++debugopt;
	    break;
	case 'v':
	    ++verboseopt;
	    break;
	case 'M':
	    corefile = optarg;
	    break;
	case 'N':
	    sysfile = optarg;
	    break;
	default:
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }
    ac -= optind;
    av += optind;

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }

    kkread(kd, Nl[1].n_value, &ncpus, sizeof(int));
    totalzones = 0;
    totalfree = 0;
    for (i = 0; i < ncpus; ++i) {
	kkread(kd, Nl[0].n_value + i * sizeof(struct privatespace), &gd, sizeof(gd));
	printf("CPU %02d (NFreeZones=%d) {\n",
		i, gd.gd_slab.NFreeZones);
	totalfree += gd.gd_slab.NFreeZones;

	for (j = 0; j < NZONES; ++j) {
		printf("    Zone %02d {\n", j);
		totalzones += slzonedump(kd, gd.gd_slab.ZoneAry[j]);
		printf("    }\n");
	}

	printf("    FreeZone {\n");
	totalzones += slzonedump(kd, gd.gd_slab.FreeZones);
	printf("    }\n");

	printf("    FreeOVZon {\n");
	totalzones += slzonedump(kd, gd.gd_slab.FreeOvZones);
	printf("    }\n");

	printf("}\n");
    }
    printf("TotalZones %d x 131072 = %jd\n",
	totalzones, (intmax_t)totalzones * 131072LL);
    printf("TotalFree  %d x 131072 = %jd\n",
	totalfree, (intmax_t)totalfree * 131072LL);
    return(0);
}
Example #20
0
int
main(int ac, char **av)
{
    const char *corefile = NULL;
    const char *sysfile = NULL;
    vm_page_t mptr;
    struct vm_page m;
    struct vm_object obj;
    kvm_t *kd;
    int ch;
    int hv;
    int i;
    const char *qstr;
    const char *ostr;
    vm_offset_t last;

    while ((ch = getopt(ac, av, "M:N:dv")) != -1) {
	switch(ch) {
	case 'd':
	    ++debugopt;
	    break;
	case 'v':
	    ++verboseopt;
	    break;
	case 'M':
	    corefile = optarg;
	    break;
	case 'N':
	    sysfile = optarg;
	    break;
	default:
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }
    ac -= optind;
    av += optind;

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }
    kkread(kd, Nl[0].n_value, &kmap, sizeof(kmap));
    last = kmap.header.start;
    mapscan(kd, kmap.rb_root.rbh_root, &last);

    printf("%4ldM 0x%016jx %08lx-%08lx (%6ldK) EMPTY\n",
	total_used / 1024 / 1024,
	(intmax_t)NULL,
	last, kmap.header.end,
	(kmap.header.end - last) / 1024);
    total_empty += kmap.header.end - last;

    printf("-----------------------------------------------\n");
    printf("Total empty space: %7ldK\n", total_empty / 1024);
    printf("Total used  space: %7ldK\n", total_used / 1024);
}
Example #21
0
static struct vnode *
dumpvp(kvm_t *kd, struct vnode *vp, int whichlist)
{
    struct vnode vn;

    kkread(kd, (u_long)vp, &vn, sizeof(vn));

    printf("    vnode %p.%d refcnt %08x auxcnt %d type=%s flags %08x",
	vp, vn.v_state, vn.v_refcnt, vn.v_auxrefs, vtype(vn.v_type), vn.v_flag);

    if ((vn.v_flag & VOBJBUF) && vn.v_object) {
	int npages = getobjpages(kd, vn.v_object);
	int vnpsize = getobjvnpsize(kd, vn.v_object);
	if (npages || vnpsize)
	    printf(" vmobjpgs=%d vnpsize=%d", npages, vnpsize);
    }

    if (vn.v_flag & VROOT)
	printf(" VROOT");
    if (vn.v_flag & VTEXT)
	printf(" VTEXT");
    if (vn.v_flag & VSYSTEM)
	printf(" VSYSTEM");
    if (vn.v_flag & VISTTY)
	printf(" VISTTY");
#ifdef VXLOCK
    if (vn.v_flag & VXLOCK)
	printf(" VXLOCK");
    if (vn.v_flag & VXWANT)
	printf(" VXWANT");
#endif
#ifdef VRECLAIMED
    if (vn.v_flag & VRECLAIMED)
	printf(" VRECLAIMED");
    if (vn.v_flag & VINACTIVE)
	printf(" VINACTIVE");
#endif
    if (vn.v_flag & VOBJBUF)
	printf(" VOBJBUF");
#ifdef VSWAPCACHE
    if (vn.v_flag & VSWAPCACHE)
	printf(" VSWAPCACHE");
#endif
    switch(vn.v_flag & (VAGE0 | VAGE1)) {
    case 0:
	printf(" VAGE0");
	break;
    case VAGE0:
	printf(" VAGE1");
	break;
    case VAGE1:
	printf(" VAGE2");
	break;
    case VAGE0 | VAGE1:
	printf(" VAGE3");
	break;
    }
#ifdef VDOOMED
    if (vn.v_flag & VDOOMED)
	printf(" VDOOMED");
#endif
#ifdef VINFREE
    if (vn.v_flag & VINFREE)
	printf(" VINFREE");
#endif
    if (vn.v_flag & VONWORKLST)
	printf(" VONWORKLST");
    if (vn.v_flag & VOBJDIRTY)
	printf(" VOBJDIRTY");
    if (vn.v_flag & VMAYHAVELOCKS)
	printf(" VMAYHAVELOCKS");

    printf("\n");

    if (vn.v_lock.lk_count || vn.v_lock.lk_lockholder != LK_NOTHREAD) {
	printf("\tlk_flags %08x count %08x holder = %p\n",
	    vn.v_lock.lk_flags, vn.v_lock.lk_count,
	    vn.v_lock.lk_lockholder);
    }

    if (withnames && TAILQ_FIRST(&vn.v_namecache)) {
	struct namecache ncp;
	int nlen;
	char buf[1024];

	kkread(kd, (u_long)TAILQ_FIRST(&vn.v_namecache), &ncp, sizeof(ncp));
	if ((nlen = ncp.nc_nlen) >= sizeof(buf))
		nlen = sizeof(buf) - 1;
	if (nlen < 0)
		nlen = 0;
	if (nlen) {
		kkread(kd, (u_long)ncp.nc_name, buf, nlen);
		buf[nlen] = 0;
		printf("\tfilename %s\n", buf);
	}
    }

    if (tracebufs) {
	if (vn.v_rbclean_tree.rbh_root) {
	    printf("\tCLEAN BUFFERS\n");
	    dumpbufs(kd, vn.v_rbclean_tree.rbh_root, "ROOT");
	}
	if (vn.v_rbdirty_tree.rbh_root) {
	    printf("\tDIRTY BUFFERS\n");
	    dumpbufs(kd, vn.v_rbdirty_tree.rbh_root, "ROOT");
	}
    }

    if (tracelocks) {
	if (vn.v_tag == VT_UFS && vn.v_data) {
	    struct inode *ip = vn.v_data;
	    struct lockf lockf;

	    kkread(kd, (u_long)&ip->i_lockf, &lockf, sizeof(lockf));
	    dumplocks(kd, &lockf);
	}
    }


    if (whichlist)
	return(vn.v_nmntvnodes.tqe_next);
    else
	return(vn.v_list.tqe_next);
}
Example #22
0
int
main(int ac, char **av)
{
    const char *corefile = NULL;
    const char *sysfile = NULL;
    struct bufpcpu bpcpu;
    struct timespec delay = { 1, 0 };
    kvm_t *kd;
    int count;
    int ncpus;
    int ch;
    int cpu;
    int q;

    while ((ch = getopt(ac, av, "M:N:v")) != -1) {
	switch(ch) {
	case 'v':
	    ++verboseopt;
	    break;
	case 'M':
	    corefile = optarg;
	    break;
	case 'N':
	    sysfile = optarg;
	    break;
	default:
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }
    ac -= optind;
    av += optind;

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }

    if (ac > 0)
	    loaddelay(&delay, av[0]);

    kkread(kd, Nl[1].n_value, &ncpus, sizeof(ncpus), 1);
    kkread(kd, Nl[2].n_value, &nbuf, sizeof(nbuf), 1);

    for (count = 0; ; ++count) {
	    for (cpu = 0; cpu < ncpus; cpu++) {
		    kkread(kd, Nl[0].n_value + cpu * sizeof(struct bufpcpu),
			&bpcpu, sizeof(struct bufpcpu), 1);
		    scan_queues(kd, cpu, &bpcpu);
	    }

	    if (count && !verboseopt) {
		    if ((count & 15) == 1)
			    printf("  NONE  LOCKED  CLEAN  DIRTY  "
				"DIRTY_HW  EMPTYKVA  EMPTY  OFF-QUEUE KVMFAIL\n");
		    printf("%6d %7d %6d %6d %9d %9d %6d %10d %7d\n",
			qcounter[0], qcounter[1], qcounter[2],
			qcounter[3], qcounter[4], qcounter[5],
			qcounter[6], (nbuf - totalcount), failcount);
	    }

	    /* If in verbose mode only output detailed bufs info once */
	    if (verboseopt)
		    break;
	    nanosleep(&delay, NULL);
	    bzero(&qcounter, sizeof(qcounter));
	    totalcount = 0;
	    failcount = 0;
    }
    return(0);
}
Example #23
0
int
main(int ac, char **av)
{
    struct mount *mp;
    struct vnode *vp;
    kvm_t *kd;
    int i;
    int ch;
    const char *corefile = NULL;
    const char *sysfile = NULL;

    while ((ch = getopt(ac, av, "alnbM:N:")) != -1) {
	switch(ch) {   
	case 'b':
	    tracebufs = 1;
	    break;
	case 'n':
	    withnames = 1;
	    break;
	case 'l':
	    tracelocks = 1;
	    break;
	case 'a':
	    tracebufs = 1;
	    tracelocks = 1;
	    withnames = 1;
	    break;
	case 'M':
	    corefile = optarg;
	    break;
	case 'N': 
	    sysfile = optarg;
	    break; 
	default:  
	    fprintf(stderr, "%s [-M core] [-N system]\n", av[0]);
	    exit(1);
	}
    }

    if ((kd = kvm_open(sysfile, corefile, NULL, O_RDONLY, "kvm:")) == NULL) {
	perror("kvm_open");
	exit(1);
    }
    if (kvm_nlist(kd, Nl) != 0) {
	perror("kvm_nlist");
	exit(1);
    }
    kkread(kd, Nl[0].n_value, &mp, sizeof(mp));
    while (mp)
	mp = dumpmount(kd, mp);
    printf("INACTIVELIST {\n");
    kkread(kd, Nl[1].n_value, &vp, sizeof(vp));
    while (vp)
	vp = dumpvp(kd, vp, 0);
    printf("}\n");
    printf("ACTIVELIST {\n");
    kkread(kd, Nl[2].n_value, &vp, sizeof(vp));
    while (vp)
	vp = dumpvp(kd, vp, 0);
    printf("}\n");
    return(0);
}