OpenOCD
command.h File Reference
Include dependency graph for command.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  command
 
struct  command_context
 
struct  command_invocation
 When run_command is called, a new instance will be created on the stack, filled with the proper values, and passed by reference to the required COMMAND_HANDLER routine. More...
 
struct  command_registration
 

Macros

#define __COMMAND_HANDLER(name, extra ...)    int name(struct command_invocation *cmd, ## extra)
 Command handlers may be defined with more parameters than the base set provided by command.c. More...
 
#define CALL_COMMAND_HANDLER(name, extra ...)    name(cmd, ## extra)
 Use this to macro to call a command helper (or a nested handler). More...
 
#define CMD   (cmd)
 Use this macro to access the command being handled, rather than accessing the variable directly. More...
 
#define CMD_ARGC   (cmd->argc)
 Use this macro to access the number of arguments for the command being handled, rather than accessing the variable directly. More...
 
#define CMD_ARGV   (cmd->argv)
 Use this macro to access the arguments for the command being handled, rather than accessing the variable directly. More...
 
#define CMD_CTX   (cmd->ctx)
 Use this macro to access the context of the command being handled, rather than accessing the variable directly. More...
 
#define CMD_CURRENT   (cmd->current)
 Use this macro to access the current command being handled, rather than accessing the variable directly. More...
 
#define CMD_DATA   (CMD_CURRENT->jim_handler_data)
 Use this macro to access the invoked command handler's data pointer, rather than accessing the variable directly. More...
 
#define CMD_JIMTCL_ARGV   (cmd->jimtcl_argv)
 Use this macro to access the jimtcl arguments for the command being handled, rather than accessing the variable directly. More...
 
#define CMD_NAME   (cmd->name)
 Use this macro to access the name of the command being handled, rather than accessing the variable directly. More...
 
#define COMMAND_HANDLER(name)    static __COMMAND_HANDLER(name)
 Always use this macro to define new command handler functions. More...
 
#define COMMAND_HELPER(name, extra ...)   __COMMAND_HANDLER(name, extra)
 Similar to COMMAND_HANDLER, except some parameters are expected. More...
 
#define COMMAND_PARSE_ADDITIONAL_NUMBER(type, argn, out, name_str)
 parses the command argument at position argn into out as a type, or prints a command error referring to name_str and passes the error code to the caller. More...
 
#define COMMAND_PARSE_ADDRESS(in, out)    COMMAND_PARSE_NUMBER(target_addr, in, out)
 
#define COMMAND_PARSE_BOOL(in, out, on, off)
 Parse the string as a binary parameter, storing the boolean value in out. More...
 
#define COMMAND_PARSE_ENABLE(in, out)    COMMAND_PARSE_BOOL(in, out, "enable", "disable")
 parses an enable/disable command argument More...
 
#define COMMAND_PARSE_NUMBER(type, in, out)
 parses the string in into out as a type, or prints a command error and passes the error code to the caller. More...
 
#define COMMAND_PARSE_ON_OFF(in, out)    COMMAND_PARSE_BOOL(in, out, "on", "off")
 parses an on/off command argument More...
 
#define COMMAND_PARSE_OPTIONAL_NUMBER(type, argn, out)
 parses the command argument at position argn into out as a type if the argument argn does not start with '-'. More...
 
#define COMMAND_REGISTRATION_DONE   { .name = NULL, .chain = NULL }
 Use this as the last entry in an array of command_registration records. More...
 
#define DECLARE_PARSE_WRAPPER(name, type)    int parse ## name(const char *str, type * ul)
 
#define ERROR_COMMAND_ARGUMENT_INVALID   (-603)
 
#define ERROR_COMMAND_ARGUMENT_OVERFLOW   (-604)
 
#define ERROR_COMMAND_ARGUMENT_UNDERFLOW   (-605)
 
#define ERROR_COMMAND_CLOSE_CONNECTION   (-600)
 
#define ERROR_COMMAND_NOTFOUND   (-602)
 
#define ERROR_COMMAND_SYNTAX_ERROR   (-601)
 
#define PRINTF_ATTRIBUTE_FORMAT   printf
 

Typedefs

typedef int(* command_output_handler_t) (struct command_context *context, const char *line)
 The type signature for command context's output handler. More...
 

