]> www.infradead.org Git - users/borneoa/openocd-next.git/commitdiff
target: improve error reporting for `-event` option
authorEvgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Mon, 28 Apr 2025 13:55:35 +0000 (16:55 +0300)
committerAntonio Borneo <borneo.antonio@gmail.com>
Fri, 9 May 2025 12:12:32 +0000 (12:12 +0000)
`target create` calls can get quite long and an indication what is the
option that caused the error can be helpful.

Also, there can be multiple `-event` options for different events,
therefore indicating which one is it is also helpful.

Change-Id: I5ea61437ca9705e790ed8343183883a3fdfebc80
Signed-off-by: Evgeniy Naydanov <evgeniy.naydanov@syntacore.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8861
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
src/target/target.c

index 6d2fc95060e76dce48fe2edaba4e4d32087a9c9f..6653c381c0671420c3ccb974678d8dc9187afa56 100644 (file)
@@ -4926,7 +4926,8 @@ static COMMAND_HELPER(target_configure, struct target *target, unsigned int inde
 
                case TCFG_EVENT:
                        if (index == CMD_ARGC) {
-                               command_print(CMD, "missing event-name");
+                               command_print(CMD, "expecting %s event-name event-body",
+                                               CMD_ARGV[index - 1]);
                                return ERROR_COMMAND_ARGUMENT_INVALID;
                        }
 
@@ -4939,7 +4940,8 @@ static COMMAND_HELPER(target_configure, struct target *target, unsigned int inde
 
                        if (is_configure) {
                                if (index == CMD_ARGC) {
-                                       command_print(CMD, "missing event-body");
+                                       command_print(CMD, "expecting %s %s event-body",
+                                                       CMD_ARGV[index - 2], CMD_ARGV[index - 1]);
                                        return ERROR_COMMAND_ARGUMENT_INVALID;
                                }
                        }