aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias K <kesmtp@freenet.de>2011-12-24 15:26:12 +0100
committerSpencer Oliver <spen@spen-soft.co.uk>2012-01-04 17:13:03 +0000
commit54d6330b78f46678e78d1ffb265c65fcc8991e83 (patch)
treea35fe89ec39967d73d93edc6f9b2634fb1d3be41
parent59cd1c892da41a2fa83524c57a5c38ec33b0190b (diff)
downloadriscv-openocd-54d6330b78f46678e78d1ffb265c65fcc8991e83.zip
riscv-openocd-54d6330b78f46678e78d1ffb265c65fcc8991e83.tar.gz
riscv-openocd-54d6330b78f46678e78d1ffb265c65fcc8991e83.tar.bz2
command: print BUG warning when usage is missing
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>
-rw-r--r--src/helper/command.c16
-rw-r--r--src/openocd.c5
-rw-r--r--src/target/target.c5
-rw-r--r--src/target/trace.c1
-rw-r--r--src/transport/transport.c3
5 files changed, 27 insertions, 3 deletions
diff --git a/src/helper/command.c b/src/helper/command.c
index 552031d..65e538b 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -323,6 +323,22 @@ static struct command *command_new(struct command_context *cmd_ctx,
{
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;
diff --git a/src/openocd.c b/src/openocd.c
index 3f0e142..60cbf23 100644
--- a/src/openocd.c
+++ b/src/openocd.c
@@ -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.",
+ .usage = ""
},
{
.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.",
-
+ .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",
-
+ .usage = "<directory>"
},
COMMAND_REGISTRATION_DONE
};
diff --git a/src/target/target.c b/src/target/target.c
index 6b03466..7763685 100644
--- a/src/target/target.c
+++ b/src/target/target.c
@@ -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",
+ .usage = "",
},
{
.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 */
@@ -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,
+ .usage = "",
.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",
- .usage = "usage: bp <address> [<asid>]<length> ['hw'|'hw_ctx']",
+ .usage = "<address> [<asid>]<length> ['hw'|'hw_ctx']",
},
{
.name = "rbp",
diff --git a/src/target/trace.c b/src/target/trace.c
index a8ec143..7604db8 100644
--- a/src/target/trace.c
+++ b/src/target/trace.c
@@ -179,6 +179,7 @@ static const struct command_registration trace_command_handlers[] = {
.name = "trace",
.mode = COMMAND_EXEC,
.help = "trace command group",
+ .usage = "",
.chain = trace_exec_command_handlers,
},
COMMAND_REGISTRATION_DONE
diff --git a/src/transport/transport.c b/src/transport/transport.c
index b5e4b90..3e67221 100644
--- a/src/transport/transport.c
+++ b/src/transport/transport.c
@@ -336,12 +336,14 @@ static const struct command_registration transport_commands[] = {
*/
.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",
+ .usage = ""
},
{
.name = "select",
@@ -359,6 +361,7 @@ static const struct command_registration transport_group[] = {
.mode = COMMAND_ANY,
.help = "Transport command group",
.chain = transport_commands,
+ .usage = ""
},
COMMAND_REGISTRATION_DONE
};