Enumerations

enum  command_mode { COMMAND_EXEC , COMMAND_CONFIG , COMMAND_ANY , COMMAND_UNKNOWN = -1 }
 OpenOCD command mode is COMMAND_CONFIG at start, then switches to COMMAND_EXEC during the execution of command 'init'. More...
 

Functions

typedef __COMMAND_HANDLER ((*command_handler_t))
 The type signature for command handling functions. More...
 
int __register_commands (struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data, struct target *override_target)
 
int command_context_mode (struct command_context *context, enum command_mode mode)
 
void command_done (struct command_context *context)
 Frees the resources associated with a command context. More...
 
void command_exit (struct command_context *context)
 Shutdown a command context. More...
 
 COMMAND_HELPER (handle_command_parse_bool, bool *out, const char *label)
 
struct command_contextcommand_init (const char *startup_tcl, Jim_Interp *interp)
 Creates a new command context using the startup TCL provided and the existing Jim interpreter, if any. More...
 
int void command_output_text (struct command_context *context, const char *data)
 
int command_parse_bool_arg (const char *in, bool *out)
 
void command_print (struct command_invocation *cmd, const char *format,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
 
void void command_print_sameline (struct command_invocation *cmd, const char *format,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
 
void void int command_run_line (struct command_context *context, char *line)
 
int command_run_linef (struct command_context *context, const char *format,...) __attribute__((format(PRINTF_ATTRIBUTE_FORMAT
 
void command_set_output_handler (struct command_context *context, command_output_handler_t output_handler, void *priv)
 
struct command_contextcopy_command_context (struct command_context *cmd_ctx)
 Creates a copy of an existing command context. More...
 
struct command_contextcurrent_command_context (Jim_Interp *interp)
 
 DECLARE_PARSE_WRAPPER (_int, int)
 
 DECLARE_PARSE_WRAPPER (_s16, int16_t)
 
 DECLARE_PARSE_WRAPPER (_s32, int32_t)
 
 DECLARE_PARSE_WRAPPER (_s64, int64_t)
 
 DECLARE_PARSE_WRAPPER (_s8, int8_t)
 
 DECLARE_PARSE_WRAPPER (_target_addr, target_addr_t)
 
 DECLARE_PARSE_WRAPPER (_u16, uint16_t)
 
 DECLARE_PARSE_WRAPPER (_u32, uint32_t)
 
 DECLARE_PARSE_WRAPPER (_u64, uint64_t)
 
 DECLARE_PARSE_WRAPPER (_u8, uint8_t)
 
 DECLARE_PARSE_WRAPPER (_uint, unsigned)
 
int help_del_all_commands (struct command_context *cmd_ctx)
 Unregisters the help for all commands. More...
 
static struct commandjim_to_command (Jim_Interp *interp)
 
bool jimcmd_is_oocd_command (Jim_Cmd *cmd)
 Return true if the command cmd is registered by OpenOCD. More...
 
void * jimcmd_privdata (Jim_Cmd *cmd)
 Return the pointer to the command's private data specified during the registration of command cmd . More...
 
int parse_llong (const char *str, long long *ul)
 
int parse_long (const char *str, long *ul)
 
int parse_ullong (const char *str, unsigned long long *ul)
 
int parse_ulong (const char *str, unsigned long *ul)
 
void process_jim_events (struct command_context *cmd_ctx)
 
static int register_commands (struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds)
 Register one or more commands in the specified context, as children of parent (or top-level commends, if NULL). More...
 
static int register_commands_override_target (struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, struct target *target)
 Register one or more commands, as register_commands(), plus specify that command should override the current target. More...
 
static int register_commands_with_data (struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data)
 Register one or more commands, as register_commands(), plus specify a pointer to command private data that would be accessible through the macro CMD_DATA. More...
 
int unregister_all_commands (struct command_context *cmd_ctx, const char *cmd_prefix)
 Unregisters all commands from the specified context. More...
 

Macro Definition Documentation

◆ __COMMAND_HANDLER

#define __COMMAND_HANDLER (   name,
  extra ... 
)     int name(struct command_invocation *cmd, ## extra)

Command handlers may be defined with more parameters than the base set provided by command.c.

This macro uses C99 magic to allow defining all such derivative types using this macro.

Definition at line 102 of file command.h.

◆ CALL_COMMAND_HANDLER

#define CALL_COMMAND_HANDLER (   name,
  extra ... 
)     name(cmd, ## extra)

Use this to macro to call a command helper (or a nested handler).

It provides command handler authors protection against reordering or removal of unused parameters.

Note: This macro uses lexical capture to provide some arguments. As a result, this macro should be used only within functions defined by the COMMAND_HANDLER or COMMAND_HELPER macros. Those macros provide the expected lexical context captured by this macro. Furthermore, it should be used only from the top-level of handler or helper function, or care must be taken to avoid redefining the same variables in intervening scope(s) by accident.

Definition at line 118 of file command.h.

◆ CMD

#define CMD   (cmd)

Use this macro to access the command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 141 of file command.h.

◆ CMD_ARGC

#define CMD_ARGC   (cmd->argc)

Use this macro to access the number of arguments for the command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 151 of file command.h.

◆ CMD_ARGV

#define CMD_ARGV   (cmd->argv)

Use this macro to access the arguments for the command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 156 of file command.h.

◆ CMD_CTX

#define CMD_CTX   (cmd->ctx)

Use this macro to access the context of the command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 146 of file command.h.

◆ CMD_CURRENT

#define CMD_CURRENT   (cmd->current)

Use this macro to access the current command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 171 of file command.h.

◆ CMD_DATA

#define CMD_DATA   (CMD_CURRENT->jim_handler_data)

Use this macro to access the invoked command handler's data pointer, rather than accessing the variable directly.

It may be moved.

Definition at line 176 of file command.h.

◆ CMD_JIMTCL_ARGV

#define CMD_JIMTCL_ARGV   (cmd->jimtcl_argv)

Use this macro to access the jimtcl arguments for the command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 161 of file command.h.

◆ CMD_NAME

#define CMD_NAME   (cmd->name)

Use this macro to access the name of the command being handled, rather than accessing the variable directly.

It may be moved.

Definition at line 166 of file command.h.

◆ COMMAND_HANDLER

#define COMMAND_HANDLER (   name)     static __COMMAND_HANDLER(name)

Always use this macro to define new command handler functions.

It ensures the parameters are ordered, typed, and named properly, so they be can be used by other macros (e.g. COMMAND_PARSE_NUMBER). All command handler functions must be defined as static in scope.

Definition at line 127 of file command.h.

◆ COMMAND_HELPER

#define COMMAND_HELPER (   name,
  extra ... 
)    __COMMAND_HANDLER(name, extra)

Similar to COMMAND_HANDLER, except some parameters are expected.

A helper is globally-scoped because it may be shared between several source files (e.g. the s3c24xx device command helper).

Definition at line 135 of file command.h.

◆ COMMAND_PARSE_ADDITIONAL_NUMBER

#define COMMAND_PARSE_ADDITIONAL_NUMBER (   type,
  argn,
  out,
  name_str 
)
Value:
do { \
if (argn+1 >= CMD_ARGC || CMD_ARGV[argn+1][0] == '-') { \
command_print(CMD, "no " name_str " given"); \
return ERROR_FAIL; \
} \
++argn; \
COMMAND_PARSE_NUMBER(type, CMD_ARGV[argn], out); \
} while (0)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
uint8_t type
Definition: esp_usb_jtag.c:0
#define ERROR_FAIL
Definition: log.h:170

parses the command argument at position argn into out as a type, or prints a command error referring to name_str and passes the error code to the caller.

argn will be incremented if no error occurred. Otherwise the calling function will return the error code produced by the parsing function.

This function may cause the calling function to return immediately, so it should be used carefully to avoid leaking resources. In most situations, parsing should be completed in full before proceeding to allocate resources, and this strategy will most prevents leaks.

Definition at line 467 of file command.h.

◆ COMMAND_PARSE_ADDRESS

#define COMMAND_PARSE_ADDRESS (   in,
  out 
)     COMMAND_PARSE_NUMBER(target_addr, in, out)

Definition at line 452 of file command.h.

◆ COMMAND_PARSE_BOOL

#define COMMAND_PARSE_BOOL (   in,
  out,
  on,
  off 
)
Value:
do { \
bool value; \
int retval_macro_tmp = command_parse_bool_arg(in, &value); \
if (retval_macro_tmp != ERROR_OK) { \
command_print(CMD, stringify(out) \
" option value ('%s') is not valid", in); \
command_print(CMD, " choices are '%s' or '%s'", \
on, off); \
return retval_macro_tmp; \
} \
out = value; \
} while (0)
int command_parse_bool_arg(const char *in, bool *out)
Definition: command.c:1348
#define ERROR_OK
Definition: log.h:164
#define stringify(s)
turns a macro argument into a string constant
Definition: types.h:46

Parse the string as a binary parameter, storing the boolean value in out.

The strings on and off are used to match different strings for true and false options (e.g. "on" and "off" or "enable" and "disable").

Definition at line 503 of file command.h.

◆ COMMAND_PARSE_ENABLE

#define COMMAND_PARSE_ENABLE (   in,
  out 
)     COMMAND_PARSE_BOOL(in, out, "enable", "disable")

