Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ddb_trap_hook



> > > > i'll remove ddb_trap_hook unless anyone objects.
> > > 
> > > Why ? I've found this usefull on occasion, when the kernel doesn't accept
> > > keyboard input any more (both in dom0 and domU).
> > 
> > because:
> > - it annoys me when the console doesn't have enough lines.  eg. vga
> 
> You can still use dmesg to get what was before the trace

not all messages are from kernel.

> > - it isn't xen-specific at all.
> >   if it's really desirable, it should be done in MI ddb.
> 
> Sure it would be nice to have this in MI ddb as a compile time option.
> For now, please keep it as a compile time option so that it can be enabled
> when desireable.

the attached patch is enough for you?
usage: options DDB_COMMANDONENTER="tr;sh re"

YAMAMOTO Takashi
Index: conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.739.2.3
diff -u -p -r1.739.2.3 files
--- conf/files  22 Nov 2005 16:08:06 -0000      1.739.2.3
+++ conf/files  23 Nov 2005 13:00:31 -0000
@@ -202,6 +202,7 @@ defflag     opt_mbr.h               COMPAT_386BSD_MBRPART
 defflag        opt_ddb.h               DDB
 defparam opt_ddbparam.h                DDB_FROMCONSOLE DDB_ONPANIC 
DDB_HISTORY_SIZE
                                DDB_BREAK_CHAR DDB_KEYCODE SYMTAB_SPACE
+                               DDB_COMMANDONENTER
 defflag        opt_kgdb.h              KGDB
 defparam opt_kgdb.h            KGDB_DEV KGDB_DEVNAME KGDB_DEVPORT
                                KGDB_DEVADDR KGDB_DEVRATE KGDB_DEVMODE
Index: ddb/db_command.c
===================================================================
RCS file: /cvsroot/src/sys/ddb/db_command.c,v
retrieving revision 1.79
diff -u -p -r1.79 db_command.c
--- ddb/db_command.c    1 Jun 2005 12:25:27 -0000       1.79
+++ ddb/db_command.c    23 Nov 2005 13:00:31 -0000
@@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD$");
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
 #include "opt_inet.h"
+#include "opt_ddbparam.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -201,6 +202,10 @@ static const struct db_command db_comman
 };
 
 static const struct db_command *db_last_command = NULL;
+#if defined(DDB_COMMANDONENTER)
+const char *db_cmd_on_enter = ___STRING(DDB_COMMANDONENTER);
+#endif /* defined(DDB_COMMANDONENTER) */
+#define        DB_LINE_SEP     ';'
 
 /*
  * Utility routine - discard tokens through end-of-line.
@@ -244,6 +249,27 @@ db_command_loop(void)
        db_recover = &db_jmpbuf;
        (void) setjmp(&db_jmpbuf);
 
+#if defined(DDB_COMMANDONENTER)
+       if (db_cmd_on_enter != NULL) {
+               const struct db_command *dummy = NULL;
+               const char *cmd = db_cmd_on_enter;
+
+               while (*cmd != '\0') {
+                       const char *ep = cmd;
+
+                       while (*ep != '\0' && *ep != DB_LINE_SEP) {
+                               ep++;
+                       }
+                       db_set_line(cmd, ep);
+                       db_command(&dummy, db_command_table);
+                       cmd = ep;
+                       if (*cmd == DB_LINE_SEP) {
+                               cmd++;
+                       }
+               }
+       }
+#endif /* defined(DDB_COMMANDONENTER) */
+
        while (!db_cmd_loop_done) {
                if (db_print_position() != 0)
                        db_printf("\n");
Index: ddb/db_lex.c
===================================================================
RCS file: /cvsroot/src/sys/ddb/db_lex.c,v
retrieving revision 1.18
diff -u -p -r1.18 db_lex.c
--- ddb/db_lex.c        17 May 2003 09:58:03 -0000      1.18
+++ ddb/db_lex.c        23 Nov 2005 13:00:31 -0000
@@ -52,7 +52,8 @@ db_expr_t     db_tok_number;
 char           db_tok_string[TOK_STRING_SIZE];
 
 static char    db_line[120];
-static char    *db_lp, *db_endlp;
+static const char *db_lp;
+static const char *db_endlp;
 
 static int     db_look_char = 0;
 static int     db_look_token = 0;
@@ -70,11 +71,18 @@ db_read_line(void)
        i = db_readline(db_line, sizeof(db_line));
        if (i == 0)
                return (0);     /* EOI */
-       db_lp = db_line;
-       db_endlp = db_lp + i;
+       db_set_line(db_line, db_line + i);
        return (i);
 }
 
+void
+db_set_line(const char *sp, const char *ep)
+{
+
+       db_lp = sp;
+       db_endlp = ep;
+}
+
 static void
 db_flush_line(void)
 {
Index: ddb/db_lex.h
===================================================================
RCS file: /cvsroot/src/sys/ddb/db_lex.h,v
retrieving revision 1.13
diff -u -p -r1.13 db_lex.h
--- ddb/db_lex.h        15 Feb 2002 07:33:51 -0000      1.13
+++ ddb/db_lex.h        23 Nov 2005 13:00:31 -0000
@@ -35,6 +35,7 @@
 void   db_flush_lex(void);
 char   *db_num_to_str(db_expr_t);
 int    db_read_line(void);
+void   db_set_line(const char *, const char *);
 int    db_read_token(void);
 void   db_unread_token(int);
 


Home | Main Index | Thread Index | Old Index