From 3f2a1b0656646ef7f34b3baac5f9461305f4920c Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 31 Jul 2003 17:29:42 +0000 Subject: [PATCH] Update the 'ps', 'show pci', and 'show ktr' ddb commands to use the new pager callout instead of homerolling their own paging facility. --- sys/ddb/db_ps.c | 34 ++++++---------------------------- sys/dev/pci/pci.c | 33 ++++----------------------------- sys/kern/kern_ktr.c | 34 +++++++++++----------------------- 3 files changed, 21 insertions(+), 80 deletions(-) diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index e706cd7302fa..55aa86ba42b3 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -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); */ diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index f4681f14c3a4..e8e82452208b 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -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", diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 13d0526b9519..321e86f0f58b 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -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