parses an enable/disable command argument

Definition at line 524 of file command.h.

◆ COMMAND_PARSE_NUMBER

#define COMMAND_PARSE_NUMBER (   type,
  in,
  out 
)
Value:
do { \
int retval_macro_tmp = parse_ ## type(in, &(out)); \
if (retval_macro_tmp != ERROR_OK) { \
command_print(CMD, stringify(out) \
" option value ('%s') is not valid", in); \
return retval_macro_tmp; \
} \
} while (0)

parses the string in into out as a type, or prints a command error and passes the error code to the caller.

If an error does occur, the calling function will return the error code produced by the parsing function (one of ERROR_COMMAND_ARGUMENT_*).

This function may cause the calling function to return immediately, so it should be used carefully to avoid leaking resources. In most situations, parsing should be completed in full before proceeding to allocate resources, and this strategy will most prevents leaks.

Definition at line 442 of file command.h.

◆ COMMAND_PARSE_ON_OFF

#define COMMAND_PARSE_ON_OFF (   in,
  out 
)     COMMAND_PARSE_BOOL(in, out, "on", "off")

parses an on/off command argument

Definition at line 521 of file command.h.

◆ COMMAND_PARSE_OPTIONAL_NUMBER

#define COMMAND_PARSE_OPTIONAL_NUMBER (   type,
  argn,
  out 
)
Value:
do { \
if (argn+1 < CMD_ARGC && CMD_ARGV[argn+1][0] != '-') { \
++argn; \
COMMAND_PARSE_NUMBER(type, CMD_ARGV[argn], out); \
} \
} while (0)

