make DDB_COMMANDONENTER sysctl. (ddb.commandonenter)
suggested by Christos Zoulas.
This commit is contained in:
parent
a53e9b6a94
commit
3afdabd868
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_command.c,v 1.80 2005/11/26 12:16:44 yamt Exp $ */
|
||||
/* $NetBSD: db_command.c,v 1.81 2005/11/27 13:05:28 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.80 2005/11/26 12:16:44 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.81 2005/11/27 13:05:28 yamt Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
|
@ -203,7 +203,9 @@ static const struct db_command db_command_table[] = {
|
|||
|
||||
static const struct db_command *db_last_command = NULL;
|
||||
#if defined(DDB_COMMANDONENTER)
|
||||
const char *db_cmd_on_enter = ___STRING(DDB_COMMANDONENTER);
|
||||
char db_cmd_on_enter[DB_LINE_MAXLEN + 1] = ___STRING(DDB_COMMANDONENTER);
|
||||
#else /* defined(DDB_COMMANDONENTER) */
|
||||
char db_cmd_on_enter[DB_LINE_MAXLEN + 1] = "";
|
||||
#endif /* defined(DDB_COMMANDONENTER) */
|
||||
#define DB_LINE_SEP ';'
|
||||
|
||||
|
@ -231,6 +233,27 @@ db_error(s)
|
|||
longjmp(db_recover);
|
||||
}
|
||||
|
||||
static void
|
||||
db_execute_commandlist(const char *cmdlist)
|
||||
{
|
||||
const char *cmd = cmdlist;
|
||||
const struct db_command *dummy = NULL;
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
db_command_loop(void)
|
||||
{
|
||||
|
@ -249,26 +272,7 @@ 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) */
|
||||
db_execute_commandlist(db_cmd_on_enter);
|
||||
|
||||
while (!db_cmd_loop_done) {
|
||||
if (db_print_position() != 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_command.h,v 1.24 2005/06/01 12:25:27 drochner Exp $ */
|
||||
/* $NetBSD: db_command.h,v 1.25 2005/11/27 13:05:28 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -45,6 +45,8 @@ extern db_addr_t db_prev; /* last address examined
|
|||
extern db_addr_t db_next; /* next address to be examined
|
||||
or written */
|
||||
|
||||
extern char db_cmd_on_enter[];
|
||||
|
||||
/*
|
||||
* Command table
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_lex.c,v 1.19 2005/11/26 12:16:45 yamt Exp $ */
|
||||
/* $NetBSD: db_lex.c,v 1.20 2005/11/27 13:05:28 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -34,7 +34,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.19 2005/11/26 12:16:45 yamt Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.20 2005/11/27 13:05:28 yamt Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -51,7 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_lex.c,v 1.19 2005/11/26 12:16:45 yamt Exp $");
|
|||
db_expr_t db_tok_number;
|
||||
char db_tok_string[TOK_STRING_SIZE];
|
||||
|
||||
static char db_line[120];
|
||||
static char db_line[DB_LINE_MAXLEN];
|
||||
static const char *db_lp;
|
||||
static const char *db_endlp;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_lex.h,v 1.14 2005/11/26 12:16:45 yamt Exp $ */
|
||||
/* $NetBSD: db_lex.h,v 1.15 2005/11/27 13:05:28 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -39,8 +39,10 @@ void db_set_line(const char *, const char *);
|
|||
int db_read_token(void);
|
||||
void db_unread_token(int);
|
||||
|
||||
#define DB_LINE_MAXLEN 120
|
||||
|
||||
extern db_expr_t db_tok_number;
|
||||
#define TOK_STRING_SIZE 120
|
||||
#define TOK_STRING_SIZE DB_LINE_MAXLEN
|
||||
extern char db_tok_string[];
|
||||
|
||||
#define tEOF (-1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: db_variables.c,v 1.33 2005/06/01 12:25:27 drochner Exp $ */
|
||||
/* $NetBSD: db_variables.c,v 1.34 2005/11/27 13:05:28 yamt Exp $ */
|
||||
|
||||
/*
|
||||
* Mach Operating System
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.33 2005/06/01 12:25:27 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: db_variables.c,v 1.34 2005/11/27 13:05:28 yamt Exp $");
|
||||
|
||||
#include "opt_ddbparam.h"
|
||||
|
||||
|
@ -166,6 +166,13 @@ SYSCTL_SETUP(sysctl_ddb_setup, "sysctl ddb subtree setup")
|
|||
SYSCTL_DESCR("Whether to tee ddb output to the msgbuf"),
|
||||
NULL, 0, &db_tee_msgbuf, 0,
|
||||
CTL_DDB, CTL_CREATE, CTL_EOL);
|
||||
|
||||
sysctl_createv(clog, 0, NULL, NULL,
|
||||
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
|
||||
CTLTYPE_STRING, "commandonenter",
|
||||
SYSCTL_DESCR("Command to be executed on each ddb enter"),
|
||||
NULL, 0, &db_cmd_on_enter, DB_LINE_MAXLEN,
|
||||
CTL_DDB, CTL_CREATE, CTL_EOL);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue