1995-05-30 08:16:23 +00:00
|
|
|
/*
|
1993-06-12 14:58:17 +00:00
|
|
|
* Mach Operating System
|
|
|
|
* Copyright (c) 1991,1990 Carnegie Mellon University
|
|
|
|
* All Rights Reserved.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1993-06-12 14:58:17 +00:00
|
|
|
* Permission to use, copy, modify and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
|
1993-06-12 14:58:17 +00:00
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
|
|
|
|
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1993-06-12 14:58:17 +00:00
|
|
|
* Carnegie Mellon requests users of this software to return to
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1993-06-12 14:58:17 +00:00
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1993-06-12 14:58:17 +00:00
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*
|
1999-07-01 19:42:56 +00:00
|
|
|
* $Id: db_command.c,v 1.31 1999/05/09 10:51:03 phk Exp $
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
1993-10-16 16:47:35 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Author: David B. Golub, Carnegie Mellon University
|
|
|
|
* Date: 7/90
|
|
|
|
*/
|
1993-10-16 16:47:35 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Command dispatcher.
|
|
|
|
*/
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/param.h>
|
1999-01-14 06:22:10 +00:00
|
|
|
#include <sys/linker_set.h>
|
1996-08-27 19:46:28 +00:00
|
|
|
#include <sys/reboot.h>
|
1994-08-13 03:50:34 +00:00
|
|
|
#include <sys/systm.h>
|
1995-12-10 19:08:32 +00:00
|
|
|
|
1999-05-09 10:51:13 +00:00
|
|
|
#include <machine/cons.h>
|
|
|
|
|
1995-12-10 19:08:32 +00:00
|
|
|
#include <ddb/ddb.h>
|
1995-11-24 14:13:42 +00:00
|
|
|
#include <ddb/db_command.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
#include <ddb/db_lex.h>
|
|
|
|
#include <ddb/db_output.h>
|
|
|
|
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Exported global variables
|
|
|
|
*/
|
|
|
|
boolean_t db_cmd_loop_done;
|
1998-02-13 02:19:29 +00:00
|
|
|
extern struct linker_set db_cmd_set;
|
1993-06-12 14:58:17 +00:00
|
|
|
db_addr_t db_dot;
|
1996-09-14 09:13:15 +00:00
|
|
|
jmp_buf db_jmpbuf;
|
1993-06-12 14:58:17 +00:00
|
|
|
db_addr_t db_last_addr;
|
|
|
|
db_addr_t db_prev;
|
|
|
|
db_addr_t db_next;
|
1996-12-18 17:58:24 +00:00
|
|
|
extern struct linker_set db_show_cmd_set;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static db_cmdfcn_t db_fncall;
|
1996-08-27 19:46:28 +00:00
|
|
|
static db_cmdfcn_t db_gdb;
|
|
|
|
|
1996-09-14 09:13:15 +00:00
|
|
|
/* XXX this is actually forward-static. */
|
|
|
|
extern struct command db_show_cmds[];
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* if 'ed' style: 'dot' is set at start of last item printed,
|
|
|
|
* and '+' points to next line.
|
|
|
|
* Otherwise: 'dot' points to next item, '..' points to last.
|
|
|
|
*/
|
1995-11-29 10:25:50 +00:00
|
|
|
static boolean_t db_ed_style = TRUE;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Utility routine - discard tokens through end-of-line.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
db_skip_to_eol()
|
|
|
|
{
|
|
|
|
int t;
|
|
|
|
do {
|
|
|
|
t = db_read_token();
|
|
|
|
} while (t != tEOL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Results of command search.
|
|
|
|
*/
|
|
|
|
#define CMD_UNIQUE 0
|
|
|
|
#define CMD_FOUND 1
|
|
|
|
#define CMD_NONE 2
|
|
|
|
#define CMD_AMBIGUOUS 3
|
|
|
|
#define CMD_HELP 4
|
|
|
|
|
1996-09-14 09:13:15 +00:00
|
|
|
static void db_cmd_list __P((struct command *table,
|
|
|
|
struct command **aux_tablep));
|
1995-11-29 10:25:50 +00:00
|
|
|
static int db_cmd_search __P((char *name, struct command *table,
|
1996-09-14 09:13:15 +00:00
|
|
|
struct command **aux_tablep,
|
1995-11-24 14:13:42 +00:00
|
|
|
struct command **cmdp));
|
1995-11-29 10:25:50 +00:00
|
|
|
static void db_command __P((struct command **last_cmdp,
|
1996-09-14 09:13:15 +00:00
|
|
|
struct command *cmd_table,
|
|
|
|
struct command **aux_cmd_tablep));
|
1995-11-24 14:13:42 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
|
|
|
* Search for command prefix.
|
|
|
|
*/
|
1995-11-29 10:25:50 +00:00
|
|
|
static int
|
1996-09-14 09:13:15 +00:00
|
|
|
db_cmd_search(name, table, aux_tablep, cmdp)
|
1993-06-12 14:58:17 +00:00
|
|
|
char * name;
|
|
|
|
struct command *table;
|
1996-09-14 09:13:15 +00:00
|
|
|
struct command **aux_tablep;
|
1993-06-12 14:58:17 +00:00
|
|
|
struct command **cmdp; /* out */
|
|
|
|
{
|
|
|
|
struct command *cmd;
|
1996-09-14 09:13:15 +00:00
|
|
|
struct command **aux_cmdp;
|
1993-06-12 14:58:17 +00:00
|
|
|
int result = CMD_NONE;
|
|
|
|
|
|
|
|
for (cmd = table; cmd->name != 0; cmd++) {
|
|
|
|
register char *lp;
|
|
|
|
register char *rp;
|
|
|
|
register int c;
|
|
|
|
|
|
|
|
lp = name;
|
|
|
|
rp = cmd->name;
|
|
|
|
while ((c = *lp) == *rp) {
|
|
|
|
if (c == 0) {
|
|
|
|
/* complete match */
|
|
|
|
*cmdp = cmd;
|
|
|
|
return (CMD_UNIQUE);
|
|
|
|
}
|
|
|
|
lp++;
|
|
|
|
rp++;
|
|
|
|
}
|
|
|
|
if (c == 0) {
|
|
|
|
/* end of name, not end of command -
|
|
|
|
partial match */
|
|
|
|
if (result == CMD_FOUND) {
|
|
|
|
result = CMD_AMBIGUOUS;
|
|
|
|
/* but keep looking for a full match -
|
|
|
|
this lets us match single letters */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*cmdp = cmd;
|
|
|
|
result = CMD_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1996-09-14 09:13:15 +00:00
|
|
|
if (result == CMD_NONE && aux_tablep != 0)
|
|
|
|
/* XXX repeat too much code. */
|
|
|
|
for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) {
|
|
|
|
register char *lp;
|
|
|
|
register char *rp;
|
|
|
|
register int c;
|
|
|
|
|
|
|
|
lp = name;
|
|
|
|
rp = (*aux_cmdp)->name;
|
|
|
|
while ((c = *lp) == *rp) {
|
|
|
|
if (c == 0) {
|
|
|
|
/* complete match */
|
|
|
|
*cmdp = *aux_cmdp;
|
|
|
|
return (CMD_UNIQUE);
|
|
|
|
}
|
|
|
|
lp++;
|
|
|
|
rp++;
|
|
|
|
}
|
|
|
|
if (c == 0) {
|
|
|
|
/* end of name, not end of command -
|
|
|
|
partial match */
|
|
|
|
if (result == CMD_FOUND) {
|
|
|
|
result = CMD_AMBIGUOUS;
|
|
|
|
/* but keep looking for a full match -
|
|
|
|
this lets us match single letters */
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*cmdp = *aux_cmdp;
|
|
|
|
result = CMD_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1993-06-12 14:58:17 +00:00
|
|
|
if (result == CMD_NONE) {
|
|
|
|
/* check for 'help' */
|
|
|
|
if (name[0] == 'h' && name[1] == 'e'
|
|
|
|
&& name[2] == 'l' && name[3] == 'p')
|
|
|
|
result = CMD_HELP;
|
|
|
|
}
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static void
|
1996-09-14 09:13:15 +00:00
|
|
|
db_cmd_list(table, aux_tablep)
|
1993-06-12 14:58:17 +00:00
|
|
|
struct command *table;
|
1996-09-14 09:13:15 +00:00
|
|
|
struct command **aux_tablep;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
register struct command *cmd;
|
1996-09-14 09:13:15 +00:00
|
|
|
register struct command **aux_cmdp;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
for (cmd = table; cmd->name != 0; cmd++) {
|
|
|
|
db_printf("%-12s", cmd->name);
|
|
|
|
db_end_line();
|
|
|
|
}
|
1996-09-14 09:13:15 +00:00
|
|
|
if (aux_tablep == 0)
|
|
|
|
return;
|
|
|
|
for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) {
|
|
|
|
db_printf("%-12s", (*aux_cmdp)->name);
|
|
|
|
db_end_line();
|
|
|
|
}
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static void
|
1996-09-14 09:13:15 +00:00
|
|
|
db_command(last_cmdp, cmd_table, aux_cmd_tablep)
|
1993-06-12 14:58:17 +00:00
|
|
|
struct command **last_cmdp; /* IN_OUT */
|
|
|
|
struct command *cmd_table;
|
1996-09-14 09:13:15 +00:00
|
|
|
struct command **aux_cmd_tablep;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
struct command *cmd;
|
|
|
|
int t;
|
|
|
|
char modif[TOK_STRING_SIZE];
|
|
|
|
db_expr_t addr, count;
|
1993-11-25 01:38:01 +00:00
|
|
|
boolean_t have_addr = FALSE;
|
1993-06-12 14:58:17 +00:00
|
|
|
int result;
|
|
|
|
|
|
|
|
t = db_read_token();
|
|
|
|
if (t == tEOL) {
|
|
|
|
/* empty line repeats last command, at 'next' */
|
|
|
|
cmd = *last_cmdp;
|
|
|
|
addr = (db_expr_t)db_next;
|
|
|
|
have_addr = FALSE;
|
|
|
|
count = 1;
|
|
|
|
modif[0] = '\0';
|
|
|
|
}
|
|
|
|
else if (t == tEXCL) {
|
1995-08-27 02:39:39 +00:00
|
|
|
db_fncall((db_expr_t)0, (boolean_t)0, (db_expr_t)0, (char *)0);
|
1993-06-12 14:58:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (t != tIDENT) {
|
|
|
|
db_printf("?\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Search for command
|
|
|
|
*/
|
|
|
|
while (cmd_table) {
|
|
|
|
result = db_cmd_search(db_tok_string,
|
|
|
|
cmd_table,
|
1996-09-14 09:13:15 +00:00
|
|
|
aux_cmd_tablep,
|
1993-06-12 14:58:17 +00:00
|
|
|
&cmd);
|
|
|
|
switch (result) {
|
|
|
|
case CMD_NONE:
|
|
|
|
db_printf("No such command\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
case CMD_AMBIGUOUS:
|
|
|
|
db_printf("Ambiguous\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
case CMD_HELP:
|
1996-09-14 09:13:15 +00:00
|
|
|
db_cmd_list(cmd_table, aux_cmd_tablep);
|
1993-06-12 14:58:17 +00:00
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((cmd_table = cmd->more) != 0) {
|
1996-09-14 09:13:15 +00:00
|
|
|
/* XXX usually no more aux's. */
|
|
|
|
aux_cmd_tablep = 0;
|
|
|
|
if (cmd_table == db_show_cmds)
|
|
|
|
aux_cmd_tablep =
|
|
|
|
(struct command **)&db_show_cmd_set.ls_items[0];
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
t = db_read_token();
|
|
|
|
if (t != tIDENT) {
|
1996-09-14 09:13:15 +00:00
|
|
|
db_cmd_list(cmd_table, aux_cmd_tablep);
|
1993-06-12 14:58:17 +00:00
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((cmd->flag & CS_OWN) == 0) {
|
|
|
|
/*
|
|
|
|
* Standard syntax:
|
|
|
|
* command [/modifier] [addr] [,count]
|
|
|
|
*/
|
|
|
|
t = db_read_token();
|
|
|
|
if (t == tSLASH) {
|
|
|
|
t = db_read_token();
|
|
|
|
if (t != tIDENT) {
|
|
|
|
db_printf("Bad modifier\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
db_strcpy(modif, db_tok_string);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
db_unread_token(t);
|
|
|
|
modif[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (db_expression(&addr)) {
|
|
|
|
db_dot = (db_addr_t) addr;
|
|
|
|
db_last_addr = db_dot;
|
|
|
|
have_addr = TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addr = (db_expr_t) db_dot;
|
|
|
|
have_addr = FALSE;
|
|
|
|
}
|
|
|
|
t = db_read_token();
|
|
|
|
if (t == tCOMMA) {
|
|
|
|
if (!db_expression(&count)) {
|
|
|
|
db_printf("Count missing\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
db_unread_token(t);
|
|
|
|
count = -1;
|
|
|
|
}
|
|
|
|
if ((cmd->flag & CS_MORE) == 0) {
|
|
|
|
db_skip_to_eol();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*last_cmdp = cmd;
|
|
|
|
if (cmd != 0) {
|
|
|
|
/*
|
|
|
|
* Execute the command.
|
|
|
|
*/
|
|
|
|
(*cmd->fcn)(addr, have_addr, count, modif);
|
|
|
|
|
|
|
|
if (cmd->flag & CS_SET_DOT) {
|
|
|
|
/*
|
|
|
|
* If command changes dot, set dot to
|
|
|
|
* previous address displayed (if 'ed' style).
|
|
|
|
*/
|
|
|
|
if (db_ed_style) {
|
|
|
|
db_dot = db_prev;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
db_dot = db_next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* If command does not change dot,
|
|
|
|
* set 'next' location to be the same.
|
|
|
|
*/
|
|
|
|
db_next = db_dot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 'show' commands
|
|
|
|
*/
|
1994-08-18 22:36:09 +00:00
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static struct command db_show_all_cmds[] = {
|
1993-06-12 14:58:17 +00:00
|
|
|
#if 0
|
1994-02-11 21:14:52 +00:00
|
|
|
{ "threads", db_show_all_threads, 0, 0 },
|
1994-05-25 09:21:21 +00:00
|
|
|
#endif
|
1994-08-27 16:14:39 +00:00
|
|
|
{ "procs", db_ps, 0, 0 },
|
1993-06-12 14:58:17 +00:00
|
|
|
{ (char *)0 }
|
|
|
|
};
|
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static struct command db_show_cmds[] = {
|
1993-06-12 14:58:17 +00:00
|
|
|
{ "all", 0, 0, db_show_all_cmds },
|
|
|
|
{ "registers", db_show_regs, 0, 0 },
|
|
|
|
{ "breaks", db_listbreak_cmd, 0, 0 },
|
|
|
|
#if 0
|
|
|
|
{ "thread", db_show_one_thread, 0, 0 },
|
|
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
{ "port", ipc_port_print, 0, 0 },
|
|
|
|
#endif
|
|
|
|
{ (char *)0, }
|
|
|
|
};
|
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static struct command db_command_table[] = {
|
1993-06-12 14:58:17 +00:00
|
|
|
{ "print", db_print_cmd, 0, 0 },
|
1995-03-05 22:56:21 +00:00
|
|
|
{ "p", db_print_cmd, 0, 0 },
|
1993-06-12 14:58:17 +00:00
|
|
|
{ "examine", db_examine_cmd, CS_SET_DOT, 0 },
|
|
|
|
{ "x", db_examine_cmd, CS_SET_DOT, 0 },
|
|
|
|
{ "search", db_search_cmd, CS_OWN|CS_SET_DOT, 0 },
|
|
|
|
{ "set", db_set_cmd, CS_OWN, 0 },
|
|
|
|
{ "write", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
|
|
|
|
{ "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
|
|
|
|
{ "delete", db_delete_cmd, 0, 0 },
|
|
|
|
{ "d", db_delete_cmd, 0, 0 },
|
|
|
|
{ "break", db_breakpoint_cmd, 0, 0 },
|
|
|
|
{ "dwatch", db_deletewatch_cmd, 0, 0 },
|
|
|
|
{ "watch", db_watchpoint_cmd, CS_MORE,0 },
|
|
|
|
{ "step", db_single_step_cmd, 0, 0 },
|
|
|
|
{ "s", db_single_step_cmd, 0, 0 },
|
|
|
|
{ "continue", db_continue_cmd, 0, 0 },
|
|
|
|
{ "c", db_continue_cmd, 0, 0 },
|
|
|
|
{ "until", db_trace_until_call_cmd,0, 0 },
|
|
|
|
{ "next", db_trace_until_matching_cmd,0, 0 },
|
|
|
|
{ "match", db_trace_until_matching_cmd,0, 0 },
|
|
|
|
{ "trace", db_stack_trace_cmd, 0, 0 },
|
|
|
|
{ "call", db_fncall, CS_OWN, 0 },
|
|
|
|
{ "show", 0, 0, db_show_cmds },
|
1994-02-11 21:14:52 +00:00
|
|
|
{ "ps", db_ps, 0, 0 },
|
1996-08-27 19:46:28 +00:00
|
|
|
{ "gdb", db_gdb, 0, 0 },
|
1993-06-12 14:58:17 +00:00
|
|
|
{ (char *)0, }
|
|
|
|
};
|
|
|
|
|
1995-11-29 10:25:50 +00:00
|
|
|
static struct command *db_last_command = 0;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1995-03-16 18:17:34 +00:00
|
|
|
#if 0
|
1993-06-12 14:58:17 +00:00
|
|
|
void
|
|
|
|
db_help_cmd()
|
|
|
|
{
|
|
|
|
struct command *cmd = db_command_table;
|
|
|
|
|
|
|
|
while (cmd->name != 0) {
|
|
|
|
db_printf("%-12s", cmd->name);
|
|
|
|
db_end_line();
|
|
|
|
cmd++;
|
|
|
|
}
|
|
|
|
}
|
1995-03-16 18:17:34 +00:00
|
|
|
#endif
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1998-02-13 02:19:29 +00:00
|
|
|
/*
|
|
|
|
* At least one non-optional command must be implemented using
|
|
|
|
* DB_COMMAND() so that db_cmd_set gets created. Here is one.
|
|
|
|
*/
|
|
|
|
DB_COMMAND(panic, db_panic)
|
1995-02-05 21:09:04 +00:00
|
|
|
{
|
1995-03-19 14:29:26 +00:00
|
|
|
panic("from debugger");
|
1995-02-05 21:09:04 +00:00
|
|
|
}
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
void
|
|
|
|
db_command_loop()
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Initialize 'prev' and 'next' to dot.
|
|
|
|
*/
|
|
|
|
db_prev = db_dot;
|
|
|
|
db_next = db_dot;
|
|
|
|
|
|
|
|
db_cmd_loop_done = 0;
|
|
|
|
while (!db_cmd_loop_done) {
|
|
|
|
|
|
|
|
(void) setjmp(db_jmpbuf);
|
|
|
|
if (db_print_position() != 0)
|
|
|
|
db_printf("\n");
|
|
|
|
|
|
|
|
db_printf("db> ");
|
|
|
|
(void) db_read_line();
|
|
|
|
|
1996-09-14 09:13:15 +00:00
|
|
|
db_command(&db_last_command, db_command_table,
|
|
|
|
(struct command **)&db_cmd_set.ls_items[0]);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
db_error(s)
|
|
|
|
char *s;
|
|
|
|
{
|
|
|
|
if (s)
|
|
|
|
db_printf(s);
|
|
|
|
db_flush_lex();
|
|
|
|
longjmp(db_jmpbuf, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call random function:
|
|
|
|
* !expr(arg,arg,arg)
|
|
|
|
*/
|
1995-11-29 10:25:50 +00:00
|
|
|
static void
|
1995-08-27 02:39:39 +00:00
|
|
|
db_fncall(dummy1, dummy2, dummy3, dummy4)
|
|
|
|
db_expr_t dummy1;
|
|
|
|
boolean_t dummy2;
|
|
|
|
db_expr_t dummy3;
|
|
|
|
char * dummy4;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
|
|
|
db_expr_t fn_addr;
|
1995-11-24 14:13:42 +00:00
|
|
|
#define MAXARGS 11 /* XXX only 10 are passed */
|
1993-06-12 14:58:17 +00:00
|
|
|
db_expr_t args[MAXARGS];
|
|
|
|
int nargs = 0;
|
|
|
|
db_expr_t retval;
|
1995-11-24 14:13:42 +00:00
|
|
|
typedef db_expr_t fcn_10args_t __P((db_expr_t, db_expr_t, db_expr_t,
|
|
|
|
db_expr_t, db_expr_t, db_expr_t,
|
|
|
|
db_expr_t, db_expr_t, db_expr_t,
|
|
|
|
db_expr_t));
|
|
|
|
fcn_10args_t *func;
|
1993-06-12 14:58:17 +00:00
|
|
|
int t;
|
|
|
|
|
|
|
|
if (!db_expression(&fn_addr)) {
|
|
|
|
db_printf("Bad function\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
1995-11-24 14:13:42 +00:00
|
|
|
func = (fcn_10args_t *)fn_addr; /* XXX */
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
t = db_read_token();
|
|
|
|
if (t == tLPAREN) {
|
|
|
|
if (db_expression(&args[0])) {
|
|
|
|
nargs++;
|
|
|
|
while ((t = db_read_token()) == tCOMMA) {
|
|
|
|
if (nargs == MAXARGS) {
|
|
|
|
db_printf("Too many arguments\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!db_expression(&args[nargs])) {
|
|
|
|
db_printf("Argument missing\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
nargs++;
|
|
|
|
}
|
|
|
|
db_unread_token(t);
|
|
|
|
}
|
|
|
|
if (db_read_token() != tRPAREN) {
|
|
|
|
db_printf("?\n");
|
|
|
|
db_flush_lex();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
db_skip_to_eol();
|
|
|
|
|
|
|
|
while (nargs < MAXARGS) {
|
|
|
|
args[nargs++] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = (*func)(args[0], args[1], args[2], args[3], args[4],
|
|
|
|
args[5], args[6], args[7], args[8], args[9] );
|
1999-07-01 19:42:56 +00:00
|
|
|
db_printf("%#lr\n", (long)retval);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1996-08-27 19:46:28 +00:00
|
|
|
|
|
|
|
/* Enter GDB remote protocol debugger on the next trap. */
|
|
|
|
|
1999-05-09 10:51:13 +00:00
|
|
|
dev_t gdbdev = NODEV;
|
|
|
|
cn_getc_t *gdb_getc;
|
|
|
|
cn_putc_t *gdb_putc;
|
1999-05-07 23:08:23 +00:00
|
|
|
|
1996-08-27 19:46:28 +00:00
|
|
|
static void
|
|
|
|
db_gdb (dummy1, dummy2, dummy3, dummy4)
|
|
|
|
db_expr_t dummy1;
|
|
|
|
boolean_t dummy2;
|
|
|
|
db_expr_t dummy3;
|
|
|
|
char * dummy4;
|
|
|
|
{
|
1999-05-07 23:08:23 +00:00
|
|
|
|
1999-05-09 10:51:13 +00:00
|
|
|
if (gdbdev == NODEV) {
|
1999-05-07 23:08:23 +00:00
|
|
|
db_printf("No gdb port enabled. Set flag 0x80 on desired port\n");
|
|
|
|
db_printf("in your configuration file (currently sio only).\n");
|
|
|
|
return;
|
|
|
|
}
|
1996-08-27 19:46:28 +00:00
|
|
|
boothowto ^= RB_GDB;
|
|
|
|
|
|
|
|
db_printf("Next trap will enter %s\n",
|
|
|
|
boothowto & RB_GDB ? "GDB remote protocol mode"
|
|
|
|
: "DDB debugger");
|
|
|
|
}
|