db_command.c (50477) | db_command.c (78161) |
---|---|
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 * | 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 $ | 26 * $FreeBSD: head/sys/ddb/db_command.c 78161 2001-06-13 10:58:39Z 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; | 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; | 54db_addr_t db_dot; 55jmp_buf db_jmpbuf; 56db_addr_t db_last_addr; 57db_addr_t db_prev; 58db_addr_t db_next; |
60extern struct linker_set db_show_cmd_set; | |
61 | 59 |
60SET_DECLARE(db_cmd_set, struct command); 61SET_DECLARE(db_show_cmd_set, struct command); 62 |
|
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, | 63static db_cmdfcn_t db_fncall; 64static db_cmdfcn_t db_gdb; 65 66/* XXX this is actually forward-static. */ 67extern struct command db_show_cmds[]; 68 69/* 70 * if 'ed' style: 'dot' is set at start of last item printed, --- 19 unchanged lines hidden (view full) --- 90 */ 91#define CMD_UNIQUE 0 92#define CMD_FOUND 1 93#define CMD_NONE 2 94#define CMD_AMBIGUOUS 3 95#define CMD_HELP 4 96 97static void db_cmd_list __P((struct command *table, |
97 struct command **aux_tablep)); | 98 struct command **aux_tablep, 99 struct command **aux_tablep_end)); |
98static int db_cmd_search __P((char *name, struct command *table, 99 struct command **aux_tablep, | 100static int db_cmd_search __P((char *name, struct command *table, 101 struct command **aux_tablep, |
102 struct command **aux_tablep_end, |
|
100 struct command **cmdp)); 101static void db_command __P((struct command **last_cmdp, 102 struct command *cmd_table, | 103 struct command **cmdp)); 104static void db_command __P((struct command **last_cmdp, 105 struct command *cmd_table, |
103 struct command **aux_cmd_tablep)); | 106 struct command **aux_cmd_tablep, 107 struct command **aux_cmd_tablep_end)); |
104 105/* 106 * Search for command prefix. 107 */ 108static int | 108 109/* 110 * Search for command prefix. 111 */ 112static int |
109db_cmd_search(name, table, aux_tablep, cmdp) | 113db_cmd_search(name, table, aux_tablep, aux_tablep_end, cmdp) |
110 char * name; 111 struct command *table; 112 struct command **aux_tablep; | 114 char * name; 115 struct command *table; 116 struct command **aux_tablep; |
117 struct command **aux_tablep_end; |
|
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. */ | 118 struct command **cmdp; /* out */ 119{ 120 struct command *cmd; 121 struct command **aux_cmdp; 122 int result = CMD_NONE; 123 124 for (cmd = table; cmd->name != 0; cmd++) { 125 register char *lp; --- 22 unchanged lines hidden (view full) --- 148 else { 149 *cmdp = cmd; 150 result = CMD_FOUND; 151 } 152 } 153 } 154 if (result == CMD_NONE && aux_tablep != 0) 155 /* XXX repeat too much code. */ |
151 for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) { | 156 for (aux_cmdp = aux_tablep; aux_cmdp < aux_tablep_end; 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 | 157 register char *lp; 158 register char *rp; 159 register int c; 160 161 lp = name; 162 rp = (*aux_cmdp)->name; 163 while ((c = *lp) == *rp) { 164 if (c == 0) { --- 23 unchanged lines hidden (view full) --- 188 if (name[0] == 'h' && name[1] == 'e' 189 && name[2] == 'l' && name[3] == 'p') 190 result = CMD_HELP; 191 } 192 return (result); 193} 194 195static void |
191db_cmd_list(table, aux_tablep) | 196db_cmd_list(table, aux_tablep, aux_tablep_end) |
192 struct command *table; 193 struct command **aux_tablep; | 197 struct command *table; 198 struct command **aux_tablep; |
199 struct command **aux_tablep_end; |
|
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; | 200{ 201 register struct command *cmd; 202 register struct command **aux_cmdp; 203 204 for (cmd = table; cmd->name != 0; cmd++) { 205 db_printf("%-12s", cmd->name); 206 db_end_line(); 207 } 208 if (aux_tablep == 0) 209 return; |
204 for (aux_cmdp = aux_tablep; *aux_cmdp != 0; aux_cmdp++) { | 210 for (aux_cmdp = aux_tablep; aux_cmdp < aux_tablep_end; aux_cmdp++) { |
205 db_printf("%-12s", (*aux_cmdp)->name); 206 db_end_line(); 207 } 208} 209 210static void | 211 db_printf("%-12s", (*aux_cmdp)->name); 212 db_end_line(); 213 } 214} 215 216static void |
211db_command(last_cmdp, cmd_table, aux_cmd_tablep) | 217db_command(last_cmdp, cmd_table, aux_cmd_tablep, aux_cmd_tablep_end) |
212 struct command **last_cmdp; /* IN_OUT */ 213 struct command *cmd_table; 214 struct command **aux_cmd_tablep; | 218 struct command **last_cmdp; /* IN_OUT */ 219 struct command *cmd_table; 220 struct command **aux_cmd_tablep; |
221 struct command **aux_cmd_tablep_end; |
|
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, | 222{ 223 struct command *cmd; 224 int t; 225 char modif[TOK_STRING_SIZE]; 226 db_expr_t addr, count; 227 boolean_t have_addr = FALSE; 228 int result; 229 --- 18 unchanged lines hidden (view full) --- 248 else { 249 /* 250 * Search for command 251 */ 252 while (cmd_table) { 253 result = db_cmd_search(db_tok_string, 254 cmd_table, 255 aux_cmd_tablep, |
256 aux_cmd_tablep_end, |
|
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: | 257 &cmd); 258 switch (result) { 259 case CMD_NONE: 260 db_printf("No such command\n"); 261 db_flush_lex(); 262 return; 263 case CMD_AMBIGUOUS: 264 db_printf("Ambiguous\n"); 265 db_flush_lex(); 266 return; 267 case CMD_HELP: |
260 db_cmd_list(cmd_table, aux_cmd_tablep); | 268 db_cmd_list(cmd_table, aux_cmd_tablep, aux_cmd_tablep_end); |
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) | 269 db_flush_lex(); 270 return; 271 default: 272 break; 273 } 274 if ((cmd_table = cmd->more) != 0) { 275 /* XXX usually no more aux's. */ 276 aux_cmd_tablep = 0; 277 if (cmd_table == db_show_cmds) |
270 aux_cmd_tablep = 271 (struct command **)&db_show_cmd_set.ls_items[0]; | 278 aux_cmd_tablep = SET_BEGIN(db_show_cmd_set); 279 aux_cmd_tablep_end = SET_LIMIT(db_show_cmd_set); |
272 273 t = db_read_token(); 274 if (t != tIDENT) { | 280 281 t = db_read_token(); 282 if (t != tIDENT) { |
275 db_cmd_list(cmd_table, aux_cmd_tablep); | 283 db_cmd_list(cmd_table, aux_cmd_tablep, aux_cmd_tablep_end); |
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, | 284 db_flush_lex(); 285 return; 286 } 287 } 288 } 289 290 if ((cmd->flag & CS_OWN) == 0) { 291 /* --- 164 unchanged lines hidden (view full) --- 456 (void) setjmp(db_jmpbuf); 457 if (db_print_position() != 0) 458 db_printf("\n"); 459 460 db_printf("db> "); 461 (void) db_read_line(); 462 463 db_command(&db_last_command, db_command_table, |
456 (struct command **)&db_cmd_set.ls_items[0]); | 464 SET_BEGIN(db_cmd_set), SET_LIMIT(db_cmd_set)); |
457 } 458} 459 460void 461db_error(s) 462 char *s; 463{ 464 if (s) --- 97 unchanged lines hidden --- | 465 } 466} 467 468void 469db_error(s) 470 char *s; 471{ 472 if (s) --- 97 unchanged lines hidden --- |