Re: ddb: simplify "machine" command handling
On Mon, Apr 11 2022, Christian Weisgerber wrote: > Christian Weisgerber: > >> This will allow constifying the ddb command tables in a subsequent >> step. > > And here's that boring follow-up diff. sparc64 and riscv64 GENERIC and GENERIC.MP build successfully with this diff and the previous one, "machine" behaves as expected in ddb(4). ok jca@ -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: ddb: simplify "machine" command handling
Christian Weisgerber: > This will allow constifying the ddb command tables in a subsequent > step. And here's that boring follow-up diff. M sys/arch/alpha/alpha/db_interface.c M sys/arch/amd64/amd64/db_interface.c M sys/arch/arm/arm/db_interface.c M sys/arch/arm64/arm64/db_interface.c M sys/arch/i386/i386/db_interface.c M sys/arch/m88k/m88k/db_interface.c M sys/arch/mips64/mips64/db_machdep.c M sys/arch/powerpc/ddb/db_interface.c M sys/arch/powerpc64/powerpc64/db_interface.c M sys/arch/riscv64/riscv64/db_interface.c M sys/arch/sh/sh/db_interface.c M sys/arch/sparc64/sparc64/db_interface.c M sys/ddb/db_command.c M sys/ddb/db_command.h diff c5fcb00219e59f5bbd0cb5171af7fe5d01f0a0c3 6e95eec92a4f984cd0aff5dd99dd725920c1f1b6 blob - 7e9ce6cc9803586260886d5c16ff2e1219cc2c77 blob + 3f5056966aa3b44d3d4cdc1113256fc05c528026 --- sys/arch/alpha/alpha/db_interface.c +++ sys/arch/alpha/alpha/db_interface.c @@ -85,7 +85,7 @@ db_regs_t ddb_regs; void db_mach_cpu(db_expr_t, int, db_expr_t, char *); #endif -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #if defined(MULTIPROCESSOR) { "ddbcpu", db_mach_cpu,0, NULL }, #endif blob - b12b9c48cf147c1525c19e11fac84b35b02bc19f blob + bd57af87e871b65736c5f4afa8c4f3f98b9bef5c --- sys/arch/amd64/amd64/db_interface.c +++ sys/arch/amd64/amd64/db_interface.c @@ -394,7 +394,7 @@ x86_ipi_db(struct cpu_info *ci) #endif /* MULTIPROCESSOR */ #if NACPI > 0 -struct db_command db_acpi_cmds[] = { +const struct db_command db_acpi_cmds[] = { { "disasm", db_acpi_disasm, CS_OWN, NULL }, { "showval",db_acpi_showval,CS_OWN, NULL }, { "tree", db_acpi_tree, 0, NULL }, @@ -403,7 +403,7 @@ struct db_command db_acpi_cmds[] = { }; #endif /* NACPI > 0 */ -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "cpuinfo",db_cpuinfo_cmd, 0, 0 }, { "startcpu", db_startproc_cmd, 0, 0 }, blob - 719da88249590509dabb734794daedc7c2a3dd61 blob + bcc0cad7ce3f7c7c180b99d7aaa43b9d6c554738 --- sys/arch/arm/arm/db_interface.c +++ sys/arch/arm/arm/db_interface.c @@ -340,7 +340,7 @@ db_enter(void) asm(".word 0xe7ff"); } -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "frame", db_show_frame_cmd, 0, NULL }, #ifdef ARM32_DB_COMMANDS ARM32_DB_COMMANDS, blob - 1645b49186bed36130ffd73a933e45f8f9fc5e18 blob + cb7ecd25005541d590f94cf07152154d3340ade5 --- sys/arch/arm64/arm64/db_interface.c +++ sys/arch/arm64/arm64/db_interface.c @@ -469,7 +469,7 @@ db_stopcpu(int cpu) } #endif -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "cpuinfo",db_cpuinfo_cmd, 0, NULL }, { "startcpu", db_startproc_cmd, 0, NULL }, blob - 1807bc890744e4f32ef839e73e5647fd5488b901 blob + be2562e3a816dc0d8579275de6fc373458f5fb3e --- sys/arch/i386/i386/db_interface.c +++ sys/arch/i386/i386/db_interface.c @@ -314,7 +314,7 @@ db_ddbproc_cmd(db_expr_t addr, int have_addr, db_expr_ #endif /* MULTIPROCESSOR */ #if NACPI > 0 -struct db_command db_acpi_cmds[] = { +const struct db_command db_acpi_cmds[] = { { "disasm", db_acpi_disasm, CS_OWN, NULL }, { "showval",db_acpi_showval,CS_OWN, NULL }, { "tree", db_acpi_tree, 0, NULL }, @@ -323,7 +323,7 @@ struct db_command db_acpi_cmds[] = { }; #endif /* NACPI > 0 */ -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "sysregs",db_sysregs_cmd, 0, 0 }, #ifdef MULTIPROCESSOR { "cpuinfo",db_cpuinfo_cmd, 0, 0 }, blob - 55d5e5ba78719c954c4d6d1f5ffa9083e941a932 blob + eab0352da587873642a701debbbc0c00e8f19052 --- sys/arch/m88k/m88k/db_interface.c +++ sys/arch/m88k/m88k/db_interface.c @@ -654,7 +654,7 @@ m88k_db_cpu_cmd(db_expr_t addr, int have_addr, db_expr /* COMMAND TABLE / INIT */ // -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "ddbcpu", m88k_db_cpu_cmd,0, NULL }, #endif blob - 2c7d67c597c2a237420af198985aaa20781f124e blob + b5f2651c9dccdc3281ea43496bc68a8a86a73d26 --- sys/arch/mips64/mips64/db_machdep.c +++ sys/arch/mips64/mips64/db_machdep.c @@ -492,7 +492,7 @@ db_dump_tlb_cmd(db_expr_t addr, int have_addr, db_expr } -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "tlb",db_dump_tlb_cmd,0, NULL }, { "trap", db_trap_trace_cmd, 0, NULL }, #ifdef MULTIPROCESSOR blob -
ddb: simplify "machine" command handling
Most of our architectures implement a "machine" command as a MD extension in ddb(4). Currently that is handled in this way: * A define is placed in a MD header. * The MI ddb code checks for the define, creates an incomplete entry in the command table, and provides an initialization function. * MD code calls this function to patch a pointer to the MD sub-command into the MI command table. I guess it made sense in 1990? We can simplify this: 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. Most archs already use the name db_machine_command_table[]. This will allow constifying the ddb command tables in a subsequent step. I have tested amd64, arm64, and i386. Comments, ok? M sys/arch/alpha/alpha/db_interface.c M sys/arch/amd64/amd64/db_interface.c M sys/arch/arm/arm/db_interface.c M sys/arch/arm64/arm64/db_interface.c M sys/arch/i386/i386/db_interface.c M sys/arch/m88k/m88k/db_interface.c M sys/arch/mips64/mips64/db_machdep.c M sys/arch/powerpc/ddb/db_interface.c M sys/arch/powerpc64/powerpc64/db_interface.c M sys/arch/riscv64/riscv64/db_interface.c M sys/arch/sh/sh/db_interface.c M sys/arch/sparc64/sparc64/db_interface.c M sys/ddb/db_command.c M sys/ddb/db_command.h diff 7e559a9c431834a0b3471b1fa86985ca220b83ba c5fcb00219e59f5bbd0cb5171af7fe5d01f0a0c3 blob - fd83cb898bcddb466570b0c531b0b34171a1363f blob + 7e9ce6cc9803586260886d5c16ff2e1219cc2c77 --- sys/arch/alpha/alpha/db_interface.c +++ sys/arch/alpha/alpha/db_interface.c @@ -527,5 +527,4 @@ db_mach_cpu(db_expr_t addr, int have_addr, db_expr_t c void db_machine_init() { - db_machine_commands_install(db_machine_command_table); } blob - 186fb4d83fb4d5f849e88297c311f37eaf4638c6 blob + b12b9c48cf147c1525c19e11fac84b35b02bc19f --- sys/arch/amd64/amd64/db_interface.c +++ sys/arch/amd64/amd64/db_interface.c @@ -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; blob - a8d7805cd6f73e9d281b448e8bb03fb77e210df2 blob + 719da88249590509dabb734794daedc7c2a3dd61 --- sys/arch/arm/arm/db_interface.c +++ sys/arch/arm/arm/db_interface.c @@ -378,8 +378,6 @@ db_machine_init(void) */ db_uh.uh_handler = db_trapper; install_coproc_handler_static(0, _uh); - - db_machine_commands_install(db_machine_command_table); } u_int blob - ed28376be206f5eb55ae034981680025b2717513 blob + 1645b49186bed36130ffd73a933e45f8f9fc5e18 --- sys/arch/arm64/arm64/db_interface.c +++ sys/arch/arm64/arm64/db_interface.c @@ -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; blob - b4c6a02021c944ddea37cb8add864ee1f65a454b blob + 1807bc890744e4f32ef839e73e5647fd5488b901 --- sys/arch/i386/i386/db_interface.c +++ sys/arch/i386/i386/db_interface.c @@ -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; blob - 4d540ea2ad0e5b2d0b8a3c15837309bfe5f8db8c blob + 55d5e5ba78719c954c4d6d1f5ffa9083e941a932 --- sys/arch/m88k/m88k/db_interface.c +++ sys/arch/m88k/m88k/db_interface.c @@ -654,7 +654,7 @@ m88k_db_cpu_cmd(db_expr_t addr, int have_addr, db_expr /* 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(_mp_lock); #endif blob - bbdf2462b57e310bb79ee1890d7a5495f9487226 blob + 2c7d67c597c2a237420af198985aaa20781f124e --- sys/arch/mips64/mips64/db_machdep.c +++ sys/arch/mips64/mips64/db_machdep.c @@ -492,7 +492,7 @@ db_dump_tlb_cmd(db_expr_t addr, int have_addr, db_expr } -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