From 591faa2e45d9ae277d5f8a4a76832937cec92003 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 20 Feb 2001 09:53:27 +0000 Subject: [PATCH] - Abolish the 'show ktr_first' and 'show ktr_next' commands. - Add pager capability to the 'show ktr' command. It functions much like 'ps': Enter at the prompt displays one more entry, Space displays another page, and any other key quits. --- sys/kern/kern_ktr.c | 80 ++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 41 deletions(-) diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index 09c5327db193..cde019a509d0 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -185,40 +185,36 @@ static struct tstate tstate; static int db_ktr_verbose; static int db_mach_vtrace(void); -DB_SHOW_COMMAND(ktr_first, db_ktr_first) -{ +#define NUM_LINES_PER_PAGE 18 +DB_SHOW_COMMAND(ktr, db_ktr_all) +{ + int c, lines; + + lines = NUM_LINES_PER_PAGE; tstate.cur = (ktr_idx - 1) & (KTR_ENTRIES - 1); tstate.first = -1; if (strcmp(modif, "v") == 0) db_ktr_verbose = 1; else db_ktr_verbose = 0; - db_mach_vtrace(); - - return; -} - -DB_SHOW_COMMAND(ktr, db_ktr_all) -{ - int c; - - db_ktr_first(addr, have_addr, count, modif); - while (db_mach_vtrace()) { - c = cncheckc(); - if (c != -1) - break; - } - - return; -} - -DB_SHOW_COMMAND(ktr_next, db_ktr_next) -{ - - if (strcmp(modif, "v") == 0) - db_ktr_verbose ^= 1; - db_mach_vtrace(); + while (db_mach_vtrace()) + if (--lines == 0) { + db_printf("--More--"); + c = cngetc(); + db_printf("\r"); + switch (c) { + case '\n': /* one more line */ + lines = 1; + break; + case ' ': /* one more page */ + lines = NUM_LINES_PER_PAGE; + break; + default: + db_printf("\n"); + return; + } + } } static int @@ -234,27 +230,29 @@ db_mach_vtrace(void) /* Skip over unused entries. */ #ifdef KTR_EXTEND - if (kp->ktr_desc[0] != '\0') { + if (kp->ktr_desc[0] == '\0') { #else - if (kp->ktr_desc != NULL) { + if (kp->ktr_desc == NULL) { #endif - db_printf("%d: ", tstate.cur); - if (db_ktr_verbose) - db_printf("%4ld.%06ld ", (long)kp->ktr_tv.tv_sec, - kp->ktr_tv.tv_nsec / 1000); + db_printf("--- End of trace buffer ---\n"); + return (0); + } + db_printf("%d: ", tstate.cur); + if (db_ktr_verbose) + db_printf("%4ld.%06ld ", (long)kp->ktr_tv.tv_sec, + kp->ktr_tv.tv_nsec / 1000); #ifdef KTR_EXTEND #ifdef SMP - db_printf("cpu%d ", kp->ktr_cpu); + db_printf("cpu%d ", kp->ktr_cpu); #endif - if (db_ktr_verbose) - db_printf("%s.%d\t", kp->ktr_filename, kp->ktr_line); - db_printf("%s", kp->ktr_desc); + if (db_ktr_verbose) + db_printf("%s.%d\t", kp->ktr_filename, kp->ktr_line); + db_printf("%s", kp->ktr_desc); #else - db_printf(kp->ktr_desc, kp->ktr_parm1, kp->ktr_parm2, - kp->ktr_parm3, kp->ktr_parm4, kp->ktr_parm5); + db_printf(kp->ktr_desc, kp->ktr_parm1, kp->ktr_parm2, kp->ktr_parm3, + kp->ktr_parm4, kp->ktr_parm5); #endif - db_printf("\n"); - } + db_printf("\n"); if (tstate.first == -1) tstate.first = tstate.cur;