- 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
This commit is contained in:
parent
291fd55363
commit
d39d4a6e64
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
@ -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]);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user