parses the command argument at position argn into out as a type if the argument argn does not start with '-'.

and passes the error code to the caller. argn will be incremented if no error occurred. Otherwise the calling function will return the error code produced by the parsing function.

This function may cause the calling function to return immediately, so it should be used carefully to avoid leaking resources. In most situations, parsing should be completed in full before proceeding to allocate resources, and this strategy will most prevents leaks.

Definition at line 489 of file command.h.

◆ COMMAND_REGISTRATION_DONE

#define COMMAND_REGISTRATION_DONE   { .name = NULL, .chain = NULL }

Use this as the last entry in an array of command_registration records.

Definition at line 253 of file command.h.

◆ DECLARE_PARSE_WRAPPER

#define DECLARE_PARSE_WRAPPER (   name,
  type 
)     int parse ## name(const char *str, type * ul)

Definition at line 414 of file command.h.

◆ ERROR_COMMAND_ARGUMENT_INVALID

#define ERROR_COMMAND_ARGUMENT_INVALID   (-603)

Definition at line 404 of file command.h.

◆ ERROR_COMMAND_ARGUMENT_OVERFLOW

#define ERROR_COMMAND_ARGUMENT_OVERFLOW   (-604)

Definition at line 405 of file command.h.

◆ ERROR_COMMAND_ARGUMENT_UNDERFLOW

#define ERROR_COMMAND_ARGUMENT_UNDERFLOW   (-605)

Definition at line 406 of file command.h.

◆ ERROR_COMMAND_CLOSE_CONNECTION

