From: naddy Date: Tue, 12 Apr 2022 19:44:31 +0000 (+0000) Subject: ddb: simplify machine command handling X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d03db17a454f2e50a4836738000e20dd446c9aaa;p=openbsd ddb: simplify machine command handling Define a consistently named db_machine_command_table[] across all archs that implement the MD "machine" command, and hook this into the main command table instead of patching it at runtime. ok mpi@ jca@ --- diff --git a/sys/arch/alpha/alpha/db_interface.c b/sys/arch/alpha/alpha/db_interface.c index fd83cb898bc..a8b3bf1c61a 100644 --- a/sys/arch/alpha/alpha/db_interface.c +++ b/sys/arch/alpha/alpha/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.26 2019/11/07 14:44:52 mpi Exp $ */ +/* $OpenBSD: db_interface.c,v 1.27 2022/04/12 19:44:31 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.8 1999/10/12 17:08:57 jdolecek Exp $ */ /* @@ -527,5 +527,4 @@ db_mach_cpu(db_expr_t addr, int have_addr, db_expr_t count, char *modif) void db_machine_init() { - db_machine_commands_install(db_machine_command_table); } diff --git a/sys/arch/amd64/amd64/db_interface.c b/sys/arch/amd64/amd64/db_interface.c index 186fb4d83fb..e4ee28aee56 100644 --- a/sys/arch/amd64/amd64/db_interface.c +++ b/sys/arch/amd64/amd64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.37 2021/08/31 14:37:49 mlarkin Exp $ */ +/* $OpenBSD: db_interface.c,v 1.38 2022/04/12 19:44:31 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -422,10 +422,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; diff --git a/sys/arch/arm/arm/db_interface.c b/sys/arch/arm/arm/db_interface.c index a8d7805cd6f..52fe27437ef 100644 --- a/sys/arch/arm/arm/db_interface.c +++ b/sys/arch/arm/arm/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.17 2021/03/25 04:12:00 jsg Exp $ */ +/* $OpenBSD: db_interface.c,v 1.18 2022/04/12 19:44:31 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.34 2003/10/26 23:11:15 chris Exp $ */ /* @@ -378,8 +378,6 @@ db_machine_init(void) */ db_uh.uh_handler = db_trapper; install_coproc_handler_static(0, &db_uh); - - db_machine_commands_install(db_machine_command_table); } u_int diff --git a/sys/arch/arm64/arm64/db_interface.c b/sys/arch/arm64/arm64/db_interface.c index ed28376be20..5381e1bded8 100644 --- a/sys/arch/arm64/arm64/db_interface.c +++ b/sys/arch/arm64/arm64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.10 2021/05/30 15:05:32 visa Exp $ */ +/* $OpenBSD: db_interface.c,v 1.11 2022/04/12 19:44:31 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.34 2003/10/26 23:11:15 chris Exp $ */ /* @@ -499,10 +499,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; diff --git a/sys/arch/i386/i386/db_interface.c b/sys/arch/i386/i386/db_interface.c index b4c6a02021c..19e0f91bb5b 100644 --- a/sys/arch/i386/i386/db_interface.c +++ b/sys/arch/i386/i386/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.42 2019/11/06 07:34:35 mpi Exp $ */ +/* $OpenBSD: db_interface.c,v 1.43 2022/04/12 19:44:31 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.22 1996/05/03 19:42:00 christos Exp $ */ /* @@ -342,10 +342,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif /* MULTIPROCESSOR */ - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; diff --git a/sys/arch/m88k/m88k/db_interface.c b/sys/arch/m88k/m88k/db_interface.c index 4d540ea2ad0..6ee0f6f634e 100644 --- a/sys/arch/m88k/m88k/db_interface.c +++ b/sys/arch/m88k/m88k/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.26 2021/03/11 11:16:58 jsg Exp $ */ +/* $OpenBSD: db_interface.c,v 1.27 2022/04/12 19:44:31 naddy Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -654,7 +654,7 @@ m88k_db_cpu_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) /* COMMAND TABLE / INIT */ /************************/ -struct db_command db_machine_cmds[] = { +struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "ddbcpu", m88k_db_cpu_cmd, 0, NULL }, #endif @@ -671,7 +671,6 @@ struct db_command db_machine_cmds[] = { void db_machine_init() { - db_machine_commands_install(db_machine_cmds); #ifdef MULTIPROCESSOR __mp_lock_init(&ddb_mp_lock); #endif diff --git a/sys/arch/mips64/mips64/db_machdep.c b/sys/arch/mips64/mips64/db_machdep.c index bbdf2462b57..136b10a448d 100644 --- a/sys/arch/mips64/mips64/db_machdep.c +++ b/sys/arch/mips64/mips64/db_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_machdep.c,v 1.57 2021/05/30 15:05:32 visa Exp $ */ +/* $OpenBSD: db_machdep.c,v 1.58 2022/04/12 19:44:32 naddy Exp $ */ /* * Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se) @@ -492,7 +492,7 @@ db_dump_tlb_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *m) } -struct db_command mips_db_command_table[] = { +struct db_command db_machine_command_table[] = { { "tlb", db_dump_tlb_cmd, 0, NULL }, { "trap", db_trap_trace_cmd, 0, NULL }, #ifdef MULTIPROCESSOR @@ -510,10 +510,7 @@ db_machine_init(void) extern char *ssym; #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(mips_db_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < ncpus; i++) { get_cpu_info(i)->ci_ddb = CI_DDB_RUNNING; } diff --git a/sys/arch/powerpc/ddb/db_interface.c b/sys/arch/powerpc/ddb/db_interface.c index da7249e3b99..1e6a988fee2 100644 --- a/sys/arch/powerpc/ddb/db_interface.c +++ b/sys/arch/powerpc/ddb/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.8 2022/01/28 18:37:40 gkoehler Exp $ */ +/* $OpenBSD: db_interface.c,v 1.9 2022/04/12 19:44:32 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */ /* @@ -236,10 +236,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < ncpus; i++) { cpu_info[i].ci_ddb_paused = CI_DDB_RUNNING; } diff --git a/sys/arch/powerpc64/powerpc64/db_interface.c b/sys/arch/powerpc64/powerpc64/db_interface.c index e86b1d664bd..e6d2a854ea4 100644 --- a/sys/arch/powerpc64/powerpc64/db_interface.c +++ b/sys/arch/powerpc64/powerpc64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.4 2021/05/30 15:05:33 visa Exp $ */ +/* $OpenBSD: db_interface.c,v 1.5 2022/04/12 19:44:32 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */ /* @@ -120,7 +120,6 @@ db_machine_init(void) } } - db_machine_commands_install(db_machine_command_table); #ifdef MULTIPROCESSOR for (i = 0; i < ncpus; i++) { cpu_info[i].ci_ddb_paused = CI_DDB_RUNNING; diff --git a/sys/arch/riscv64/riscv64/db_interface.c b/sys/arch/riscv64/riscv64/db_interface.c index d5f880b74b5..d3211d8adb5 100644 --- a/sys/arch/riscv64/riscv64/db_interface.c +++ b/sys/arch/riscv64/riscv64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.6 2021/07/11 12:21:52 jasper Exp $ */ +/* $OpenBSD: db_interface.c,v 1.7 2022/04/12 19:44:32 naddy Exp $ */ /* * Copyright (c) 1996 Scott K. Stevens @@ -446,10 +446,7 @@ db_machine_init(void) { #ifdef MULTIPROCESSOR int i; -#endif - db_machine_commands_install(db_machine_command_table); -#ifdef MULTIPROCESSOR for (i = 0; i < MAXCPUS; i++) { if (cpu_info[i] != NULL) cpu_info[i]->ci_ddb_paused = CI_DDB_RUNNING; diff --git a/sys/arch/sh/sh/db_interface.c b/sys/arch/sh/sh/db_interface.c index b01fdfead60..e8091526205 100644 --- a/sys/arch/sh/sh/db_interface.c +++ b/sys/arch/sh/sh/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.13 2019/11/07 16:08:08 mpi Exp $ */ +/* $OpenBSD: db_interface.c,v 1.14 2022/04/12 19:44:32 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.37 2006/09/06 00:11:49 uwe Exp $ */ /*- @@ -86,8 +86,6 @@ struct db_command db_machine_command_table[] = { void db_machine_init(void) { - - db_machine_commands_install(db_machine_command_table); } void diff --git a/sys/arch/sparc64/sparc64/db_interface.c b/sys/arch/sparc64/sparc64/db_interface.c index fc2382cf0cf..dd414cb61d2 100644 --- a/sys/arch/sparc64/sparc64/db_interface.c +++ b/sys/arch/sparc64/sparc64/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.56 2021/05/30 15:05:33 visa Exp $ */ +/* $OpenBSD: db_interface.c,v 1.57 2022/04/12 19:44:32 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.61 2001/07/31 06:55:47 eeh Exp $ */ /* @@ -1363,5 +1363,4 @@ db_inst_trap_return(int inst) void db_machine_init(void) { - db_machine_commands_install(db_machine_command_table); } diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index f89595531f6..3146bb7eacb 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.92 2021/11/16 13:53:14 bluhm Exp $ */ +/* $OpenBSD: db_command.c,v 1.93 2022/04/12 19:44:32 naddy Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -628,7 +628,7 @@ struct db_command db_boot_cmds[] = { struct db_command db_command_table[] = { #ifdef DB_MACHINE_COMMANDS /* this must be the first entry, if it exists */ - { "machine", NULL, 0, NULL}, + { "machine", NULL, 0, db_machine_command_table }, #endif { "kill", db_kill_cmd, 0, NULL }, { "print", db_print_cmd, 0, NULL }, @@ -666,18 +666,6 @@ struct db_command db_command_table[] = { { NULL, NULL, 0, NULL } }; -#ifdef DB_MACHINE_COMMANDS - -/* 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(struct db_command *ptr) -{ - db_command_table[0].more = ptr; -} - -#endif - struct db_command *db_last_command = NULL; void diff --git a/sys/ddb/db_command.h b/sys/ddb/db_command.h index 45800424d35..c9ccce96ff6 100644 --- a/sys/ddb/db_command.h +++ b/sys/ddb/db_command.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.h,v 1.33 2019/11/07 13:16:25 mpi Exp $ */ +/* $OpenBSD: db_command.h,v 1.34 2022/04/12 19:44:32 naddy Exp $ */ /* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */ /* @@ -39,7 +39,6 @@ void db_error(char *); void db_skip_to_eol(void); void db_command_loop(void); void db_command(struct db_command **, struct db_command *); -void db_machine_commands_install(struct db_command *); extern vaddr_t db_dot, db_last_addr, db_prev, db_next; @@ -57,3 +56,7 @@ struct db_command { #define CS_SET_DOT 0x100 /* set dot after command */ struct db_command *more; /* another level of command */ }; + +#ifdef DB_MACHINE_COMMANDS +extern struct db_command db_machine_command_table[]; +#endif