From nobody Tue Jul 05 15:08:57 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 370961D027A3; Tue, 5 Jul 2022 15:08:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LcmKQ0D1sz3twK; Tue, 5 Jul 2022 15:08:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657033738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LOK9rvb8Ihe2/QC7/8TnYYPI9tONc2KxiW7N+fPxG4k=; b=ag14uv/dFt9foYYRZJIR5v07/YGchs/xqZpm+impWcegjk8dRKYAi/GSjipKT36qq/Ns46 PWM2GiiSRQ2JqCIBm4F/EN0EkFD4wa4ZZzE8UV1Ygsdfxpe/FwwELS8FEUIG3+152c2yZE SKmE4eSpGu9/9ilJ0LpVM6hGrwMqKGdbrXpFq9jcyF9aE+5iZBq1a2g/mEKUfrppff3nPK JR6cL5iM9uUwzLVlic5l0zlafff4yGLHQSOC5EEGoMfaw8DxKDky/Phr/pQEBf8rA3d7mc UmNQdTQIjVlTLq68m7jdaTRP6/jOCovyjZ1z3SLWAnhx2VY6KhcxBy+cqWYXfg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCA0F27C82; Tue, 5 Jul 2022 15:08:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 265F8vc6069953; Tue, 5 Jul 2022 15:08:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 265F8vUN069952; Tue, 5 Jul 2022 15:08:57 GMT (envelope-from git) Date: Tue, 5 Jul 2022 15:08:57 GMT Message-Id: <202207051508.265F8vUN069952@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 8a0994823365 - main - db_command.c: use designated initializers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a0994823365740f4d92842c2d6f7f524310ba64 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657033738; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=LOK9rvb8Ihe2/QC7/8TnYYPI9tONc2KxiW7N+fPxG4k=; b=i8qJpy+tV8xOh++4zxumCuoMIGfeHyOCT4HtQBI3VqlX977fJ7bbs3fdUNCjeSshVpliVw 2By4uAhKjd1nsNEtmgCH1xey36yTEVESCEgBAmWQD/uFE4LRlS/thckxZNAilA4mO9WMst LsFF1Zs3sk9S5m0HF8hs5kj47x9odtLmRK76IY0PcIxCeH61e/mqAtSPSumFY+K7zrMp6N fjR7eY605GbAg2XfPCSe/O9mRbGozHJ0hGbS2XJXlKd9rPOPq/SsmJ5lXSm5zcm3CWXLOv C9tUks3M5MeG9FU2FvVgRul228AkCxKIuaI8zEBBGmdnUhkUegH0tkQcxQpSGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657033738; a=rsa-sha256; cv=none; b=kgC8ZiS3hTmbH5yhRx4ifQh6RvcnaEIdm+ptHeHfsoQVUPQQlkbeC/wEngUsd/vHu4LSMS ThfcxJqHdvbFOmv85gGaV/tlSrMg8fYRLijQVPZgN5NCQnuSMW+/or7eDs5nSwM5E7+elg 4KJOCUYMwUmcJUsHDwb8r0UcwMa8SX9YmAzAO1HGc0WKbFi3k2wLoqRsizeBKiKP0VIGoH LyCDaXHJiO19R09k1dE/wWBEoXjjj7DNxBa3SFJDh98oKyH9tGXaI/m6iifUqKz9ktJndn RC+LhYdJc4sO+qi/lffKee/8DSj028MRJ7x+Q/9m5AohOPU8b3upEFCu+nxH4Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=8a0994823365740f4d92842c2d6f7f524310ba64 commit 8a0994823365740f4d92842c2d6f7f524310ba64 Author: Mitchell Horne AuthorDate: 2022-07-05 14:45:47 +0000 Commit: Mitchell Horne CommitDate: 2022-07-05 14:51:31 +0000 db_command.c: use designated initializers Provide separate helper macros for regular commands and next-level table commands as they are mutually exclusive. This ensures proper initialization of each element and allows us to exclude some redundant fields, such as specifying .more = NULL for every regular command. Reviewed by: markj, jhb MFC after: 3 days Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D35580 --- sys/ddb/db_command.c | 127 ++++++++++++++++++++++++++++----------------------- 1 file changed, 70 insertions(+), 57 deletions(-) diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index e0183e11ab93..e6de6cd716e2 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -79,84 +79,97 @@ static db_cmdfcn_t db_stack_trace_active; static db_cmdfcn_t db_stack_trace_all; static db_cmdfcn_t db_watchdog; -/* - * 'show' commands - */ +#define DB_CMD(_name, _func, _flags) \ +{ \ + .name = (_name), \ + .fcn = (_func), \ + .flag = (_flags), \ + .more = NULL, \ +} +#define DB_TABLE(_name, _more) \ +{ \ + .name = (_name), \ + .fcn = NULL, \ + .more = (_more), \ +} static struct db_command db_show_active_cmds[] = { - { "trace", db_stack_trace_active, 0, NULL }, + DB_CMD("trace", db_stack_trace_active, 0), }; struct db_command_table db_show_active_table = LIST_HEAD_INITIALIZER(db_show_active_table); static struct db_command db_show_all_cmds[] = { - { "trace", db_stack_trace_all, 0, NULL }, + DB_CMD("trace", db_stack_trace_all, 0), }; struct db_command_table db_show_all_table = LIST_HEAD_INITIALIZER(db_show_all_table); static struct db_command db_show_cmds[] = { - { "active", 0, 0, &db_show_active_table }, - { "all", 0, 0, &db_show_all_table }, - { "registers", db_show_regs, 0, NULL }, - { "breaks", db_listbreak_cmd, 0, NULL }, - { "threads", db_show_threads, 0, NULL }, + DB_TABLE("active", &db_show_active_table), + DB_TABLE("all", &db_show_all_table), + DB_CMD("registers", db_show_regs, 0), + DB_CMD("breaks", db_listbreak_cmd, 0), + DB_CMD("threads", db_show_threads, 0), }; struct db_command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table); static struct db_command db_cmds[] = { - { "print", db_print_cmd, 0, NULL }, - { "p", db_print_cmd, 0, NULL }, - { "examine", db_examine_cmd, CS_SET_DOT, NULL }, - { "x", db_examine_cmd, CS_SET_DOT, NULL }, - { "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL }, - { "set", db_set_cmd, CS_OWN, NULL }, - { "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL }, - { "w", db_write_cmd, CS_MORE|CS_SET_DOT, NULL }, - { "delete", db_delete_cmd, 0, NULL }, - { "d", db_delete_cmd, 0, NULL }, - { "dump", db_dump, 0, NULL }, - { "break", db_breakpoint_cmd, 0, NULL }, - { "b", db_breakpoint_cmd, 0, NULL }, - { "dwatch", db_deletewatch_cmd, 0, NULL }, - { "watch", db_watchpoint_cmd, CS_MORE,NULL }, - { "dhwatch", db_deletehwatch_cmd, 0, NULL }, - { "hwatch", db_hwatchpoint_cmd, 0, NULL }, - { "step", db_single_step_cmd, 0, NULL }, - { "s", db_single_step_cmd, 0, NULL }, - { "continue", db_continue_cmd, 0, NULL }, - { "c", db_continue_cmd, 0, NULL }, - { "until", db_trace_until_call_cmd,0, NULL }, - { "next", db_trace_until_matching_cmd,0, NULL }, - { "match", db_trace_until_matching_cmd,0, NULL }, - { "trace", db_stack_trace, CS_OWN, NULL }, - { "t", db_stack_trace, CS_OWN, NULL }, + DB_TABLE("show", &db_show_table), + DB_CMD("print", db_print_cmd, 0), + DB_CMD("p", db_print_cmd, 0), + DB_CMD("examine", db_examine_cmd, CS_SET_DOT), + DB_CMD("x", db_examine_cmd, CS_SET_DOT), + DB_CMD("search", db_search_cmd, CS_OWN|CS_SET_DOT), + DB_CMD("set", db_set_cmd, CS_OWN), + DB_CMD("write", db_write_cmd, CS_MORE|CS_SET_DOT), + DB_CMD("w", db_write_cmd, CS_MORE|CS_SET_DOT), + DB_CMD("delete", db_delete_cmd, 0), + DB_CMD("d", db_delete_cmd, 0), + DB_CMD("dump", db_dump, 0), + DB_CMD("break", db_breakpoint_cmd, 0), + DB_CMD("b", db_breakpoint_cmd, 0), + DB_CMD("dwatch", db_deletewatch_cmd, 0), + DB_CMD("watch", db_watchpoint_cmd, CS_MORE), + DB_CMD("dhwatch", db_deletehwatch_cmd, 0), + DB_CMD("hwatch", db_hwatchpoint_cmd, 0), + DB_CMD("step", db_single_step_cmd, 0), + DB_CMD("s", db_single_step_cmd, 0), + DB_CMD("continue", db_continue_cmd, 0), + DB_CMD("c", db_continue_cmd, 0), + DB_CMD("until", db_trace_until_call_cmd, 0), + DB_CMD("next", db_trace_until_matching_cmd, 0), + DB_CMD("match", db_trace_until_matching_cmd, 0), + DB_CMD("trace", db_stack_trace, CS_OWN), + DB_CMD("t", db_stack_trace, CS_OWN), /* XXX alias for active trace */ - { "acttrace", db_stack_trace_active, 0, NULL }, + DB_CMD("acttrace", db_stack_trace_active, 0), /* XXX alias for all trace */ - { "alltrace", db_stack_trace_all, 0, NULL }, - { "where", db_stack_trace, CS_OWN, NULL }, - { "bt", db_stack_trace, CS_OWN, NULL }, - { "call", db_fncall, CS_OWN, NULL }, - { "show", 0, 0, &db_show_table }, - { "ps", db_ps, 0, NULL }, - { "gdb", db_gdb, 0, NULL }, - { "halt", db_halt, 0, NULL }, - { "reboot", db_reset, 0, NULL }, - { "reset", db_reset, 0, NULL }, - { "kill", db_kill, CS_OWN, NULL }, - { "watchdog", db_watchdog, CS_OWN, NULL }, - { "thread", db_set_thread, 0, NULL }, - { "run", db_run_cmd, CS_OWN, NULL }, - { "script", db_script_cmd, CS_OWN, NULL }, - { "scripts", db_scripts_cmd, 0, NULL }, - { "unscript", db_unscript_cmd, CS_OWN, NULL }, - { "capture", db_capture_cmd, CS_OWN, NULL }, - { "textdump", db_textdump_cmd, CS_OWN, NULL }, - { "findstack", db_findstack_cmd, 0, NULL }, + DB_CMD("alltrace", db_stack_trace_all, 0), + DB_CMD("where", db_stack_trace, CS_OWN), + DB_CMD("bt", db_stack_trace, CS_OWN), + DB_CMD("call", db_fncall, CS_OWN), + DB_CMD("ps", db_ps, 0), + DB_CMD("gdb", db_gdb, 0), + DB_CMD("halt", db_halt, 0), + DB_CMD("reboot", db_reset, 0), + DB_CMD("reset", db_reset, 0), + DB_CMD("kill", db_kill, CS_OWN), + DB_CMD("watchdog", db_watchdog, CS_OWN), + DB_CMD("thread", db_set_thread, 0), + DB_CMD("run", db_run_cmd, CS_OWN), + DB_CMD("script", db_script_cmd, CS_OWN), + DB_CMD("scripts", db_scripts_cmd, 0), + DB_CMD("unscript", db_unscript_cmd, CS_OWN), + DB_CMD("capture", db_capture_cmd, CS_OWN), + DB_CMD("textdump", db_textdump_cmd, CS_OWN), + DB_CMD("findstack", db_findstack_cmd, 0), }; struct db_command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table); +#undef DB_CMD +#undef DB_TABLE + static struct db_command *db_last_command = NULL; /*