#define ERROR_COMMAND_CLOSE_CONNECTION   (-600)

Definition at line 401 of file command.h.

◆ ERROR_COMMAND_NOTFOUND

#define ERROR_COMMAND_NOTFOUND   (-602)

Definition at line 403 of file command.h.

◆ ERROR_COMMAND_SYNTAX_ERROR

#define ERROR_COMMAND_SYNTAX_ERROR   (-601)

Definition at line 402 of file command.h.

◆ PRINTF_ATTRIBUTE_FORMAT

#define PRINTF_ATTRIBUTE_FORMAT   printf

Definition at line 27 of file command.h.

Typedef Documentation

◆ command_output_handler_t

typedef int(* command_output_handler_t) (struct command_context *context, const char *line)

The type signature for command context's output handler.

Definition at line 49 of file command.h.

Enumeration Type Documentation

◆ command_mode

OpenOCD command mode is COMMAND_CONFIG at start, then switches to COMMAND_EXEC during the execution of command 'init'.

The field 'mode' in struct command_registration specifies in which command mode the command can be executed:

  • during COMMAND_CONFIG only,
  • during COMMAND_EXEC only,
  • in both modes (COMMAND_ANY).
Enumerator
COMMAND_EXEC 
COMMAND_CONFIG 
COMMAND_ANY 
COMMAND_UNKNOWN 

Definition at line 39 of file command.h.

Function Documentation

◆ __COMMAND_HANDLER()

typedef __COMMAND_HANDLER ( command_handler_t)

The type signature for command handling functions.

They are usually registered as part of command_registration, providing a high-level means for executing a command.

If the command fails, it MUST return a value != ERROR_OK (many commands break this rule, patches welcome!)

This is especially important for commands such as writing to flash or verifying memory. The reason is that those commands can be used by programs to determine if the operation succeeded or not. If the operation failed, then a program can try an alternative approach.

Returning ERROR_COMMAND_SYNTAX_ERROR will have the effect of printing out the syntax of the command.

◆ __register_commands()

int __register_commands ( struct command_context cmd_ctx,
const char *  cmd_prefix,
const struct command_registration cmds,
void *  data,
struct target override_target 
)

◆ command_context_mode()

int command_context_mode ( struct command_context context,
enum command_mode  mode 
)

Definition at line 1254 of file command.c.

References ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, command_context::mode, and mode.

Referenced by COMMAND_HANDLER(), and openocd_main().

◆ command_done()

void command_done ( struct command_context context)

Frees the resources associated with a command context.

The commands are not removed, so unregister_all_commands() must be called first.

Parameters
contextThe command_context that will be destroyed.

Definition at line 644 of file command.c.

Referenced by add_connection(), command_exit(), remove_connection(), and setup_command_handler().

◆ command_exit()

void command_exit ( struct command_context context)

Shutdown a command context.

Free the command context and the associated Jim interpreter.

Parameters
contextThe command_context that will be destroyed.

Definition at line 1244 of file command.c.

References command_done(), command_context::help_list, and command_context::interp.

Referenced by openocd_main().

◆ COMMAND_HELPER()

COMMAND_HELPER ( handle_command_parse_bool  ,
bool *  out,
const char *  label 
)

◆ command_init()

struct command_context* command_init ( const char *  startup_tcl,
Jim_Interp *  interp 
)

Creates a new command context using the startup TCL provided and the existing Jim interpreter, if any.

If interp == NULL, then command_init creates a command interpreter.

Definition at line 1209 of file command.c.

References command_builtin_handlers, COMMAND_EXEC, command_context::help_list, INIT_LIST_HEAD(), command_context::interp, LOG_ERROR, LOG_USER_N, command_context::mode, NULL, and register_commands().

Referenced by setup_command_handler().

◆ command_output_text()

int void command_output_text ( struct command_context context,
const char *  data 
)

Definition at line 414 of file command.c.

References command_context::output_handler.

Referenced by command_run_line(), target_asciimsg(), and target_hexmsg().

◆ command_parse_bool_arg()

int command_parse_bool_arg ( const char *  in,
bool *  out 
)

Definition at line 1348 of file command.c.

References command_parse_bool(), ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.

Referenced by COMMAND_HELPER().

