diff options
author | Antonio Borneo <borneo.antonio@gmail.com> | 2020-05-13 01:59:59 +0200 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2021-04-18 15:34:10 +0100 |
commit | e216186fab59d71fdee24af926d1807a1d7fc950 (patch) | |
tree | 73c0495cd397a5144b8836ebc76b449277c5bf39 /src/target | |
parent | aacc26559e4984b649083ac046db2cbcb54e2f70 (diff) | |
download | riscv-openocd-e216186fab59d71fdee24af926d1807a1d7fc950.zip riscv-openocd-e216186fab59d71fdee24af926d1807a1d7fc950.tar.gz riscv-openocd-e216186fab59d71fdee24af926d1807a1d7fc950.tar.bz2 |
helper/command: register full-name commands in jim
While still keeping the tree of struct command, stop registering
commands in jim by the root "word" only.
Register the full-name of the command and pass as private data the
struct command of the command itself.
Still use the tree of struct command to un-register the commands.
Some "native" commands (.jim_handler) share the same handler, then
the handler checks the command name to run the right code.
Now argv[0] returns the full-name of the command, so check the
name by looking in the struct command passed as private data.
Change-Id: I5623c61cceee8a75f5d5a551ef3fbf5a303af6be
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5671
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Diffstat (limited to 'src/target')
-rw-r--r-- | src/target/aarch64.c | 3 | ||||
-rw-r--r-- | src/target/arm_tpiu_swo.c | 4 | ||||
-rw-r--r-- | src/target/target.c | 3 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/target/aarch64.c b/src/target/aarch64.c index 46ed49f..4ba92c8 100644 --- a/src/target/aarch64.c +++ b/src/target/aarch64.c @@ -2966,6 +2966,7 @@ COMMAND_HANDLER(aarch64_mask_interrupts_command) static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { + struct command *c = jim_to_command(interp); struct command_context *context; struct target *target; struct arm *arm; @@ -2973,7 +2974,7 @@ static int jim_mcrmrc(Jim_Interp *interp, int argc, Jim_Obj * const *argv) bool is_mcr = false; int arg_cnt = 0; - if (Jim_CompareStringImmediate(interp, argv[0], "mcr")) { + if (!strcmp(c->name, "mcr")) { is_mcr = true; arg_cnt = 7; } else { diff --git a/src/target/arm_tpiu_swo.c b/src/target/arm_tpiu_swo.c index 186ce5d..f935086 100644 --- a/src/target/arm_tpiu_swo.c +++ b/src/target/arm_tpiu_swo.c @@ -550,16 +550,16 @@ err_no_params: static int jim_arm_tpiu_swo_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { + struct command *c = jim_to_command(interp); Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1); - goi.isconfigure = !strcmp(Jim_GetString(argv[0], NULL), "configure"); + goi.isconfigure = !strcmp(c->name, "configure"); if (goi.argc < 1) { Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv, "missing: -option ..."); return JIM_ERR; } - struct command *c = jim_to_command(interp); struct arm_tpiu_swo_object *obj = c->jim_handler_data; return arm_tpiu_swo_configure(&goi, obj); } diff --git a/src/target/target.c b/src/target/target.c index fa033d3..e9d6770 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5197,10 +5197,11 @@ no_params: static int jim_target_configure(Jim_Interp *interp, int argc, Jim_Obj * const *argv) { + struct command *c = jim_to_command(interp); Jim_GetOptInfo goi; Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1); - goi.isconfigure = !strcmp(Jim_GetString(argv[0], NULL), "configure"); + goi.isconfigure = !strcmp(c->name, "configure"); if (goi.argc < 1) { Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv, "missing: -option ..."); |