summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-07-12 21:22:44 +0000
committerjhb <jhb@FreeBSD.org>2006-07-12 21:22:44 +0000
commita72b0bcd7fd4baed9952beefc6398b3d79c789d9 (patch)
treef2aff187736391b024e6cf6f28e95e5708a2d927
parent883bd6a55eef6005b2e79ccc0c939a365bebb656 (diff)
downloadFreeBSD-src-a72b0bcd7fd4baed9952beefc6398b3d79c789d9.zip
FreeBSD-src-a72b0bcd7fd4baed9952beefc6398b3d79c789d9.tar.gz
Simplify the pager support in DDB. Allowing different db commands to
install custom pager functions didn't actually happen in practice (they all just used the simple pager and passed in a local quit pointer). So, just hardcode the simple pager as the only pager and make it set a global db_pager_quit flag that db commands can check when the user hits 'q' (or a suitable variant) at the pager prompt. Also, now that it's easy to do so, enable paging by default for all ddb commands. Any command that wishes to honor the quit flag can do so by checking db_pager_quit. Note that the pager can also be effectively disabled by setting $lines to 0. Other fixes: - 'show idt' on i386 and pc98 now actually checks the quit flag and terminates early. - 'show intr' now actually checks the quit flag and terminates early.
-rw-r--r--sys/amd64/amd64/db_trace.c6
-rw-r--r--sys/amd64/amd64/intr_machdep.c6
-rw-r--r--sys/amd64/amd64/local_apic.c6
-rw-r--r--sys/arm/arm/db_trace.c6
-rw-r--r--sys/ddb/db_command.c8
-rw-r--r--sys/ddb/db_output.c69
-rw-r--r--sys/ddb/db_output.h2
-rw-r--r--sys/ddb/db_ps.c14
-rw-r--r--sys/ddb/db_thread.c6
-rw-r--r--sys/ddb/ddb.h7
-rw-r--r--sys/dev/pci/pci.c7
-rw-r--r--sys/i386/i386/db_trace.c6
-rw-r--r--sys/i386/i386/intr_machdep.c6
-rw-r--r--sys/i386/i386/local_apic.c6
-rw-r--r--sys/i386/i386/machdep.c5
-rw-r--r--sys/ia64/ia64/db_machdep.c6
-rw-r--r--sys/kern/kern_intr.c10
-rw-r--r--sys/kern/kern_ktr.c17
-rw-r--r--sys/kern/subr_prf.c7
-rw-r--r--sys/pc98/pc98/machdep.c5
-rw-r--r--sys/powerpc/powerpc/db_trace.c5
-rw-r--r--sys/sparc64/sparc64/db_trace.c15
22 files changed, 90 insertions, 135 deletions
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
index d050787..101ff39 100644
--- a/sys/amd64/amd64/db_trace.c
+++ b/sys/amd64/amd64/db_trace.c
@@ -390,16 +390,14 @@ db_backtrace(struct thread *td, struct trapframe *tf,
long *argp;
db_expr_t offset;
c_db_sym_t sym;
- int narg, quit;
+ int narg;
boolean_t first;
if (count == -1)
count = 1024;
first = TRUE;
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- while (count-- && !quit) {
+ while (count-- && !db_pager_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 9d70d06..9a4eaca 100644
--- a/sys/amd64/amd64/intr_machdep.c
+++ b/sys/amd64/amd64/intr_machdep.c
@@ -338,16 +338,14 @@ SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL)
DB_SHOW_COMMAND(irqs, db_show_irqs)
{
struct intsrc **isrc;
- int i, quit, verbose;
+ int i, verbose;
- quit = 0;
if (strcmp(modif, "v") == 0)
verbose = 1;
else
verbose = 0;
isrc = interrupt_sources;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
+ for (i = 0; i < NUM_IO_INTS && !db_pager_quit; i++, isrc++)
if (*isrc != NULL)
db_dump_intr_event((*isrc)->is_event, verbose);
}
diff --git a/sys/amd64/amd64/local_apic.c b/sys/amd64/amd64/local_apic.c
index 384de39..eaf65b4 100644
--- a/sys/amd64/amd64/local_apic.c
+++ b/sys/amd64/amd64/local_apic.c
@@ -755,18 +755,16 @@ apic_idt_to_irq(u_int vector)
DB_SHOW_COMMAND(apic, db_show_apic)
{
struct intsrc *isrc;
- int quit, i, verbose;
+ int i, verbose;
u_int irq;
- quit = 0;
if (strcmp(modif, "vv") == 0)
verbose = 2;
else if (strcmp(modif, "v") == 0)
verbose = 1;
else
verbose = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (i = 0; i < APIC_NUM_IOINTS + 1 && !quit; i++) {
+ for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) {
irq = ioint_irqs[i];
if (irq != 0 && irq != IRQ_SYSCALL) {
db_printf("vec 0x%2x -> ", i + APIC_IO_INTS);
diff --git a/sys/arm/arm/db_trace.c b/sys/arm/arm/db_trace.c
index 7d6685b..e9ce328 100644
--- a/sys/arm/arm/db_trace.c
+++ b/sys/arm/arm/db_trace.c
@@ -93,15 +93,13 @@ db_stack_trace_cmd(db_expr_t addr, db_expr_t count)
db_expr_t value;
db_expr_t offset;
boolean_t kernel_only = TRUE;
- int scp_offset, quit;
+ int scp_offset;
frame = (u_int32_t *)addr;
lastframe = NULL;
scp_offset = -(get_pc_str_offset() >> 2);
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- while (count-- && frame != NULL && !quit) {
+ while (count-- && frame != NULL && !db_pager_quit) {
db_addr_t scp;
u_int32_t savecode;
int r;
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index c15edaa..c92d52f 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -392,8 +392,9 @@ db_command(last_cmdp, cmd_table)
/*
* Execute the command.
*/
+ db_enable_pager();
(*cmd->fcn)(addr, have_addr, count, modif);
- db_setup_paging(NULL, NULL, -1);
+ db_disable_pager();
if (cmd->flag & CS_SET_DOT) {
/*
@@ -675,16 +676,13 @@ db_stack_trace_all(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3,
{
struct proc *p;
struct thread *td;
- int quit;
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
LIST_FOREACH(p, &allproc, p_list) {
FOREACH_THREAD_IN_PROC(p, td) {
db_printf("\nTracing command %s pid %d tid %ld td %p\n",
p->p_comm, p->p_pid, (long)td->td_tid, td);
db_trace_thread(td, -1);
- if (quit)
+ if (db_pager_quit)
return;
}
}
diff --git a/sys/ddb/db_output.c b/sys/ddb/db_output.c
index fccae29..e9f0c82 100644
--- a/sys/ddb/db_output.c
+++ b/sys/ddb/db_output.c
@@ -66,15 +66,15 @@ db_expr_t db_tab_stop_width = 8; /* how wide are tab stops? */
((((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 */
+volatile int db_pager_quit; /* user requested quit */
static int db_newlines; /* # lines this 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 db_maxlines; /* max lines/page when paging */
static int ddb_use_printf = 0;
SYSCTL_INT(_debug, OID_AUTO, ddb_use_printf, CTLFLAG_RW, &ddb_use_printf, 0,
"use printf for all ddb output");
static void db_putchar(int c, void *arg);
+static void db_pager(void);
/*
* Force pending whitespace.
@@ -120,12 +120,10 @@ db_putchar(c, arg)
return;
if (c == '\r' || c == '\n')
db_check_interrupt();
- if (c == '\n' && db_maxlines > 0 && db_page_callout != NULL) {
+ if (c == '\n' && db_maxlines > 0) {
db_newlines++;
- if (db_newlines >= db_maxlines) {
- db_maxlines = -1;
- db_page_callout(db_page_callout_arg);
- }
+ if (db_newlines >= db_maxlines)
+ db_pager();
}
return;
}
@@ -149,12 +147,10 @@ db_putchar(c, arg)
db_output_position = 0;
db_last_non_space = 0;
db_check_interrupt();
- if (db_maxlines > 0 && db_page_callout != NULL) {
+ if (db_maxlines > 0) {
db_newlines++;
- if (db_newlines >= db_maxlines) {
- db_maxlines = -1;
- db_page_callout(db_page_callout_arg);
- }
+ if (db_newlines >= db_maxlines)
+ db_pager();
}
}
else if (c == '\r') {
@@ -181,27 +177,34 @@ db_putchar(c, arg)
}
/*
- * Register callout for providing a pager for output.
+ * Turn on the pager.
*/
void
-db_setup_paging(db_page_calloutfcn_t *callout, void *arg, int maxlines)
+db_enable_pager(void)
{
-
- if (db_page_callout == NULL || callout == NULL || arg ==
- db_page_callout_arg) {
- db_page_callout = callout;
- db_page_callout_arg = arg;
- db_maxlines = maxlines;
+ if (db_maxlines == 0) {
+ db_maxlines = db_lines_per_page;
db_newlines = 0;
+ db_pager_quit = 0;
}
}
/*
- * A simple paging callout function. If the argument is not null, it
- * points to an integer that will be set to 1 if the user asks to quit.
+ * Turn off the pager.
*/
void
-db_simple_pager(void *arg)
+db_disable_pager(void)
+{
+ db_maxlines = 0;
+}
+
+/*
+ * A simple paging callout function. It supports several simple more(1)-like
+ * commands as well as a quit command that sets db_pager_quit which db
+ * commands can poll to see if they should terminate early.
+ */
+void
+db_pager(void)
{
int c, done;
@@ -214,20 +217,18 @@ db_simple_pager(void *arg)
case 'j':
case '\n':
/* Just one more line. */
- db_setup_paging(db_simple_pager, arg, 1);
+ db_maxlines = 1;
done++;
break;
case 'd':
/* Half a page. */
- db_setup_paging(db_simple_pager, arg,
- db_lines_per_page / 2);
+ db_maxlines = db_lines_per_page / 2;
done++;
break;
case 'f':
case ' ':
/* Another page. */
- db_setup_paging(db_simple_pager, arg,
- db_lines_per_page);
+ db_maxlines = db_lines_per_page;
done++;
break;
case 'q':
@@ -235,11 +236,10 @@ db_simple_pager(void *arg)
case 'x':
case 'X':
/* Quit */
- if (arg != NULL) {
- *(int *)arg = 1;
- done++;
- break;
- }
+ db_maxlines = 0;
+ db_pager_quit = 1;
+ done++;
+ break;
#if 0
/* FALLTHROUGH */
default:
@@ -248,6 +248,7 @@ db_simple_pager(void *arg)
}
}
db_printf(" \r");
+ db_newlines = 0;
}
/*
diff --git a/sys/ddb/db_output.h b/sys/ddb/db_output.h
index 7615ea6..480c40d 100644
--- a/sys/ddb/db_output.h
+++ b/sys/ddb/db_output.h
@@ -38,6 +38,8 @@
* Printing routines for kernel debugger.
*/
+void db_disable_pager(void);
+void db_enable_pager(void);
void db_end_line(void);
void db_force_whitespace(void);
int db_print_position(void);
diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c
index 39dff4c..f220de0 100644
--- a/sys/ddb/db_ps.c
+++ b/sys/ddb/db_ps.c
@@ -73,23 +73,21 @@ db_ps(db_expr_t addr, boolean_t hasaddr, db_expr_t count, char *modif)
struct ucred *cred;
struct pgrp *pgrp;
char state[9];
- int np, quit, rflag, sflag, dflag, lflag, wflag;
+ int np, rflag, sflag, dflag, lflag, wflag;
np = nprocs;
- quit = 0;
if (!LIST_EMPTY(&allproc))
p = LIST_FIRST(&allproc);
else
p = &proc0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
#ifdef __LP64__
db_printf(" pid uid ppid pgrp state wmesg wchan cmd\n");
#else
db_printf(" pid uid ppid pgrp state wmesg wchan cmd\n");
#endif
- while (--np >= 0 && !quit) {
+ while (--np >= 0 && !db_pager_quit) {
if (p == NULL) {
db_printf("oops, ran out of processes early!\n");
break;
@@ -191,7 +189,7 @@ db_ps(db_expr_t addr, boolean_t hasaddr, db_expr_t count, char *modif)
#endif
FOREACH_THREAD_IN_PROC(p, td) {
dumpthread(p, td, p->p_flag & P_HADTHREADS);
- if (quit)
+ if (db_pager_quit)
break;
}
@@ -363,7 +361,7 @@ DB_SHOW_COMMAND(proc, db_show_proc)
{
struct thread *td;
struct proc *p;
- int i, quit;
+ int i;
/* Determine which process to examine. */
if (have_addr)
@@ -371,8 +369,6 @@ DB_SHOW_COMMAND(proc, db_show_proc)
else
p = kdb_thread->td_proc;
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
db_printf("Process %d (%s) at %p:\n", p->p_pid, p->p_comm, p);
db_printf(" state: ");
switch (p->p_state) {
@@ -411,7 +407,7 @@ DB_SHOW_COMMAND(proc, db_show_proc)
db_printf(" threads: %d\n", p->p_numthreads);
FOREACH_THREAD_IN_PROC(p, td) {
dumpthread(p, td, 1);
- if (quit)
+ if (db_pager_quit)
break;
}
}
diff --git a/sys/ddb/db_thread.c b/sys/ddb/db_thread.c
index a946dd8..13c3878 100644
--- a/sys/ddb/db_thread.c
+++ b/sys/ddb/db_thread.c
@@ -93,13 +93,9 @@ db_show_threads(db_expr_t addr, boolean_t hasaddr, db_expr_t cnt, char *mod)
jmp_buf jb;
void *prev_jb;
struct thread *thr;
- int pager_quit;
- db_setup_paging(db_simple_pager, &pager_quit, db_lines_per_page);
-
- pager_quit = 0;
thr = kdb_thr_first();
- while (!pager_quit && thr != NULL) {
+ while (!db_pager_quit && thr != NULL) {
db_printf(" %6ld (%p) ", (long)thr->td_tid, thr);
prev_jb = kdb_jmpbuf(jb);
if (setjmp(jb) == 0) {
diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h
index 549e24e..716740b 100644
--- a/sys/ddb/ddb.h
+++ b/sys/ddb/ddb.h
@@ -52,8 +52,6 @@ int DB_CALL(db_expr_t, db_expr_t *, int, db_expr_t[]);
typedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count,
char *modif);
-typedef void db_page_calloutfcn_t(void *arg);
-
#define DB_COMMAND(cmd_name, func_name) \
DB_FUNC(cmd_name, func_name, db_cmd_set, 0, NULL)
#define DB_SHOW_COMMAND(cmd_name, func_name) \
@@ -85,6 +83,7 @@ extern int db_indent;
extern int db_inst_count;
extern int db_load_count;
extern int db_store_count;
+extern volatile int db_pager_quit;
extern db_expr_t db_radix;
extern db_expr_t db_max_width;
extern db_expr_t db_tab_stop_width;
@@ -118,8 +117,6 @@ int db_readline(char *lstart, int lsize);
void db_restart_at_pc(boolean_t watchpt);
int db_set_variable(db_expr_t value);
void db_set_watchpoints(void);
-void db_setup_paging(db_page_calloutfcn_t *callout, void *arg,
- int maxlines);
void db_skip_to_eol(void);
boolean_t db_stop_at_pc(boolean_t *is_breakpoint);
#define db_strcpy strcpy
@@ -149,8 +146,6 @@ db_cmdfcn_t db_trace_until_matching_cmd;
db_cmdfcn_t db_watchpoint_cmd;
db_cmdfcn_t db_write_cmd;
-db_page_calloutfcn_t db_simple_pager;
-
/*
* Command table.
*/
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index 554e6f2..674a661 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -1716,7 +1716,7 @@ DB_SHOW_COMMAND(pciregs, db_pci_dump)
struct devlist *devlist_head;
struct pci_conf *p;
const char *name;
- int i, error, none_count, quit;
+ int i, error, none_count;
none_count = 0;
/* get the head of the device queue */
@@ -1725,10 +1725,9 @@ 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);
- for (error = 0, i = 0, quit = 0,
+ for (error = 0, i = 0,
dinfo = STAILQ_FIRST(devlist_head);
- (dinfo != NULL) && (error == 0) && (i < pci_numdevs) && !quit;
+ (dinfo != NULL) && (error == 0) && (i < pci_numdevs) && !db_pager_quit;
dinfo = STAILQ_NEXT(dinfo, pci_links), i++) {
/* Populate pd_name and pd_unit */
diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c
index ea2c208..c3ea8ac 100644
--- a/sys/i386/i386/db_trace.c
+++ b/sys/i386/i386/db_trace.c
@@ -401,7 +401,7 @@ db_backtrace(struct thread *td, struct trapframe *tf, struct i386_frame *frame,
int *argp;
db_expr_t offset;
c_db_sym_t sym;
- int instr, narg, quit;
+ int instr, narg;
boolean_t first;
/*
@@ -432,9 +432,7 @@ db_backtrace(struct thread *td, struct trapframe *tf, struct i386_frame *frame,
count = 1024;
first = TRUE;
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- while (count-- && !quit) {
+ while (count-- && !db_pager_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 f163ff9..fe41cc6 100644
--- a/sys/i386/i386/intr_machdep.c
+++ b/sys/i386/i386/intr_machdep.c
@@ -338,16 +338,14 @@ SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL)
DB_SHOW_COMMAND(irqs, db_show_irqs)
{
struct intsrc **isrc;
- int i, quit, verbose;
+ int i, verbose;
- quit = 0;
if (strcmp(modif, "v") == 0)
verbose = 1;
else
verbose = 0;
isrc = interrupt_sources;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
+ for (i = 0; i < NUM_IO_INTS && !db_pager_quit; i++, isrc++)
if (*isrc != NULL)
db_dump_intr_event((*isrc)->is_event, verbose);
}
diff --git a/sys/i386/i386/local_apic.c b/sys/i386/i386/local_apic.c
index c26eeab..456eaff 100644
--- a/sys/i386/i386/local_apic.c
+++ b/sys/i386/i386/local_apic.c
@@ -758,18 +758,16 @@ apic_idt_to_irq(u_int vector)
DB_SHOW_COMMAND(apic, db_show_apic)
{
struct intsrc *isrc;
- int quit, i, verbose;
+ int i, verbose;
u_int irq;
- quit = 0;
if (strcmp(modif, "vv") == 0)
verbose = 2;
else if (strcmp(modif, "v") == 0)
verbose = 1;
else
verbose = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (i = 0; i < APIC_NUM_IOINTS + 1 && !quit; i++) {
+ for (i = 0; i < APIC_NUM_IOINTS + 1 && !db_pager_quit; i++) {
irq = ioint_irqs[i];
if (irq != 0 && irq != IRQ_SYSCALL) {
db_printf("vec 0x%2x -> ", i + APIC_IO_INTS);
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index e3d7e86..f3c21da 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -1584,12 +1584,11 @@ extern inthand_t
DB_SHOW_COMMAND(idt, db_show_idt)
{
struct gate_descriptor *ip;
- int idx, quit;
+ int idx;
uintptr_t func;
ip = idt;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (idx = 0, quit = 0; idx < NIDT; idx++) {
+ for (idx = 0; idx < NIDT && !db_pager_quit; idx++) {
func = (ip->gd_hioffset << 16 | ip->gd_looffset);
if (func != (uintptr_t)&IDTVEC(rsvd)) {
db_printf("%3d\t", idx);
diff --git a/sys/ia64/ia64/db_machdep.c b/sys/ia64/ia64/db_machdep.c
index 9e965f0..00f3205 100644
--- a/sys/ia64/ia64/db_machdep.c
+++ b/sys/ia64/ia64/db_machdep.c
@@ -228,12 +228,10 @@ db_backtrace(struct thread *td, struct pcb *pcb, int count)
db_expr_t offset;
uint64_t bsp, cfm, ip, pfs, reg, sp;
c_db_sym_t sym;
- int args, error, i, quit;
+ int args, error, i;
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
error = unw_create_from_pcb(&rs, pcb);
- while (!error && count-- && !quit) {
+ while (!error && count-- && !db_pager_quit) {
error = unw_get_cfm(&rs, &cfm);
if (!error)
error = unw_get_bsp(&rs, &bsp);
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index 042a0ec..7693954 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -905,16 +905,16 @@ db_dump_intr_event(struct intr_event *ie, int handlers)
DB_SHOW_COMMAND(intr, db_show_intr)
{
struct intr_event *ie;
- int quit, all, verbose;
+ int all, verbose;
- quit = 0;
verbose = index(modif, 'v') != NULL;
all = index(modif, 'a') != NULL;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
TAILQ_FOREACH(ie, &event_list, ie_list) {
if (!all && TAILQ_EMPTY(&ie->ie_handlers))
continue;
db_dump_intr_event(ie, verbose);
+ if (db_pager_quit)
+ break;
}
}
#endif /* DDB */
@@ -976,11 +976,9 @@ DB_SHOW_COMMAND(intrcnt, db_show_intrcnt)
{
u_long *i;
char *cp;
- int quit;
cp = intrnames;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (i = intrcnt, quit = 0; i != eintrcnt && !quit; i++) {
+ for (i = intrcnt; i != eintrcnt && !db_pager_quit; i++) {
if (*cp == '\0')
break;
if (*i != 0)
diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c
index 7ae5582..f12f971 100644
--- a/sys/kern/kern_ktr.c
+++ b/sys/kern/kern_ktr.c
@@ -55,8 +55,10 @@ __FBSDID("$FreeBSD$");
#include <machine/ktr.h>
#endif
-
+#ifdef DDB
#include <ddb/ddb.h>
+#include <ddb/db_output.h>
+#endif
#ifndef KTR_ENTRIES
#define KTR_ENTRIES 1024
@@ -288,22 +290,17 @@ static int db_mach_vtrace(void);
DB_SHOW_COMMAND(ktr, db_ktr_all)
{
- int quit;
- quit = 0;
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;
- if (strcmp(modif, "a") == 0) {
+ db_ktr_verbose = index(modif, 'v') != NULL;
+ if (index(modif, 'a') != NULL) {
+ db_disable_pager();
while (cncheckc() != -1)
if (db_mach_vtrace() == 0)
break;
} else {
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- while (!quit)
+ while (!db_pager_quit)
if (db_mach_vtrace() == 0)
break;
}
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index f003bad..12f29b6 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -912,20 +912,17 @@ SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear,
DB_SHOW_COMMAND(msgbuf, db_show_msgbuf)
{
- int i, j, quit;
-
- quit = 0;
+ int i, j;
if (!msgbufmapped) {
db_printf("msgbuf not mapped yet\n");
return;
}
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
db_printf("msgbufp = %p\n", msgbufp);
db_printf("magic = %x, size = %d, r= %u, w = %u, ptr = %p, cksum= %u\n",
msgbufp->msg_magic, msgbufp->msg_size, msgbufp->msg_rseq,
msgbufp->msg_wseq, msgbufp->msg_ptr, msgbufp->msg_cksum);
- for (i = 0; i < msgbufp->msg_size && !quit; i++) {
+ for (i = 0; i < msgbufp->msg_size && !db_pager_quit; i++) {
j = MSGBUF_SEQ_TO_POS(msgbufp, i + msgbufp->msg_rseq);
db_printf("%c", msgbufp->msg_ptr[j]);
}
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index 5a686ad..d61970a 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -1581,12 +1581,11 @@ extern inthand_t
DB_SHOW_COMMAND(idt, db_show_idt)
{
struct gate_descriptor *ip;
- int idx, quit;
+ int idx;
uintptr_t func;
ip = idt;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- for (idx = 0, quit = 0; idx < NIDT; idx++) {
+ for (idx = 0; idx < NIDT && !db_pager_quit; idx++) {
func = (ip->gd_hioffset << 16 | ip->gd_looffset);
if (func != (uintptr_t)&IDTVEC(rsvd)) {
db_printf("%3d\t", idx);
diff --git a/sys/powerpc/powerpc/db_trace.c b/sys/powerpc/powerpc/db_trace.c
index e70f5e1..188e028 100644
--- a/sys/powerpc/powerpc/db_trace.c
+++ b/sys/powerpc/powerpc/db_trace.c
@@ -131,7 +131,6 @@ db_backtrace(struct thread *td, db_addr_t fp, int count)
const char *symname;
boolean_t kernel_only = TRUE;
boolean_t full = FALSE;
- int quit;
#if 0
{
@@ -151,9 +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);
- while (!quit) {
+ while (!db_pager_quit) {
if (stackframe < PAGE_SIZE)
break;
diff --git a/sys/sparc64/sparc64/db_trace.c b/sys/sparc64/sparc64/db_trace.c
index bb5f60c..73d3b31 100644
--- a/sys/sparc64/sparc64/db_trace.c
+++ b/sys/sparc64/sparc64/db_trace.c
@@ -103,7 +103,7 @@ db_frame(struct db_variable *vp, db_expr_t *valuep, int op)
* User stack trace (debugging aid).
*/
static void
-db_utrace(struct thread *td, struct trapframe *tf, int count, int *quitp)
+db_utrace(struct thread *td, struct trapframe *tf, int count)
{
struct pcb *pcb;
db_addr_t sp, rsp, o7, pc;
@@ -115,7 +115,7 @@ db_utrace(struct thread *td, struct trapframe *tf, int count, int *quitp)
FALSE);
pc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE);
db_printf("user trace: trap %%o7=%#lx\n", o7);
- while (count-- && sp != 0 && !*quitp) {
+ while (count-- && sp != 0 && !db_pager_quit) {
db_printf("pc %#lx, sp %#lx\n", pc, sp);
/* First, check whether the frame is in the pcb. */
found = 0;
@@ -141,7 +141,7 @@ db_utrace(struct thread *td, struct trapframe *tf, int count, int *quitp)
}
static int
-db_print_trap(struct thread *td, struct trapframe *tf, int count, int *quitp)
+db_print_trap(struct thread *td, struct trapframe *tf, int count)
{
struct proc *p;
const char *symname;
@@ -219,7 +219,7 @@ db_print_trap(struct thread *td, struct trapframe *tf, int count, int *quitp)
db_printf("userland() at ");
db_printsym(tpc, DB_STGY_PROC);
db_printf("\n");
- db_utrace(td, tf, count, quitp);
+ db_utrace(td, tf, count);
}
return (user);
}
@@ -236,7 +236,6 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
db_addr_t pc;
int trap;
int user;
- int quit;
if (count == -1)
count = 1024;
@@ -244,9 +243,7 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
trap = 0;
user = 0;
npc = 0;
- quit = 0;
- db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
- while (count-- && !user && !quit) {
+ while (count-- && !user && !db_pager_quit) {
pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc,
sizeof(fp->fr_pc), FALSE);
if (trap) {
@@ -272,7 +269,7 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
tf = (struct trapframe *)(fp + 1);
npc = db_get_value((db_addr_t)&tf->tf_tpc,
sizeof(tf->tf_tpc), FALSE);
- user = db_print_trap(td, tf, count, &quit);
+ user = db_print_trap(td, tf, count);
trap = 1;
} else {
db_printf("%s() at ", name);
OpenPOWER on IntegriCloud