--- Gnu-Mach/ddb/db_command.c 2020/09/02 04:36:57 1.1 +++ Gnu-Mach/ddb/db_command.c 2020/09/02 04:48:22 1.1.1.4 @@ -1,25 +1,25 @@ -/* +/* * Mach Operating System * Copyright (c) 1991 Carnegie Mellon University * All Rights Reserved. - * + * * 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. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ @@ -28,31 +28,41 @@ * Date: 7/90 */ -#include "mach_kdb.h" #if MACH_KDB /* * Command dispatcher. */ -#include -#include -#include +#include #include -#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include #include #include /* 4proto */ #include /* 4proto */ - +#include +#include +#include /* * Exported global variables @@ -85,17 +95,17 @@ boolean_t db_ed_style = TRUE; */ int db_cmd_search(name, table, cmdp) - char * name; - struct db_command *table; - struct db_command **cmdp; /* out */ + const char * name; + const struct db_command *table; + const struct db_command **cmdp; /* out */ { - struct db_command *cmd; + const struct db_command *cmd; int result = CMD_NONE; for (cmd = table; cmd->name != 0; cmd++) { - register char *lp; - register char *rp; - register int c; + const char *lp; + char *rp; + int c; lp = name; rp = cmd->name; @@ -132,9 +142,9 @@ db_cmd_search(name, table, cmdp) void db_cmd_list(table) - struct db_command *table; + const struct db_command *table; { - register struct db_command *cmd; + const struct db_command *cmd; for (cmd = table; cmd->name != 0; cmd++) { db_printf("%-12s", cmd->name); @@ -143,9 +153,9 @@ db_cmd_list(table) } void -db_command(last_cmdp, cmd_table) - struct db_command **last_cmdp; /* IN_OUT */ - struct db_command *cmd_table; +db_command( + struct db_command **last_cmdp, /* IN_OUT */ + struct db_command *cmd_table) { struct db_command *cmd; int t; @@ -166,7 +176,6 @@ db_command(last_cmdp, cmd_table) db_unread_token(t); } else if (t == tEXCL) { - void db_fncall(); db_fncall(); return; } @@ -284,50 +293,20 @@ db_command(last_cmdp, cmd_table) } void -db_command_list(last_cmdp, cmd_table) - struct db_command **last_cmdp; /* IN_OUT */ - struct db_command *cmd_table; +db_command_list( + struct db_command **last_cmdp, /* IN_OUT */ + struct db_command *cmd_table) { - void db_skip_to_eol(); - do { db_command(last_cmdp, cmd_table); db_skip_to_eol(); - } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == 0); + } while (db_read_token() == tSEMI_COLON && db_cmd_loop_done == FALSE); } -/* - * 'show' commands - */ -extern void db_listbreak_cmd(); -extern void db_listwatch_cmd(); -extern void db_show_regs(), db_show_one_thread(), db_show_one_task(); -extern void db_show_all_threads(); -extern void db_show_macro(); -extern void vm_map_print(), vm_object_print(), vm_page_print(); -extern void vm_map_copy_print(); -extern void ipc_port_print(), ipc_pset_print(), db_show_all_slocks(); -extern void ipc_kmsg_print(), ipc_msg_print(); -extern void db_show_port_id(); -void db_show_help(); -#if NORMA_IPC -extern void netipc_packet_print(), netipc_pcs_print(), db_show_all_uids(); -extern void db_show_all_proxies(), db_show_all_principals(); -extern void db_show_all_uids_verbose(); -#endif NORMA_IPC -#if NORMA_VM -extern void xmm_obj_print(), xmm_reply_print(); -#endif NORMA_VM - struct db_command db_show_all_cmds[] = { + { "tasks", db_show_all_tasks, 0, 0 }, { "threads", db_show_all_threads, 0, 0 }, { "slocks", db_show_all_slocks, 0, 0 }, -#if NORMA_IPC - { "uids", db_show_all_uids, 0, 0 }, - { "proxies", db_show_all_proxies, 0, 0 }, - { "principals", db_show_all_principals, 0, 0 }, - { "vuids", db_show_all_uids_verbose, 0, 0 }, -#endif NORMA_IPC { (char *)0 } }; @@ -348,31 +327,9 @@ struct db_command db_show_cmds[] = { { "kmsg", ipc_kmsg_print, 0, 0 }, { "msg", ipc_msg_print, 0, 0 }, { "ipc_port", db_show_port_id, 0, 0 }, -#if NORMA_IPC - { "packet", netipc_packet_print, 0, 0 }, - { "pcs", netipc_pcs_print, 0, 0 }, -#endif NORMA_IPC -#if NORMA_VM - { "xmm_obj", xmm_obj_print, 0, 0 }, - { "xmm_reply", xmm_reply_print, 0, 0 }, -#endif NORMA_VM { (char *)0, } }; -extern void db_print_cmd(), db_examine_cmd(), db_set_cmd(); -extern void db_examine_forward(), db_examine_backward(); -extern void db_search_cmd(); -extern void db_write_cmd(); -extern void db_delete_cmd(), db_breakpoint_cmd(); -extern void db_deletewatch_cmd(), db_watchpoint_cmd(); -extern void db_single_step_cmd(), db_trace_until_call_cmd(), - db_trace_until_matching_cmd(), db_continue_cmd(); -extern void db_stack_trace_cmd(), db_cond_cmd(); -void db_help_cmd(); -void db_def_macro_cmd(), db_del_macro_cmd(); -void db_fncall(); -extern void db_reset_cpu(); - struct db_command db_command_table[] = { #ifdef DB_MACHINE_COMMANDS /* this must be the first entry, if it exists */ @@ -407,6 +364,7 @@ struct db_command db_command_table[] = { { "show", 0, 0, db_show_cmds }, { "reset", db_reset_cpu, 0, 0 }, { "reboot", db_reset_cpu, 0, 0 }, + { "halt", db_halt_cpu, 0, 0 }, { (char *)0, } }; @@ -414,20 +372,19 @@ struct db_command db_command_table[] = { /* this function should be called to install the machine dependent commands. It should be called before the debugger is enabled */ -void db_machine_commands_install(ptr) -struct db_command *ptr; +void db_machine_commands_install(struct db_command *ptr) { db_command_table[0].more = ptr; return; } -#endif +#endif /* DB_MACHINE_COMMANDS */ struct db_command *db_last_command = 0; void -db_help_cmd() +db_help_cmd(void) { struct db_command *cmd = db_command_table; @@ -438,18 +395,13 @@ db_help_cmd() } } -int (*ddb_display)(); - void -db_command_loop() +db_command_loop(void) { jmp_buf_t db_jmpbuf; jmp_buf_t *prev = db_recover; extern int db_output_line; extern int db_macro_level; -#if NORMA_IPC - extern int _node_self; /* node_self() may not be callable yet */ -#endif NORMA_IPC /* * Initialize 'prev' and 'next' to dot. @@ -457,10 +409,7 @@ db_command_loop() db_prev = db_dot; db_next = db_dot; - if (ddb_display) - (*ddb_display)(); - - db_cmd_loop_done = 0; + db_cmd_loop_done = FALSE; while (!db_cmd_loop_done) { (void) _setjmp(db_recover = &db_jmpbuf); db_macro_level = 0; @@ -468,9 +417,6 @@ db_command_loop() db_printf("\n"); db_output_line = 0; db_printf("db%s", (db_default_thread)? "t": ""); -#if NORMA_IPC - db_printf("%d", _node_self); -#endif #if NCPUS > 1 db_printf("{%d}", cpu_number()); #endif @@ -484,13 +430,13 @@ db_command_loop() } boolean_t -db_exec_cmd_nest(cmd, size) - char *cmd; - int size; +db_exec_cmd_nest( + char *cmd, + int size) { struct db_lex_context lex_context; - db_cmd_loop_done = 0; + db_cmd_loop_done = FALSE; if (cmd) { db_save_lex_context(&lex_context); db_switch_input(cmd, size /**OLD, &lex_context OLD**/); @@ -498,15 +444,11 @@ db_exec_cmd_nest(cmd, size) db_command_list(&db_last_command, db_command_table); if (cmd) db_restore_lex_context(&lex_context); - return(db_cmd_loop_done == 0); + return(db_cmd_loop_done == FALSE); } -#ifdef __GNUC__ -extern __volatile__ void _longjmp(); -#endif - void db_error(s) - char *s; + const char *s; { extern int db_macro_level; @@ -530,7 +472,7 @@ void db_error(s) * !expr(arg,arg,arg) */ void -db_fncall() +db_fncall(void) { db_expr_t fn_addr; #define MAXARGS 11 @@ -581,12 +523,12 @@ db_fncall() db_printf(" %#N\n", retval); } -boolean_t +boolean_t __attribute__ ((pure)) db_option(modif, option) - char *modif; - int option; + const char *modif; + int option; { - register char *p; + const char *p; for (p = modif; *p; p++) if (*p == option) @@ -594,4 +536,4 @@ db_option(modif, option) return(FALSE); } -#endif MACH_KDB +#endif /* MACH_KDB */