Update the 'ps', 'show pci', and 'show ktr' ddb commands to use the new

pager callout instead of homerolling their own paging facility.
This commit is contained in:
John Baldwin 2003-07-31 17:29:42 +00:00
parent 1e16f6098b
commit 3f2a1b0656
3 changed files with 21 additions and 80 deletions

View File

@ -55,13 +55,13 @@ db_ps(dummy1, dummy2, dummy3, dummy4)
db_expr_t dummy3;
char * dummy4;
{
int np;
int nl = 0;
volatile struct proc *p, *pp;
volatile struct thread *td;
char *state;
int np, quit;
np = nprocs;
quit = 0;
/* sx_slock(&allproc_lock); */
if (!LIST_EMPTY(&allproc))
@ -69,32 +69,9 @@ db_ps(dummy1, dummy2, dummy3, dummy4)
else
p = &proc0;
db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
db_printf(" pid proc addr uid ppid pgrp flag stat wmesg wchan cmd\n");
while (--np >= 0) {
/*
* XXX just take 20 for now...
*/
if (nl++ >= 20) {
int c;
db_printf("--More--");
c = cngetc();
db_printf("\r");
/*
* A whole screenfull or just one line?
*/
switch (c) {
case '\n': /* just one line */
nl = 20;
break;
case ' ':
nl = 0; /* another screenfull */
break;
default: /* exit */
db_printf("\n");
return;
}
}
while (--np >= 0 && !quit) {
if (p == NULL) {
printf("oops, ran out of processes early!\n");
break;
@ -131,7 +108,8 @@ db_ps(dummy1, dummy2, dummy3, dummy4)
db_printf("(threaded) %s\n", p->p_comm);
FOREACH_THREAD_IN_PROC(p, td) {
dumpthread(p, td);
nl++;
if (quit)
break;
}
/* PROC_UNLOCK(p); */

View File

@ -1274,19 +1274,19 @@ DB_SHOW_COMMAND(pciregs, db_pci_dump)
struct devlist *devlist_head;
struct pci_conf *p;
const char *name;
int i, error, none_count, nl;
int i, error, none_count, quit;
none_count = 0;
nl = 0;
/* get the head of the device queue */
devlist_head = &pci_devq;
/*
* Go through the list of devices and print out devices
*/
for (error = 0, i = 0,
db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
for (error = 0, i = 0, quit = 0,
dinfo = STAILQ_FIRST(devlist_head);
(dinfo != NULL) && (error == 0) && (i < pci_numdevs);
(dinfo != NULL) && (error == 0) && (i < pci_numdevs) && !quit;
dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
/* Populate pd_name and pd_unit */
@ -1295,31 +1295,6 @@ DB_SHOW_COMMAND(pciregs, db_pci_dump)
name = device_get_name(dinfo->cfg.dev);
p = &dinfo->conf;
/*
* XXX just take 20 for now...
*/
if (nl++ == 20) {
int c;
db_printf("--More--");
c = cngetc();
db_printf("\r");
/*
* A whole screenfull or just one line?
*/
switch (c) {
case '\n': /* just one line */
nl = 20;
break;
case ' ':
nl = 0; /* another screenfull */
break;
default: /* exit */
db_printf("\n");
return;
}
}
db_printf("%s%d@pci%d:%d:%d:\tclass=0x%06x card=0x%08x "
"chip=0x%08x rev=0x%02x hdr=0x%02x\n",
(name && *name) ? name : "none",

View File

@ -267,9 +267,9 @@ static int db_mach_vtrace(void);
DB_SHOW_COMMAND(ktr, db_ktr_all)
{
int c, lines;
int all = 0;
int c, quit;
quit = 0;
lines = NUM_LINES_PER_PAGE;
tstate.cur = (ktr_idx - 1) & (KTR_ENTRIES - 1);
tstate.first = -1;
@ -277,28 +277,16 @@ DB_SHOW_COMMAND(ktr, db_ktr_all)
db_ktr_verbose = 1;
else
db_ktr_verbose = 0;
if (strcmp(modif, "a") == 0)
all = 1;
while (db_mach_vtrace())
if (all) {
if (cncheckc() != -1)
return;
} else if (--lines == 0) {
db_printf("--More--");
c = cngetc();
db_printf("\r");
switch (c) {
case '\n': /* one more line */
lines = 1;
if (strcmp(modif, "a") == 0) {
while (cncheckc() != -1)
if (db_mach_vtrace() == 0)
break;
case ' ': /* one more page */
lines = NUM_LINES_PER_PAGE;
} else {
db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
while (!quit)
if (db_mach_vtrace() == 0)
break;
default:
db_printf("\n");
return;
}
}
}
}
static int