command: print BUG warning when usage is missing
authorMathias K <kesmtp@freenet.de>
Sat, 24 Dec 2011 14:26:12 +0000 (15:26 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 4 Jan 2012 17:13:03 +0000 (17:13 +0000)
These error messages will prompt patches to be submitted for missing
.usage or empty fields. All of the below must be resolved before next
release.

The Jim defined commands are excluded from this checklist because the
help text can be set later than during command registration.

strlen(.usage) == 0 means that the command expects no arguments.

Updates to this patch in Gerrit to fix problems below are most
welcome. Anyone can push updated versions of a patch to Gerrit. If
there are no further updates to this patch within a week, it will be
pushed to the master branch to prompt more fixes.

These were caught by launching OpenOCD.

Error: BUG: command 'command' does not have the '.usage' field filled out
Error: BUG: command 'script' does not have the '.usage' field filled out
Error: BUG: command 'power_restore' does not have the '.usage' field filled out
Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out
Error: BUG: command 'measure_clk' does not have the '.usage' field filled out
Error: BUG: command 'exit' does not have the '.usage' field filled out
Error: BUG: command 'shutdown' does not have the '.usage' field filled out
Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out
Error: BUG: command 'interface_list' does not have the '.usage' field filled out
Error: BUG: command 'target' does not have the '.usage' field filled out
Error: BUG: command 'target init' does not have the '.usage' field filled out
Error: BUG: command 'flash' does not have the '.usage' field filled out
Error: BUG: command 'flash init' does not have the '.usage' field filled out
Error: BUG: command 'flash banks' does not have the '.usage' field filled out
Error: BUG: command 'nand' does not have the '.usage' field filled out
Error: BUG: command 'nand drivers' does not have the '.usage' field filled out
Error: BUG: command 'nand init' does not have the '.usage' field filled out
Error: BUG: command 'pld' does not have the '.usage' field filled out
Error: BUG: command 'pld init' does not have the '.usage' field filled out
Error: BUG: command 'mflash' does not have the '.usage' field filled out
Error: BUG: command 'mflash init' does not have the '.usage' field filled out
Error: BUG: command 'dummy' does not have the '.usage' field filled out
Error: BUG: command 'dummy foo' does not have the '.usage' field filled out
Error: BUG: command 'scan_chain' does not have the '.usage' field filled out
Error: BUG: command 'jtag' does not have the '.usage' field filled out
Error: BUG: command 'jtag init' does not have the '.usage' field filled out
Error: BUG: command 'arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'etm' does not have the '.usage' field filled out
Error: BUG: command 'arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'target_request' does not have the '.usage' field filled out
^C
oyvind@fierce:~/openocd$ openocd -c "interface dummy" -f board/at91eb40a.cfg 2>&1 | grep -w BUG
Error: BUG: command 'command' does not have the '.usage' field filled out
Error: BUG: command 'script' does not have the '.usage' field filled out
Error: BUG: command 'power_restore' does not have the '.usage' field filled out
Error: BUG: command 'srst_deasserted' does not have the '.usage' field filled out
Error: BUG: command 'measure_clk' does not have the '.usage' field filled out
Error: BUG: command 'exit' does not have the '.usage' field filled out
Error: BUG: command 'shutdown' does not have the '.usage' field filled out
Error: BUG: command 'gdb_sync' does not have the '.usage' field filled out
Error: BUG: command 'interface_list' does not have the '.usage' field filled out
Error: BUG: command 'target' does not have the '.usage' field filled out
Error: BUG: command 'target init' does not have the '.usage' field filled out
Error: BUG: command 'flash' does not have the '.usage' field filled out
Error: BUG: command 'flash init' does not have the '.usage' field filled out
Error: BUG: command 'flash banks' does not have the '.usage' field filled out
Error: BUG: command 'nand' does not have the '.usage' field filled out
Error: BUG: command 'nand drivers' does not have the '.usage' field filled out
Error: BUG: command 'nand init' does not have the '.usage' field filled out
Error: BUG: command 'pld' does not have the '.usage' field filled out
Error: BUG: command 'pld init' does not have the '.usage' field filled out
Error: BUG: command 'mflash' does not have the '.usage' field filled out
Error: BUG: command 'mflash init' does not have the '.usage' field filled out
Error: BUG: command 'dummy' does not have the '.usage' field filled out
Error: BUG: command 'dummy foo' does not have the '.usage' field filled out
Error: BUG: command 'scan_chain' does not have the '.usage' field filled out
Error: BUG: command 'jtag' does not have the '.usage' field filled out
Error: BUG: command 'jtag init' does not have the '.usage' field filled out
Error: BUG: command 'arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'etm' does not have the '.usage' field filled out
Error: BUG: command 'arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm' does not have the '.usage' field filled out
Error: BUG: command 'arm reg' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu etm' does not have the '.usage' field filled out
Error: BUG: command 'at91eb40a.cpu arm7_9' does not have the '.usage' field filled out
Error: BUG: command 'target_request' does not have the '.usage' field filled out

Change-Id: I2c3e529530a15d2295a1950ffc59e8f2fc661012
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Signed-off-by: Mathias K <kesmtp@freenet.de>
Reviewed-on: http://openocd.zylin.com/299
Tested-by: jenkins
Reviewed-by: Øyvind Harboe <oyvindharboe@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/helper/command.c
src/openocd.c
src/target/target.c
src/target/trace.c
src/transport/transport.c

index 552031df063d1614e53e143bb910ac18f57388a3..65e538bbdcf8e60d650c54273d779b48eb8dc5a9 100644 (file)
@@ -323,6 +323,22 @@ static struct command *command_new(struct command_context *cmd_ctx,
 {
        assert(cr->name);
 
 {
        assert(cr->name);
 
+       /*
+          If it is a non-jim command with no .usage specified,
+          log an error.
+
+          strlen(.usage) == 0 means that the command takes no
+          arguments.
+       */
+       if ((cr->jim_handler == NULL) &&
+           (cr->usage == NULL)) {
+               LOG_DEBUG("BUG: command '%s%s%s' does not have the "
+                       "'.usage' field filled out",
+                       parent && parent->name ? parent->name : "",
+                       parent && parent->name ? " " : "",
+                       cr->name);
+       }
+
        struct command *c = calloc(1, sizeof(struct command));
        if (NULL == c)
                return NULL;
        struct command *c = calloc(1, sizeof(struct command));
        if (NULL == c)
                return NULL;
index 3f0e14289f047d3a75e309ff5d083e5ccce999f4..60cbf232a61d1c8e68f006a2d5c3dc2606791149 100644 (file)
@@ -195,6 +195,7 @@ static const struct command_registration openocd_command_handlers[] = {
                .handler = &handle_noinit_command,
                .mode = COMMAND_CONFIG,
                .help = "Prevent 'init' from being called at startup.",
                .handler = &handle_noinit_command,
                .mode = COMMAND_CONFIG,
                .help = "Prevent 'init' from being called at startup.",
+               .usage = ""
        },
        {
                .name = "init",
        },
        {
                .name = "init",
@@ -204,14 +205,14 @@ static const struct command_registration openocd_command_handlers[] = {
                        "Changes command mode from CONFIG to EXEC.  "
                        "Unless 'noinit' is called, this command is "
                        "called automatically at the end of startup.",
                        "Changes command mode from CONFIG to EXEC.  "
                        "Unless 'noinit' is called, this command is "
                        "called automatically at the end of startup.",
-
+               .usage = ""
        },
        {
                .name = "add_script_search_dir",
                .handler = &handle_add_script_search_dir_command,
                .mode = COMMAND_ANY,
                .help = "dir to search for config files and scripts",
        },
        {
                .name = "add_script_search_dir",
                .handler = &handle_add_script_search_dir_command,
                .mode = COMMAND_ANY,
                .help = "dir to search for config files and scripts",
-
+               .usage = "<directory>"
        },
        COMMAND_REGISTRATION_DONE
 };
        },
        COMMAND_REGISTRATION_DONE
 };
index 6b034665c757540c799706bcc6e1d53d4a441694..7763685db7548e9e4c5c3507d767e33bd6e4db09 100644 (file)
@@ -5534,11 +5534,13 @@ static const struct command_registration target_exec_command_handlers[] = {
                .mode = COMMAND_EXEC,
                .help = "loads active fast load image to current target "
                        "- mainly for profiling purposes",
                .mode = COMMAND_EXEC,
                .help = "loads active fast load image to current target "
                        "- mainly for profiling purposes",
+               .usage = "",
        },
        {
                .name = "profile",
                .handler = handle_profile_command,
                .mode = COMMAND_EXEC,
        },
        {
                .name = "profile",
                .handler = handle_profile_command,
                .mode = COMMAND_EXEC,
+               .usage = "seconds filename",
                .help = "profiling samples the CPU PC",
        },
        /** @todo don't register virt2phys() unless target supports it */
                .help = "profiling samples the CPU PC",
        },
        /** @todo don't register virt2phys() unless target supports it */
@@ -5599,6 +5601,7 @@ static const struct command_registration target_exec_command_handlers[] = {
                .name = "soft_reset_halt",
                .handler = handle_soft_reset_halt_command,
                .mode = COMMAND_EXEC,
                .name = "soft_reset_halt",
                .handler = handle_soft_reset_halt_command,
                .mode = COMMAND_EXEC,
+               .usage = "",
                .help = "halt the target and do a soft reset",
        },
        {
                .help = "halt the target and do a soft reset",
        },
        {
@@ -5655,7 +5658,7 @@ static const struct command_registration target_exec_command_handlers[] = {
                .handler = handle_bp_command,
                .mode = COMMAND_EXEC,
                .help = "list or set hardware or software breakpoint",
                .handler = handle_bp_command,
                .mode = COMMAND_EXEC,
                .help = "list or set hardware or software breakpoint",
-               .usage = "usage: bp <address> [<asid>]<length> ['hw'|'hw_ctx']",
+               .usage = "<address> [<asid>]<length> ['hw'|'hw_ctx']",
        },
        {
                .name = "rbp",
        },
        {
                .name = "rbp",
index a8ec143ef0b67ca9c83a9ec3a88c386087369dcb..7604db8b49908bd80a9e7365247035d3d323d3f4 100644 (file)
@@ -179,6 +179,7 @@ static const struct command_registration trace_command_handlers[] = {
                .name = "trace",
                .mode = COMMAND_EXEC,
                .help = "trace command group",
                .name = "trace",
                .mode = COMMAND_EXEC,
                .help = "trace command group",
+               .usage = "",
                .chain = trace_exec_command_handlers,
        },
        COMMAND_REGISTRATION_DONE
                .chain = trace_exec_command_handlers,
        },
        COMMAND_REGISTRATION_DONE
index b5e4b9003c3ac378af62e6e93aa27a8bbcd7f1a3..3e6722111369d767f9ceb2e32f210c93990acf24 100644 (file)
@@ -336,12 +336,14 @@ static const struct command_registration transport_commands[] = {
                 */
                .mode = COMMAND_ANY,
                .help = "Initialize this session's transport",
                 */
                .mode = COMMAND_ANY,
                .help = "Initialize this session's transport",
+               .usage = ""
        },
        {
                .name = "list",
                .handler = handle_transport_list,
                .mode = COMMAND_ANY,
                .help = "list all built-in transports",
        },
        {
                .name = "list",
                .handler = handle_transport_list,
                .mode = COMMAND_ANY,
                .help = "list all built-in transports",
+               .usage = ""
        },
        {
                .name = "select",
        },
        {
                .name = "select",
@@ -359,6 +361,7 @@ static const struct command_registration transport_group[] = {
                .mode = COMMAND_ANY,
                .help = "Transport command group",
                .chain = transport_commands,
                .mode = COMMAND_ANY,
                .help = "Transport command group",
                .chain = transport_commands,
+               .usage = ""
        },
        COMMAND_REGISTRATION_DONE
 };
        },
        COMMAND_REGISTRATION_DONE
 };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)