helper/command: pass command arguments also as Jim_Obj 57/8057/4
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 6 Aug 2023 10:38:54 +0000 (12:38 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 13 Jan 2024 14:44:32 +0000 (14:44 +0000)
commite680841fd276439844ecf340f4005860d6e22582
treed2c4679d8098b63d0b90bb12d041d8c251c30699
parentf857db98bd2a3d97ada208a8137c48c47e9d3a78
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
doc/manual/helper.txt
src/helper/command.c
src/helper/command.h

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)