Add 'ps' command. Add -more- pager to output from Mach ddb.

This commit is contained in:
brezak 1993-07-15 18:35:00 +00:00
parent dc7bae3f10
commit 4404af90d7
3 changed files with 118 additions and 37 deletions

View File

@ -24,11 +24,11 @@
* rights to redistribute these changes.
*/
/*
* $Id: db_command.c,v 1.3 1993/05/20 03:39:10 cgd Exp $
* db_command.c,v 1.3 1993/05/20 03:39:10 cgd Exp
*
* HISTORY
* $Log: db_command.c,v $
* Revision 1.3 1993/05/20 03:39:10 cgd
* db_command.c,v
* Revision 1.3 1993/05/20 03:39:10 cgd
* add explicit rcs id
*
* Revision 1.2 1993/03/21 18:08:04 cgd
@ -348,20 +348,51 @@ db_command(last_cmdp, cmd_table)
}
}
/*ARGSUSED*/
void
db_map_print_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
extern void vm_map_print();
boolean_t full = FALSE;
if (modif[0] == 'f')
full = TRUE;
vm_map_print(addr, full);
}
/*ARGSUSED*/
void
db_object_print_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
db_expr_t count;
char * modif;
{
extern void vm_object_print();
boolean_t full = FALSE;
if (modif[0] == 'f')
full = TRUE;
vm_object_print(addr, full);
}
/*
* 'show' commands
*/
extern void db_show_all_procs();
extern void db_listbreak_cmd();
extern void db_listwatch_cmd();
extern void db_show_regs(), db_show_one_thread(), db_show_all_threads();
extern void vm_map_print(), vm_object_print(), vm_page_print();
extern void ipc_port_print();
extern void db_show_regs();
void db_show_help();
struct command db_show_all_cmds[] = {
#if 0
{ "threads", db_show_all_threads,0, 0 },
#endif
{ "procs", db_show_all_procs,0, 0 },
{ (char *)0 }
};
@ -370,17 +401,8 @@ struct command db_show_cmds[] = {
{ "registers", db_show_regs, 0, 0 },
{ "breaks", db_listbreak_cmd, 0, 0 },
{ "watches", db_listwatch_cmd, 0, 0 },
#if 0
{ "thread", db_show_one_thread, 0, 0 },
#endif
{ "map", vm_map_print, 0, 0 },
{ "object", vm_object_print, 0, 0 },
#if 0
{ "page", vm_page_print, 0, 0 },
#endif
#if 0
{ "port", ipc_port_print, 0, 0 },
#endif
{ "map", db_map_print_cmd, 0, 0 },
{ "object", db_object_print_cmd, 0, 0 },
{ (char *)0, }
};
@ -417,6 +439,7 @@ struct command db_command_table[] = {
{ "match", db_trace_until_matching_cmd,0, 0 },
{ "trace", db_stack_trace_cmd, 0, 0 },
{ "call", db_fncall, CS_OWN, 0 },
{ "ps", db_show_all_procs, 0, 0 },
{ "show", 0, 0, db_show_cmds },
{ (char *)0, }
};
@ -438,6 +461,8 @@ db_help_cmd()
void
db_command_loop()
{
extern int db_output_line;
/*
* Initialize 'prev' and 'next' to dot.
*/
@ -450,6 +475,7 @@ db_command_loop()
(void) setjmp(db_jmpbuf);
if (db_print_position() != 0)
db_printf("\n");
db_output_line = 0;
db_printf("db> ");
(void) db_read_line();

View File

@ -32,11 +32,11 @@
* use spaces instead.
*/
/*
* $Id: db_output.c,v 1.3 1993/05/20 03:39:21 cgd Exp $
* db_output.c,v 1.3 1993/05/20 03:39:21 cgd Exp
*
* HISTORY
* $Log: db_output.c,v $
* Revision 1.3 1993/05/20 03:39:21 cgd
* db_output.c,v
* Revision 1.3 1993/05/20 03:39:21 cgd
* add explicit rcs id
*
* Revision 1.2 1993/03/21 18:08:08 cgd
@ -85,12 +85,24 @@
* don't print trailing spaces. This avoids most
* of the wraparounds.
*/
#ifndef DB_MAX_LINE
#define DB_MAX_LINE 24 /* maximum line */
#define DB_MAX_WIDTH 80 /* maximum width */
#endif DB_MAX_LINE
#define DB_MIN_MAX_WIDTH 20 /* minimum max width */
#define DB_MIN_MAX_LINE 3 /* minimum max line */
#define CTRL(c) ((c) & 0xff)
int db_output_position = 0; /* output column */
int db_output_line = 0; /* output line number */
int db_last_non_space = 0; /* last non-space character */
int 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)
int db_max_width = 80; /* output line width */
int db_max_line = DB_MAX_LINE; /* output max lines */
int db_max_width = DB_MAX_WIDTH; /* output line width */
extern void db_check_interrupt();
@ -119,12 +131,44 @@ db_force_whitespace()
db_last_non_space = db_output_position;
}
static void
db_more()
{
register char *p;
int quit_output = 0;
for (p = "--db_more--"; *p; p++)
cnputc(*p);
switch(cngetc()) {
case ' ':
db_output_line = 0;
break;
case 'q':
case CTRL('c'):
db_output_line = 0;
quit_output = 1;
break;
default:
db_output_line--;
break;
}
p = "\b\b\b\b\b\b\b\b\b\b\b \b\b\b\b\b\b\b\b\b\b\b";
while (*p)
cnputc(*p++);
if (quit_output) {
db_error(0);
/* NOTREACHED */
}
}
/*
* Output character. Buffer whitespace.
*/
db_putchar(c)
int c; /* character to output */
{
if (db_max_line >= DB_MIN_MAX_LINE && db_output_line >= db_max_line-1)
db_more();
if (c > ' ' && c <= '~') {
/*
* Printing character.
@ -134,6 +178,14 @@ db_putchar(c)
db_force_whitespace();
cnputc(c);
db_output_position++;
if (db_max_width >= DB_MIN_MAX_WIDTH
&& db_output_position >= db_max_width-1) {
/* auto new line */
cnputc('\n');
db_output_position = 0;
db_last_non_space = 0;
db_output_line++;
}
db_last_non_space = db_output_position;
}
else if (c == '\n') {
@ -141,6 +193,7 @@ db_putchar(c)
cnputc(c);
db_output_position = 0;
db_last_non_space = 0;
db_output_line++;
db_check_interrupt();
}
else if (c == '\t') {
@ -167,16 +220,6 @@ db_print_position()
return (db_output_position);
}
/*
* End line if too long.
*/
void
db_end_line()
{
if (db_output_position >= db_max_width)
db_printf("\n");
}
/*
* Printing
*/
@ -202,6 +245,16 @@ kdbprintf(char *fmt, ...)
va_end(listp);
}
/*
* End line if too long.
*/
void
db_end_line()
{
if (db_output_position >= db_max_width)
db_printf("\n");
}
/*
* Put a number (base <= 16) in a buffer in reverse order; return an
* optional length and a pointer to the NULL terminated (preceded?)

View File

@ -24,11 +24,11 @@
* rights to redistribute these changes.
*/
/*
* $Id: db_variables.c,v 1.2 1993/05/20 03:39:35 cgd Exp $
* db_variables.c,v 1.2 1993/05/20 03:39:35 cgd Exp
*
* HISTORY
* $Log: db_variables.c,v $
* Revision 1.2 1993/05/20 03:39:35 cgd
* db_variables.c,v
* Revision 1.2 1993/05/20 03:39:35 cgd
* add explicit rcs id
*
* Revision 1.1.1.1 1993/03/21 09:46:27 cgd
@ -72,12 +72,14 @@ extern unsigned int db_maxoff;
extern int db_radix;
extern int db_max_width;
extern int db_tab_stop_width;
extern int db_max_line;
struct db_variable db_vars[] = {
{ "radix", &db_radix, FCN_NULL },
{ "maxoff", (int *)&db_maxoff, FCN_NULL },
{ "maxwidth", &db_max_width, FCN_NULL },
{ "tabstops", &db_tab_stop_width, FCN_NULL },
{ "lines", &db_max_line, FCN_NULL },
};
struct db_variable *db_evars = db_vars + sizeof(db_vars)/sizeof(db_vars[0]);