Add a "show all pages" command to DDB which prints one line per physical

page in the system.  Useful for getting some idea where all your memory's
gone, at least on a sufficiently small system.
This commit is contained in:
bjh21 2006-02-19 18:52:29 +00:00
parent 904145aa04
commit ed2f09f139
3 changed files with 38 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_command.c,v 1.83 2006/01/24 13:02:57 yamt Exp $ */
/* $NetBSD: db_command.c,v 1.84 2006/02/19 18:52:29 bjh21 Exp $ */
/*
* Mach Operating System
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.83 2006/01/24 13:02:57 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.84 2006/02/19 18:52:29 bjh21 Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -113,6 +113,7 @@ static void db_map_print_cmd(db_expr_t, int, db_expr_t, const char *);
static void db_namecache_print_cmd(db_expr_t, int, db_expr_t, const char *);
static void db_object_print_cmd(db_expr_t, int, db_expr_t, const char *);
static void db_page_print_cmd(db_expr_t, int, db_expr_t, const char *);
static void db_show_all_pages(db_expr_t, int, db_expr_t, const char *);
static void db_pool_print_cmd(db_expr_t, int, db_expr_t, const char *);
static void db_reboot_cmd(db_expr_t, int, db_expr_t, const char *);
static void db_sifting_cmd(db_expr_t, int, db_expr_t, const char *);
@ -129,6 +130,7 @@ static void db_mbuf_print_cmd(db_expr_t, int, db_expr_t, const char *);
static const struct db_command db_show_all_cmds[] = {
{ "callout", db_show_callout, 0, NULL },
{ "pages", db_show_all_pages, 0, NULL },
{ "procs", db_show_all_procs, 0, NULL },
{ "pools", db_show_all_pools, 0, NULL },
{ NULL, NULL, 0, NULL }
@ -576,6 +578,14 @@ db_page_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *mo
uvm_page_printit((struct vm_page *)(intptr_t) addr, full, db_printf);
}
/*ARGSUSED*/
static void
db_show_all_pages(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)
{
uvm_page_printall(db_printf);
}
/*ARGSUSED*/
static void
db_buf_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, const char *modif)

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_ddb.h,v 1.9 2005/12/11 12:25:29 christos Exp $ */
/* $NetBSD: uvm_ddb.h,v 1.10 2006/02/19 18:52:29 bjh21 Exp $ */
/*
*
@ -46,6 +46,7 @@ void uvm_object_printit(struct uvm_object *, boolean_t,
void (*)(const char *, ...));
void uvm_page_printit(struct vm_page *, boolean_t,
void (*)(const char *, ...));
void uvm_page_printall(void (*)(const char *, ...));
void uvmexp_print(void (*)(const char *, ...));
#endif /* DDB */

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_map.c,v 1.212 2006/02/15 14:06:45 yamt Exp $ */
/* $NetBSD: uvm_map.c,v 1.213 2006/02/19 18:52:29 bjh21 Exp $ */
/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.212 2006/02/15 14:06:45 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_map.c,v 1.213 2006/02/19 18:52:29 bjh21 Exp $");
#include "opt_ddb.h"
#include "opt_uvmhist.h"
@ -4637,6 +4637,28 @@ uvm_page_printit(struct vm_page *pg, boolean_t full,
(*pr)(" >>> PAGE NOT FOUND ON PAGEQ LIST! <<<\n");
}
}
/*
* uvm_pages_printthem - print a summary of all managed pages
*/
void
uvm_page_printall(void (*pr)(const char *, ...))
{
unsigned i;
struct vm_page *pg;
(*pr)("%18s %4s %2s %18s %18s\n",
"PAGE", "FLAG", "PQ", "UOBJECT", "UANON");
for (i = 0; i < vm_nphysseg; i++) {
for (pg = vm_physmem[i].pgs; pg <= vm_physmem[i].lastpg; pg++) {
(*pr)("%18p %04x %02x %18p %18p\n",
pg, pg->flags, pg->pqflags, pg->uobject,
pg->uanon);
}
}
}
#endif
/*