|
From: openocd-gerrit <ope...@us...> - 2024-01-13 14:45:04
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via e680841fd276439844ecf340f4005860d6e22582 (commit)
from f857db98bd2a3d97ada208a8137c48c47e9d3a78 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e680841fd276439844ecf340f4005860d6e22582
Author: Antonio Borneo <bor...@gm...>
Date: Sun Aug 6 12:38:54 2023 +0200
helper/command: pass command arguments also as Jim_Obj
Some OpenOCD command gets fragment of TCL scripts as command-line
argument, fragments that will be kept and executed later on.
E.g. the command 'configure' gets the body of an OpenOCD event:
$TARGET configure -event halted {TCL code}
These commands store the argument as a Jim_Obj and pass it to the
jimtcl interpreter when the TCL fragment has to be executed.
Using Jim_Obj as storage is relevant to let the jimtcl interpreter
to recover extra info of the TCL fragment, like the file-name and
the line-number that contain the fragment, that will be printed
out in case of run-time errors.
While converting the commands to COMMAND_HANDLER, we should avoid
storing the argument as C strings otherwise we will loose precious
info in case of run-time errors making challenging the debugging
of such TCL fragments.
Extend the struct command_invocation to contain the array that
points to the Jim_Obj of the command arguments.
This will be used while converting commands to COMMAND_HANDLER.
Change-Id: If37c5f20e9a71349f77ba1571baf1e6778e28aa5
Signed-off-by: Antonio Borneo <bor...@gm...>
Reviewed-on: https://review.openocd.org/c/openocd/+/8057
Tested-by: jenkins
diff --git a/doc/manual/helper.txt b/doc/manual/helper.txt
index d5710ddde..b59fd664f 100644
--- a/doc/manual/helper.txt
+++ b/doc/manual/helper.txt
@@ -79,6 +79,8 @@ command handlers and helpers:
- @c CMD_NAME - invoked command name
- @c CMD_ARGC - the number of command arguments
- @c CMD_ARGV - array of command argument strings
+- @c CMD_JIMTCL_ARGV - array containing the Jim_Obj equivalent of command
+ argument in @c CMD_ARGV.
@section helpercmdregister Command Registration
diff --git a/src/helper/command.c b/src/helper/command.c
index 57db2adc1..a775c730b 100644
--- a/src/helper/command.c
+++ b/src/helper/command.c
@@ -511,6 +511,7 @@ static int exec_command(Jim_Interp *interp, struct command_context *context,
.name = c->name,
.argc = argc - 1,
.argv = words + 1,
+ .jimtcl_argv = argv + 1,
};
cmd.output = Jim_NewEmptyStringObj(context->interp);
diff --git a/src/helper/command.h b/src/helper/command.h
index 42cb9cb7d..dc4507042 100644
--- a/src/helper/command.h
+++ b/src/helper/command.h
@@ -79,6 +79,7 @@ struct command_invocation {
const char *name;
unsigned argc;
const char **argv;
+ Jim_Obj * const *jimtcl_argv;
Jim_Obj *output;
};
@@ -153,6 +154,11 @@ void *jimcmd_privdata(Jim_Cmd *cmd);
* rather than accessing the variable directly. It may be moved.
*/
#define CMD_ARGV (cmd->argv)
+/**
+ * Use this macro to access the jimtcl arguments for the command being
+ * handled, rather than accessing the variable directly. It may be moved.
+ */
+#define CMD_JIMTCL_ARGV (cmd->jimtcl_argv)
/**
* Use this macro to access the name of the command being handled,
* rather than accessing the variable directly. It may be moved.
-----------------------------------------------------------------------
Summary of changes:
doc/manual/helper.txt | 2 ++
src/helper/command.c | 1 +
src/helper/command.h | 6 ++++++
3 files changed, 9 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|