Deleted Added
sdiff udiff text old ( 50477 ) new ( 78161 )
full compact
1/*
2 * Mach Operating System
3 * Copyright (c) 1991,1990 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the

--- 9 unchanged lines hidden (view full) ---

18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie the
24 * rights to redistribute these changes.
25 *
26 * $FreeBSD: head/sys/ddb/db_command.c 50477 1999-08-28 01:08:13Z peter $
27 */
28
29/*
30 * Author: David B. Golub, Carnegie Mellon University
31 * Date: 7/90
32 */
33
34/*

--- 11 unchanged lines hidden (view full) ---

46#include <ddb/db_output.h>
47
48#include <setjmp.h>
49
50/*
51 * Exported global variables
52 */
53boolean_t db_cmd_loop_done;
54extern struct linker_set db_cmd_set;
55db_addr_t db_dot;
56jmp_buf db_jmpbuf;
57db_addr_t db_last_addr;
58db_addr_t db_prev;
59db_addr_t db_next;
60extern struct linker_set db_show_cmd_set;
61
62static db_cmdfcn_t db_fncall;
63static db_cmdfcn_t db_gdb;
64
65/* XXX this is actually forward-static. */
66extern struct command db_show_cmds[];
67
68/*
69 * if 'ed' style: 'dot' is set at start of last item printed,

--- 19 unchanged lines hidden (view full) ---

89 */
90#define CMD_UNIQUE 0
91#define CMD_FOUND 1
92#define CMD_NONE 2
93#define CMD_AMBIGUOUS 3
94#define CMD_HELP 4
95
96static void db_cmd_list __P((struct command *table,
97 struct command **aux_tablep));
98static int db_cmd_search __P((char *name, struct command *table,
99 struct command **aux_tablep,
100 struct command **cmdp));
101static void db_command __P((struct command **last_cmdp,
102 struct command *cmd_table,
103 struct command **aux_cmd_tablep));
104
105/*
106 * Search for command prefix.
107 */
108static int
109db_cmd_search(name, table, aux_tablep, cmdp)
110 char * name;
111 struct command *table;
112 struct command **aux_tablep;
113 struct command **cmdp; /* out */
114{
115 struct command *cmd;
116 struct command **aux_cmdp;
117 int result = CMD_NONE;
118
119 for (cmd = table; cmd->name != 0; cmd++) {
120 register char *lp;

--- 22 unchanged lines hidden (view full) ---

143 else {
144 *cmdp = cmd;
145 result = CMD_FOUND;
146 }
147 }
148 }
149 if (result == CMD_NONE && aux_tablep != 0)
150 /* XXX repeat too much code. */
151 for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) {
152 register char *lp;
153 register char *rp;
154 register int c;
155
156 lp = name;
157 rp = (*aux_cmdp)->name;
158 while ((c = *lp) == *rp) {
159 if (c == 0) {

--- 23 unchanged lines hidden (view full) ---

183 if (name[0] == 'h' && name[1] == 'e'
184 && name[2] == 'l' && name[3] == 'p')
185 result = CMD_HELP;
186 }
187 return (result);
188}
189
190static void
191db_cmd_list(table, aux_tablep)
192 struct command *table;
193 struct command **aux_tablep;
194{
195 register struct command *cmd;
196 register struct command **aux_cmdp;
197
198 for (cmd = table; cmd->name != 0; cmd++) {
199 db_printf("%-12s", cmd->name);
200 db_end_line();
201 }
202 if (aux_tablep == 0)
203 return;
204 for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) {
205 db_printf("%-12s", (*aux_cmdp)->name);
206 db_end_line();
207 }
208}
209
210static void
211db_command(last_cmdp, cmd_table, aux_cmd_tablep)
212 struct command **last_cmdp; /* IN_OUT */
213 struct command *cmd_table;
214 struct command **aux_cmd_tablep;
215{
216 struct command *cmd;
217 int t;
218 char modif[TOK_STRING_SIZE];
219 db_expr_t addr, count;
220 boolean_t have_addr = FALSE;
221 int result;
222

--- 18 unchanged lines hidden (view full) ---

241 else {
242 /*
243 * Search for command
244 */
245 while (cmd_table) {
246 result = db_cmd_search(db_tok_string,
247 cmd_table,
248 aux_cmd_tablep,
249 &cmd);
250 switch (result) {
251 case CMD_NONE:
252 db_printf("No such command\n");
253 db_flush_lex();
254 return;
255 case CMD_AMBIGUOUS:
256 db_printf("Ambiguous\n");
257 db_flush_lex();
258 return;
259 case CMD_HELP:
260 db_cmd_list(cmd_table, aux_cmd_tablep);
261 db_flush_lex();
262 return;
263 default:
264 break;
265 }
266 if ((cmd_table = cmd->more) != 0) {
267 /* XXX usually no more aux's. */
268 aux_cmd_tablep = 0;
269 if (cmd_table == db_show_cmds)
270 aux_cmd_tablep =
271 (struct command **)&db_show_cmd_set.ls_items[0];
272
273 t = db_read_token();
274 if (t != tIDENT) {
275 db_cmd_list(cmd_table, aux_cmd_tablep);
276 db_flush_lex();
277 return;
278 }
279 }
280 }
281
282 if ((cmd->flag & CS_OWN) == 0) {
283 /*

--- 164 unchanged lines hidden (view full) ---

448 (void) setjmp(db_jmpbuf);
449 if (db_print_position() != 0)
450 db_printf("\n");
451
452 db_printf("db> ");
453 (void) db_read_line();
454
455 db_command(&db_last_command, db_command_table,
456 (struct command **)&db_cmd_set.ls_items[0]);
457 }
458}
459
460void
461db_error(s)
462 char *s;
463{
464 if (s)

--- 97 unchanged lines hidden ---