server/telnet: fix autocomplete for jimtcl commands

Current autocomplete filters-out some command reported by "info
commands". One of the filter rule concerns the command's private
data.
Every command registered by OpenOCD has its 'struct command' as
private data.

By ignoring commands without private data, we loose several TCL
commands registered by jimtcl, e.g. 'foreach', 'llength'.

By assuming that every command with non-NULL private data has
'struct command' as private data, we risk at best to access
inconsistent data, at worst to trigger a segmentation fault.

Export the already available functions:
- to check if a command has been registered by OpenOCD and
- to get the private data.
While there, rename jimcmd_is_ocd_command() as
jimcmd_is_oocd_command().
Don't filter-out jimtcl commands with no private data.
Check the private data only on OpenOCD commands.

Change-Id: Ib5bf8d2bc5c12440c0cfae438f637c38724a79b7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6282
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
This commit is contained in:
Antonio Borneo
2021-05-27 15:25:43 +02:00
parent 9e7b31479b
commit fad1eaaa42
3 changed files with 26 additions and 19 deletions

View File

@@ -84,6 +84,17 @@ struct command_invocation {
Jim_Obj *output;
};
/**
* Return true if the command @c cmd is registered by OpenOCD.
*/
bool jimcmd_is_oocd_command(Jim_Cmd *cmd);
/**
* Return the pointer to the command's private data specified during the
* registration of command @a cmd .
*/
void *jimcmd_privdata(Jim_Cmd *cmd);
/**
* Command handlers may be defined with more parameters than the base
* set provided by command.c. This macro uses C99 magic to allow