◆ command_print()

void command_print ( struct command_invocation cmd,
const char *  format,
  ... 
)

◆ command_print_sameline()

void void command_print_sameline ( struct command_invocation cmd,
const char *  format,
  ... 
)

◆ command_run_line()

◆ command_run_linef()

int command_run_linef ( struct command_context context,
const char *  format,
  ... 
)

◆ command_set_output_handler()

void command_set_output_handler ( struct command_context context,
command_output_handler_t  output_handler,
void *  priv 
)

◆ copy_command_context()

struct command_context* copy_command_context ( struct command_context cmd_ctx)

Creates a copy of an existing command context.

This does not create a deep copy of the command list, so modifications in one context will affect all shared contexts. The caller must track reference counting and ensure the commands are freed before destroying the last instance.

Parameters
cmd_ctxThe command_context that will be copied.
Returns
A new command_context with the same state as the original.

Definition at line 635 of file command.c.

Referenced by add_connection().

◆ current_command_context()

◆ DECLARE_PARSE_WRAPPER() [1/11]

DECLARE_PARSE_WRAPPER ( _int  ,
int   
)

◆ DECLARE_PARSE_WRAPPER() [2/11]

DECLARE_PARSE_WRAPPER ( _s16  ,
int16_t   
)

◆ DECLARE_PARSE_WRAPPER() [3/11]

DECLARE_PARSE_WRAPPER ( _s32  ,
int32_t   
)

◆ DECLARE_PARSE_WRAPPER() [4/11]

DECLARE_PARSE_WRAPPER ( _s64  ,
int64_t   
)

◆ DECLARE_PARSE_WRAPPER() [5/11]

DECLARE_PARSE_WRAPPER ( _s8  ,
int8_t   
)

◆ DECLARE_PARSE_WRAPPER() [6/11]

DECLARE_PARSE_WRAPPER ( _target_addr  ,
target_addr_t   
)

◆ DECLARE_PARSE_WRAPPER() [7/11]

DECLARE_PARSE_WRAPPER ( _u16  ,
uint16_t   
)

◆ DECLARE_PARSE_WRAPPER() [8/11]

DECLARE_PARSE_WRAPPER ( _u32  ,
uint32_t   
)

◆ DECLARE_PARSE_WRAPPER() [9/11]

DECLARE_PARSE_WRAPPER ( _u64  ,
uint64_t   
)

◆ DECLARE_PARSE_WRAPPER() [10/11]

DECLARE_PARSE_WRAPPER ( _u8  ,
uint8_t   
)

◆ DECLARE_PARSE_WRAPPER() [11/11]

DECLARE_PARSE_WRAPPER ( _uint  ,
unsigned   
)

◆ help_del_all_commands()

int help_del_all_commands ( struct command_context cmd_ctx)

Unregisters the help for all commands.

Used at exit to remove the help added through the commands 'add_help_text' and 'add_usage_text'.

Parameters
cmd_ctxThe context that will be cleared of registered helps.
Returns
ERROR_OK on success, or an error code.

Definition at line 988 of file command.c.

References help_entry::cmd_name, ERROR_OK, help_entry::help, command_context::help_list, help_entry::lh, lh(), list_del(), list_for_each_entry_safe, and help_entry::usage.

Referenced by openocd_main().

◆ jim_to_command()

static struct command* jim_to_command ( Jim_Interp *  interp)
inlinestatic

◆ jimcmd_is_oocd_command()

bool jimcmd_is_oocd_command ( Jim_Cmd *  cmd)

Return true if the command cmd is registered by OpenOCD.

Definition at line 51 of file command.c.

References cmd, and jim_command_dispatch().

Referenced by command_find_from_name(), jim_command_mode(), and telnet_auto_complete().

◆ jimcmd_privdata()

void* jimcmd_privdata ( Jim_Cmd *  cmd)

Return the pointer to the command's private data specified during the registration of command cmd .

Definition at line 56 of file command.c.

References cmd, and NULL.

Referenced by command_find_from_name(), jim_command_mode(), and telnet_auto_complete().

◆ parse_llong()

int parse_llong ( const char *  str,
long long *  ul 
)

◆ parse_long()

int parse_long ( const char *  str,
long *  ul 
)

