From: naddy Date: Thu, 14 Apr 2022 19:47:10 +0000 (+0000) Subject: ddb: constify command tables X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3fe80b7fb1a5bd0bd4a7a666724b5696fc175a21;p=openbsd ddb: constify command tables ok jca@ --- diff --git a/sys/arch/alpha/alpha/db_interface.c b/sys/arch/alpha/alpha/db_interface.c index a8b3bf1c61a..f0289c6acc7 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.27 2022/04/12 19:44:31 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.28 2022/04/14 19:47:10 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.8 1999/10/12 17:08:57 jdolecek Exp $ */ /* @@ -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 diff --git a/sys/arch/amd64/amd64/db_interface.c b/sys/arch/amd64/amd64/db_interface.c index e4ee28aee56..f0cf5ee29f5 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.38 2022/04/12 19:44:31 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.39 2022/04/14 19:47:10 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.1 2003/04/26 18:39:27 fvdl Exp $ */ /* @@ -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 }, diff --git a/sys/arch/arm/arm/db_interface.c b/sys/arch/arm/arm/db_interface.c index 52fe27437ef..554cda32ccc 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.18 2022/04/12 19:44:31 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.19 2022/04/14 19:47:10 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.34 2003/10/26 23:11:15 chris Exp $ */ /* @@ -340,7 +340,7 @@ db_enter(void) asm(".word 0xe7ffffff"); } -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, diff --git a/sys/arch/arm64/arm64/db_interface.c b/sys/arch/arm64/arm64/db_interface.c index 5381e1bded8..7e7e052eef8 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.11 2022/04/12 19:44:31 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.12 2022/04/14 19:47:11 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.34 2003/10/26 23:11:15 chris Exp $ */ /* @@ -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 }, diff --git a/sys/arch/i386/i386/db_interface.c b/sys/arch/i386/i386/db_interface.c index 19e0f91bb5b..e1700e18f96 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.43 2022/04/12 19:44:31 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.44 2022/04/14 19:47:11 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.22 1996/05/03 19:42:00 christos Exp $ */ /* @@ -314,7 +314,7 @@ db_ddbproc_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) #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 }, diff --git a/sys/arch/m88k/m88k/db_interface.c b/sys/arch/m88k/m88k/db_interface.c index 6ee0f6f634e..4827c21a108 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.27 2022/04/12 19:44:31 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.28 2022/04/14 19:47:11 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_command_table[] = { +const struct db_command db_machine_command_table[] = { #ifdef MULTIPROCESSOR { "ddbcpu", m88k_db_cpu_cmd, 0, NULL }, #endif diff --git a/sys/arch/mips64/mips64/db_machdep.c b/sys/arch/mips64/mips64/db_machdep.c index 136b10a448d..687f3a1b1a1 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.58 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_machdep.c,v 1.59 2022/04/14 19:47:11 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 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 diff --git a/sys/arch/powerpc/ddb/db_interface.c b/sys/arch/powerpc/ddb/db_interface.c index 1e6a988fee2..d241bece4ea 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.9 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.10 2022/04/14 19:47:11 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */ /* @@ -221,7 +221,7 @@ db_cpuinfo_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) } #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 }, diff --git a/sys/arch/powerpc64/powerpc64/db_interface.c b/sys/arch/powerpc64/powerpc64/db_interface.c index e6d2a854ea4..83a74629fc9 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.5 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.6 2022/04/14 19:47:11 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.12 2001/07/22 11:29:46 wiz Exp $ */ /* @@ -67,7 +67,7 @@ int db_enter_ddb(void); #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 }, diff --git a/sys/arch/riscv64/riscv64/db_interface.c b/sys/arch/riscv64/riscv64/db_interface.c index d3211d8adb5..1f4911b09c8 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.7 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.8 2022/04/14 19:47:11 naddy Exp $ */ /* * Copyright (c) 1996 Scott K. Stevens @@ -414,7 +414,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 }, diff --git a/sys/arch/sh/sh/db_interface.c b/sys/arch/sh/sh/db_interface.c index e8091526205..4290dfff0e6 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.14 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.15 2022/04/14 19:47:11 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.37 2006/09/06 00:11:49 uwe Exp $ */ /*- @@ -73,7 +73,7 @@ void db_frame_cmd(db_expr_t, int, db_expr_t, char *); void __db_print_symbol(db_expr_t); char *__db_procname_by_asid(int); -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "tlb", db_tlbdump_cmd, 0, NULL }, { "cache", db_cachedump_cmd, 0, NULL }, { "frame", db_frame_cmd, 0, NULL }, diff --git a/sys/arch/sparc64/sparc64/db_interface.c b/sys/arch/sparc64/sparc64/db_interface.c index dd414cb61d2..39899fb32f0 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.57 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_interface.c,v 1.58 2022/04/14 19:47:12 naddy Exp $ */ /* $NetBSD: db_interface.c,v 1.61 2001/07/31 06:55:47 eeh Exp $ */ /* @@ -1167,7 +1167,7 @@ db_register_xir(void (*fun)(void *, int), void *arg) extern void db_esp(db_expr_t, int, db_expr_t, char *); #endif -struct db_command db_machine_command_table[] = { +const struct db_command db_machine_command_table[] = { { "ctx", db_ctx_cmd, 0, 0 }, { "dtlb", db_dump_dtlb, 0, 0 }, { "dtsb", db_dump_dtsb, 0, 0 }, diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 3146bb7eacb..d6e5a20fc16 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.93 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_command.c,v 1.94 2022/04/14 19:47:12 naddy Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -79,8 +79,9 @@ vaddr_t db_prev; /* last address examined vaddr_t db_next; /* next address to be examined or written */ -int db_cmd_search(char *, struct db_command *, struct db_command **); -void db_cmd_list(struct db_command *); +int db_cmd_search(char *, const struct db_command *, + const struct db_command **); +void db_cmd_list(const struct db_command *); void db_ctf_pprint_cmd(db_expr_t, int, db_expr_t,char *); void db_map_print_cmd(db_expr_t, int, db_expr_t, char *); void db_buf_print_cmd(db_expr_t, int, db_expr_t, char *); @@ -146,9 +147,10 @@ db_skip_to_eol(void) * Search for command prefix. */ int -db_cmd_search(char *name, struct db_command *table, struct db_command **cmdp) +db_cmd_search(char *name, const struct db_command *table, + const struct db_command **cmdp) { - struct db_command *cmd; + const struct db_command *cmd; int result = CMD_NONE; for (cmd = table; cmd->name != 0; cmd++) { @@ -180,9 +182,9 @@ db_cmd_search(char *name, struct db_command *table, struct db_command **cmdp) } void -db_cmd_list(struct db_command *table) +db_cmd_list(const struct db_command *table) { - struct db_command *cmd; + const struct db_command *cmd; for (cmd = table; cmd->name != 0; cmd++) { db_printf("%-12s", cmd->name); @@ -191,9 +193,10 @@ db_cmd_list(struct db_command *table) } void -db_command(struct db_command **last_cmdp, struct db_command *cmd_table) +db_command(const struct db_command **last_cmdp, + const struct db_command *cmd_table) { - struct db_command *cmd; + const struct db_command *cmd; char modif[TOK_STRING_SIZE]; db_expr_t addr, count; int t, result, have_addr = 0; @@ -558,7 +561,7 @@ db_bcstats_print_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif * 'show' commands */ -struct db_command db_show_all_cmds[] = { +const struct db_command db_show_all_cmds[] = { { "procs", db_show_all_procs, 0, NULL }, { "callout", db_show_callout, 0, NULL }, { "pools", db_show_all_pools, 0, NULL }, @@ -578,7 +581,7 @@ struct db_command db_show_all_cmds[] = { { NULL, NULL, 0, NULL } }; -struct db_command db_show_cmds[] = { +const struct db_command db_show_cmds[] = { { "all", NULL, 0, db_show_all_cmds }, { "bcstats", db_bcstats_print_cmd, 0, NULL }, { "breaks", db_listbreak_cmd, 0, NULL }, @@ -615,7 +618,7 @@ struct db_command db_show_cmds[] = { { NULL, NULL, 0, NULL } }; -struct db_command db_boot_cmds[] = { +const struct db_command db_boot_cmds[] = { { "sync", db_boot_sync_cmd, 0, 0 }, { "crash", db_boot_crash_cmd, 0, 0 }, { "dump", db_boot_dump_cmd, 0, 0 }, @@ -625,7 +628,7 @@ struct db_command db_boot_cmds[] = { { NULL, } }; -struct db_command db_command_table[] = { +const struct db_command db_command_table[] = { #ifdef DB_MACHINE_COMMANDS /* this must be the first entry, if it exists */ { "machine", NULL, 0, db_machine_command_table }, @@ -666,7 +669,7 @@ struct db_command db_command_table[] = { { NULL, NULL, 0, NULL } }; -struct db_command *db_last_command = NULL; +const struct db_command *db_last_command = NULL; void db_help_cmd(db_expr_t addr, int haddr, db_expr_t count, char *modif) diff --git a/sys/ddb/db_command.h b/sys/ddb/db_command.h index c9ccce96ff6..dee1538a026 100644 --- a/sys/ddb/db_command.h +++ b/sys/ddb/db_command.h @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.h,v 1.34 2022/04/12 19:44:32 naddy Exp $ */ +/* $OpenBSD: db_command.h,v 1.35 2022/04/14 19:47:12 naddy Exp $ */ /* $NetBSD: db_command.h,v 1.8 1996/02/05 01:56:55 christos Exp $ */ /* @@ -38,7 +38,7 @@ struct db_command; 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_command(const struct db_command **, const struct db_command *); extern vaddr_t db_dot, db_last_addr, db_prev, db_next; @@ -54,9 +54,9 @@ struct db_command { #define CS_MORE 0x2 /* standard syntax, but may have other words at end */ #define CS_SET_DOT 0x100 /* set dot after command */ - struct db_command *more; /* another level of command */ + const struct db_command *more; /* another level of command */ }; #ifdef DB_MACHINE_COMMANDS -extern struct db_command db_machine_command_table[]; +extern const struct db_command db_machine_command_table[]; #endif