diff options
author | jhb <jhb@FreeBSD.org> | 2004-11-01 22:15:15 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2004-11-01 22:15:15 +0000 |
commit | a9860ec891d255363fab82ffc00c1be83f7d857c (patch) | |
tree | 2d51ddc5baf115819b8b07497742acacc8965e22 | |
parent | 28f5ed05c5d8e2b6e4fbadf576613fdcc0f27676 (diff) | |
download | FreeBSD-src-a9860ec891d255363fab82ffc00c1be83f7d857c.zip FreeBSD-src-a9860ec891d255363fab82ffc00c1be83f7d857c.tar.gz |
- Change the ddb paging "support" to use a variable (db_lines_per_page) to
control the number of lines per page rather than a constant. The variable
can be examined and changed in ddb as '$lines'. Setting the variable to
0 will effectively turn off paging.
- Change db_putchar() to force out pending whitespace before outputting
newlines and carriage returns so that one can rub out content on the
current line via '\r \r' type strings.
- Change the simple pager to rub out the --More-- prompt explicitly when
the routine exits.
- Add some aliases to the simple pager to make it more compatible with
more(1): 'e' and 'j' do a single line. 'd' does half a page, and
'f' does a full page.
MFC after: 1 month
Inspired by: kris
-rw-r--r-- | sys/alpha/alpha/db_trace.c | 2 | ||||
-rw-r--r-- | sys/amd64/amd64/db_trace.c | 2 | ||||
-rw-r--r-- | sys/amd64/amd64/intr_machdep.c | 2 | ||||
-rw-r--r-- | sys/arm/arm/db_trace.c | 2 | ||||
-rw-r--r-- | sys/ddb/db_output.c | 32 | ||||
-rw-r--r-- | sys/ddb/db_ps.c | 2 | ||||
-rw-r--r-- | sys/ddb/db_thread.c | 2 | ||||
-rw-r--r-- | sys/ddb/db_variables.c | 1 | ||||
-rw-r--r-- | sys/ddb/ddb.h | 3 | ||||
-rw-r--r-- | sys/dev/pci/pci.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/db_trace.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/intr_machdep.c | 2 | ||||
-rw-r--r-- | sys/i386/i386/machdep.c | 2 | ||||
-rw-r--r-- | sys/ia64/ia64/db_trace.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_intr.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_ktr.c | 2 | ||||
-rw-r--r-- | sys/pc98/i386/machdep.c | 2 | ||||
-rw-r--r-- | sys/pc98/pc98/machdep.c | 2 | ||||
-rw-r--r-- | sys/powerpc/powerpc/db_trace.c | 2 | ||||
-rw-r--r-- | sys/sparc64/sparc64/db_trace.c | 2 |
20 files changed, 43 insertions, 27 deletions
diff --git a/sys/alpha/alpha/db_trace.c b/sys/alpha/alpha/db_trace.c index 8671ca8..4e76b39 100644 --- a/sys/alpha/alpha/db_trace.c +++ b/sys/alpha/alpha/db_trace.c @@ -221,7 +221,7 @@ db_backtrace(struct thread *td, db_addr_t frame, db_addr_t pc, int count) last_ipl = ~0L; tf = NULL; quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (count-- && !quit) { sym = db_search_symbol(pc, DB_STGY_ANY, &diff); if (sym == DB_SYM_NULL) diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c index a4d464a..fb80d29 100644 --- a/sys/amd64/amd64/db_trace.c +++ b/sys/amd64/amd64/db_trace.c @@ -381,7 +381,7 @@ db_backtrace(struct thread *td, struct trapframe *tf, first = TRUE; quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (count-- && !quit) { sym = db_search_symbol(pc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); diff --git a/sys/amd64/amd64/intr_machdep.c b/sys/amd64/amd64/intr_machdep.c index c544251..8524943 100644 --- a/sys/amd64/amd64/intr_machdep.c +++ b/sys/amd64/amd64/intr_machdep.c @@ -313,7 +313,7 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) else verbose = 0; isrc = interrupt_sources; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++) if (*isrc != NULL) db_dump_ithread((*isrc)->is_ithread, verbose); diff --git a/sys/arm/arm/db_trace.c b/sys/arm/arm/db_trace.c index 013a9a9..ffdbf1e 100644 --- a/sys/arm/arm/db_trace.c +++ b/sys/arm/arm/db_trace.c @@ -138,7 +138,7 @@ db_stack_trace_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) scp_offset = -(get_pc_str_offset() >> 2); quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (count-- && frame != NULL && !quit) { db_addr_t scp; u_int32_t savecode; diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c index ff2734c..27e57a5 100644 --- a/sys/ddb/db_output.c +++ b/sys/ddb/db_output.c @@ -65,8 +65,9 @@ db_expr_t db_tab_stop_width = 8; /* how wide are tab stops? */ #define NEXT_TAB(i) \ ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width) db_expr_t db_max_width = 79; /* output line width */ +db_expr_t db_lines_per_page = 20; /* lines per page */ static int db_newlines; /* # lines this page */ -static int db_maxlines = -1; /* max lines per page */ +static int db_maxlines = -1; /* max lines/page when paging */ static db_page_calloutfcn_t *db_page_callout = NULL; static void *db_page_callout_arg = NULL; static int ddb_use_printf = 0; @@ -143,6 +144,7 @@ db_putchar(c, arg) } else if (c == '\n') { /* Newline */ + db_force_whitespace(); cnputc(c); db_output_position = 0; db_last_non_space = 0; @@ -157,6 +159,7 @@ db_putchar(c, arg) } else if (c == '\r') { /* Return */ + db_force_whitespace(); cnputc(c); db_output_position = 0; db_last_non_space = 0; @@ -197,21 +200,33 @@ db_setup_paging(db_page_calloutfcn_t *callout, void *arg, int maxlines) void db_simple_pager(void *arg) { - int c; + int c, done; db_printf("--More--\r"); - for (;;) { + done = 0; + while (!done) { c = cngetc(); switch (c) { + case 'e': + case 'j': case '\n': /* Just one more line. */ db_setup_paging(db_simple_pager, arg, 1); - return; + done++; + break; + case 'd': + /* Half a page. */ + db_setup_paging(db_simple_pager, arg, + db_lines_per_page / 2); + done++; + break; + case 'f': case ' ': /* Another page. */ db_setup_paging(db_simple_pager, arg, - DB_LINES_PER_PAGE); - return; + db_lines_per_page); + done++; + break; case 'q': case 'Q': case 'x': @@ -219,8 +234,8 @@ db_simple_pager(void *arg) /* Quit */ if (arg != NULL) { *(int *)arg = 1; - db_printf("\n"); - return; + done++; + break; } #if 0 /* FALLTHROUGH */ @@ -229,6 +244,7 @@ db_simple_pager(void *arg) #endif } } + db_printf(" \r"); } /* diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index 5820059..b03382d 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -65,7 +65,7 @@ db_ps(dummy1, dummy2, dummy3, dummy4) else p = &proc0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); db_printf(" pid proc uarea uid ppid pgrp flag stat wmesg wchan cmd\n"); while (--np >= 0 && !quit) { if (p == NULL) { diff --git a/sys/ddb/db_thread.c b/sys/ddb/db_thread.c index b58f0b0..8994f96 100644 --- a/sys/ddb/db_thread.c +++ b/sys/ddb/db_thread.c @@ -88,7 +88,7 @@ db_show_threads(db_expr_t addr, boolean_t hasaddr, db_expr_t cnt, char *mod) struct thread *thr; int pager_quit; - db_setup_paging(db_simple_pager, &pager_quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &pager_quit, db_lines_per_page); pager_quit = 0; thr = kdb_thr_first(); diff --git a/sys/ddb/db_variables.c b/sys/ddb/db_variables.c index cf8e2e7..6322a33 100644 --- a/sys/ddb/db_variables.c +++ b/sys/ddb/db_variables.c @@ -45,6 +45,7 @@ static struct db_variable db_vars[] = { { "maxoff", &db_maxoff, FCN_NULL }, { "maxwidth", &db_max_width, FCN_NULL }, { "tabstops", &db_tab_stop_width, FCN_NULL }, + { "lines", &db_lines_per_page, FCN_NULL }, }; static struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]); diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h index 97d332e..ba66705 100644 --- a/sys/ddb/ddb.h +++ b/sys/ddb/ddb.h @@ -39,8 +39,6 @@ #include <machine/db_machdep.h> /* type definitions */ -#define DB_LINES_PER_PAGE 20 - typedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif); @@ -78,6 +76,7 @@ extern int db_store_count; extern db_expr_t db_radix; extern db_expr_t db_max_width; extern db_expr_t db_tab_stop_width; +extern db_expr_t db_lines_per_page; struct thread; struct vm_map; diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 508fa3b..5acf97b 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -1484,7 +1484,7 @@ DB_SHOW_COMMAND(pciregs, db_pci_dump) /* * Go through the list of devices and print out devices */ - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + 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) && !quit; diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c index 4b6cb61..fe42d1a 100644 --- a/sys/i386/i386/db_trace.c +++ b/sys/i386/i386/db_trace.c @@ -387,7 +387,7 @@ db_backtrace(struct thread *td, struct trapframe *tf, struct i386_frame *frame, first = TRUE; quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (count-- && !quit) { sym = db_search_symbol(pc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); diff --git a/sys/i386/i386/intr_machdep.c b/sys/i386/i386/intr_machdep.c index c544251..8524943 100644 --- a/sys/i386/i386/intr_machdep.c +++ b/sys/i386/i386/intr_machdep.c @@ -313,7 +313,7 @@ DB_SHOW_COMMAND(irqs, db_show_irqs) else verbose = 0; isrc = interrupt_sources; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++) if (*isrc != NULL) db_dump_ithread((*isrc)->is_ithread, verbose); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index e17dba5..8cb54a6 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -1479,7 +1479,7 @@ DB_SHOW_COMMAND(idt, db_show_idt) uintptr_t func; ip = idt; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); for (idx = 0, quit = 0; idx < NIDT; idx++) { func = (ip->gd_hioffset << 16 | ip->gd_looffset); if (func != (uintptr_t)&IDTVEC(rsvd)) { diff --git a/sys/ia64/ia64/db_trace.c b/sys/ia64/ia64/db_trace.c index 6065eb6..f90e0e9 100644 --- a/sys/ia64/ia64/db_trace.c +++ b/sys/ia64/ia64/db_trace.c @@ -60,7 +60,7 @@ db_backtrace(struct thread *td, struct pcb *pcb, int count) int args, error, i, quit; quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); error = unw_create_from_pcb(&rs, pcb); while (!error && count-- && !quit) { error = unw_get_cfm(&rs, &cfm); diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c index 9d8af71..c777da3 100644 --- a/sys/kern/kern_intr.c +++ b/sys/kern/kern_intr.c @@ -815,7 +815,7 @@ DB_SHOW_COMMAND(intrcnt, db_show_intrcnt) int quit; cp = intrnames; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); for (i = intrcnt, quit = 0; i != eintrcnt && !quit; i++) { if (*cp == '\0') break; diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index dbb7f10..bd25e36 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -282,7 +282,7 @@ DB_SHOW_COMMAND(ktr, db_ktr_all) if (db_mach_vtrace() == 0) break; } else { - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (!quit) if (db_mach_vtrace() == 0) break; diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index e13d506..83abbb3 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -1496,7 +1496,7 @@ DB_SHOW_COMMAND(idt, db_show_idt) uintptr_t func; ip = idt; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); for (idx = 0, quit = 0; idx < NIDT; idx++) { func = (ip->gd_hioffset << 16 | ip->gd_looffset); if (func != (uintptr_t)&IDTVEC(rsvd)) { diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index e13d506..83abbb3 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -1496,7 +1496,7 @@ DB_SHOW_COMMAND(idt, db_show_idt) uintptr_t func; ip = idt; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); for (idx = 0, quit = 0; idx < NIDT; idx++) { func = (ip->gd_hioffset << 16 | ip->gd_looffset); if (func != (uintptr_t)&IDTVEC(rsvd)) { diff --git a/sys/powerpc/powerpc/db_trace.c b/sys/powerpc/powerpc/db_trace.c index 23d4e50..7c96995 100644 --- a/sys/powerpc/powerpc/db_trace.c +++ b/sys/powerpc/powerpc/db_trace.c @@ -150,7 +150,7 @@ db_backtrace(struct thread *td, db_addr_t fp, int count) stackframe = fp; quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (!quit) { if (stackframe < PAGE_SIZE) break; diff --git a/sys/sparc64/sparc64/db_trace.c b/sys/sparc64/sparc64/db_trace.c index acb4b5a..a777f55 100644 --- a/sys/sparc64/sparc64/db_trace.c +++ b/sys/sparc64/sparc64/db_trace.c @@ -238,7 +238,7 @@ db_backtrace(struct thread *td, struct frame *fp, int count) user = 0; npc = 0; quit = 0; - db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE); + db_setup_paging(db_simple_pager, &quit, db_lines_per_page); while (count-- && !user && !quit) { pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc, sizeof(fp->fr_pc), FALSE); |