diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2023-08-06 12:38:54 +0200 |
---|---|---|
committer | Evgeniy Naydanov <109669442+en-sc@users.noreply.github.com> | 2024-01-29 13:36:27 +0300 |
commit | a47fae7934da38aede80beca4876f4196c088726 (patch) | |
tree | 7b12a0d8bc13721ea4b530957c87e7a082891923 /src/helper/command.c | |
parent | 350f5c3547a8efea7015816e610f19ea64f1f6f8 (diff) | |
download | riscv-openocd-a47fae7934da38aede80beca4876f4196c088726.zip riscv-openocd-a47fae7934da38aede80beca4876f4196c088726.tar.gz riscv-openocd-a47fae7934da38aede80beca4876f4196c088726.tar.bz2 |
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 <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8057
Tested-by: jenkins
Diffstat (limited to 'src/helper/command.c')
-rw-r--r-- | src/helper/command.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index 57db2ad..a775c73 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); |