summaryrefslogtreecommitdiffstats
path: root/sys/ddb
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2004-11-01 22:15:15 +0000
committerjhb <jhb@FreeBSD.org>2004-11-01 22:15:15 +0000
commita9860ec891d255363fab82ffc00c1be83f7d857c (patch)
tree2d51ddc5baf115819b8b07497742acacc8965e22 /sys/ddb
parent28f5ed05c5d8e2b6e4fbadf576613fdcc0f27676 (diff)
downloadFreeBSD-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
Diffstat (limited to 'sys/ddb')
-rw-r--r--sys/ddb/db_output.c32
-rw-r--r--sys/ddb/db_ps.c2
-rw-r--r--sys/ddb/db_thread.c2
-rw-r--r--sys/ddb/db_variables.c1
-rw-r--r--sys/ddb/ddb.h3
5 files changed, 28 insertions, 12 deletions
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;
OpenPOWER on IntegriCloud