Referenced by add_service(), and gdb_target_add_one().

◆ parse_ullong()

int parse_ullong ( const char *  str,
unsigned long long *  ul 
)

◆ parse_ulong()

int parse_ulong ( const char *  str,
unsigned long *  ul 
)

◆ process_jim_events()

void process_jim_events ( struct command_context cmd_ctx)

Definition at line 1263 of file command.c.

References command_context::interp.

Referenced by server_loop().

◆ register_commands()

static int register_commands ( struct command_context cmd_ctx,
const char *  cmd_prefix,
const struct command_registration cmds 
)
inlinestatic

Register one or more commands in the specified context, as children of parent (or top-level commends, if NULL).

In a registration's record contains a non-NULL chain member and name is NULL, the commands on the chain will be registered in the same context. Otherwise, the chained commands are added as children of the command.

Parameters
cmd_ctxThe command_context in which to register the command.
cmd_prefixRegister this command as a child of this, or NULL to register a top-level command.
cmdsPointer to an array of command_registration records that contains the desired command parameters. The last record must have NULL for all fields.
Returns
ERROR_OK on success; ERROR_FAIL if any registration fails.

Definition at line 274 of file command.h.

References __register_commands(), and NULL.

Referenced by adapter_register_commands(), COMMAND_HANDLER(), COMMAND_HELPER(), command_init(), dapdirect_jtag_select(), dapdirect_swd_select(), etm_register_user_commands(), FLASH_BANK_COMMAND_HANDLER(), flash_init_drivers(), flash_register_commands(), gdb_register_commands(), hl_jtag_transport_select(), ipdbg_register_commands(), jsp_register_commands(), jtag_register_commands(), log_register_commands(), nand_init(), nand_register_commands(), openocd_register_commands(), pld_init(), pld_register_commands(), rtt_server_register_commands(), server_register_commands(), svf_register_commands(), swd_select(), swim_transport_select(), target_create(), target_register_commands(), target_register_user_commands(), target_request_register_commands(), tcl_register_commands(), telnet_register_commands(), trace_register_commands(), transport_register_commands(), util_init(), and xsvf_register_commands().

◆ register_commands_override_target()

static int register_commands_override_target ( struct command_context cmd_ctx,
const char *  cmd_prefix,
const struct command_registration cmds,
struct target target 
)
inlinestatic

Register one or more commands, as register_commands(), plus specify that command should override the current target.

Parameters
cmd_ctxThe command_context in which to register the command.
cmd_prefixRegister this command as a child of this, or NULL to register a top-level command.
cmdsPointer to an array of command_registration records that contains the desired command parameters. The last record must have NULL for all fields.
targetThe target that has to override current target.
Returns
ERROR_OK on success; ERROR_FAIL if any registration fails.

Definition at line 293 of file command.h.

References __register_commands(), and NULL.

Referenced by target_create().

◆ register_commands_with_data()

static int register_commands_with_data ( struct command_context cmd_ctx,
const char *  cmd_prefix,
const struct command_registration cmds,
void *  data 
)
inlinestatic

Register one or more commands, as register_commands(), plus specify a pointer to command private data that would be accessible through the macro CMD_DATA.

The private data will not be freed when command is unregistered.

Parameters
cmd_ctxThe command_context in which to register the command.
cmd_prefixRegister this command as a child of this, or NULL to register a top-level command.
cmdsPointer to an array of command_registration records that contains the desired command parameters. The last record must have NULL for all fields.
dataThe command private data.
Returns
ERROR_OK on success; ERROR_FAIL if any registration fails.

Definition at line 315 of file command.h.

References __register_commands(), and NULL.

Referenced by arm_tpiu_swo_create(), cti_create(), dap_create(), and ipdbg_register_hub_command().

◆ unregister_all_commands()

int unregister_all_commands ( struct command_context cmd_ctx,
const char *  cmd_prefix 
)

Unregisters all commands from the specified context.

Parameters
cmd_ctxThe context that will be cleared of registered commands.
cmd_prefixIf given, only clear commands from under this one command.
Returns
ERROR_OK on success, or an error code.

Definition at line 386 of file command.c.

References ERROR_OK.

Referenced by openocd_main().