OpenOCD
|
Go to the source code of this file.
Data Structures | |
struct | help_entry |
struct | log_capture_state |
Macros | |
#define | __THIS__FILE__ "command.c" |
#define | DEFINE_PARSE_LONGLONG(name, type, min, max) DEFINE_PARSE_WRAPPER(name, type, min, max, long long, _llong) |
#define | DEFINE_PARSE_NUM_TYPE(name, type, func, min, max) |
#define | DEFINE_PARSE_ULONGLONG(name, type, min, max) DEFINE_PARSE_WRAPPER(name, type, min, max, unsigned long long, _ullong) |
#define | DEFINE_PARSE_WRAPPER(name, type, min, max, functype, funcname) |
#define | HELP_LINE_WIDTH(_n) (int)(76 - (2 * _n)) |
#define | JIM_EMBEDDED |
Functions | |
static | __attribute__ ((format(PRINTF_ATTRIBUTE_FORMAT, 2, 3))) |
int | __register_commands (struct command_context *cmd_ctx, const char *cmd_prefix, const struct command_registration *cmds, void *data, struct target *override_target) |
static char * | alloc_concatenate_strings (int argc, Jim_Obj *const *argv) |
static bool | command_can_run (struct command_context *cmd_ctx, struct command *c, const char *full_name) |
int | command_context_mode (struct command_context *cmd_ctx, enum command_mode mode) |
void | command_done (struct command_context *cmd_ctx) |
Frees the resources associated with a command context. More... | |
void | command_exit (struct command_context *context) |
Shutdown a command context. More... | |
static struct command * | command_find_from_name (Jim_Interp *interp, const char *name) |
Find a openocd command from fullname. More... | |
static void | command_free (struct Jim_Interp *interp, void *priv) |
COMMAND_HANDLER (handle_echo) | |
COMMAND_HANDLER (handle_help_add_command) | |
COMMAND_HANDLER (handle_help_command) | |
COMMAND_HANDLER (handle_sleep_command) | |
static void | command_help_show_indent (unsigned n) |
static void | command_help_show_wrap (const char *str, unsigned n, unsigned n2) |
static | COMMAND_HELPER (command_help_show, struct help_entry *c, bool show_help, const char *cmd_match) |
static | COMMAND_HELPER (command_help_show_list, bool show_help, const char *cmd_match) |
COMMAND_HELPER (handle_command_parse_bool, bool *out, const char *label) | |
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. More... | |
static void | command_log_capture_finish (struct log_capture_state *state) |
static struct log_capture_state * | command_log_capture_start (Jim_Interp *interp) |
static struct command * | command_new (struct command_context *cmd_ctx, const char *full_name, const struct command_registration *cr) |
void | command_output_text (struct command_context *context, const char *data) |
static int | command_parse_bool (const char *in, bool *out, const char *on, const char *off) |
int | command_parse_bool_arg (const char *in, bool *out) |
void | command_print (struct command_invocation *cmd, const char *format,...) |
void | command_print_sameline (struct command_invocation *cmd, const char *format,...) |
static int | command_retval_set (Jim_Interp *interp, int retval) |
int | command_run_line (struct command_context *context, char *line) |
int | command_run_linef (struct command_context *context, const char *format,...) |
void | command_set_output_handler (struct command_context *context, command_output_handler_t output_handler, void *priv) |
struct command_context * | copy_command_context (struct command_context *context) |
Creates a copy of an existing command context. More... | |
struct command_context * | current_command_context (Jim_Interp *interp) |
static int | exec_command (Jim_Interp *interp, struct command_context *cmd_ctx, struct command *c, int argc, Jim_Obj *const *argv) |
static int | help_add_command (struct command_context *cmd_ctx, const char *cmd_name, const char *help_text, const char *usage_text) |
int | help_del_all_commands (struct command_context *cmd_ctx) |
Unregisters the help for all commands. More... | |
static int | help_del_command (struct command_context *cmd_ctx, const char *cmd_name) |
static int | jim_capture (Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
static int | jim_command_dispatch (Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
static int | jim_command_mode (Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
static int | jim_find (Jim_Interp *interp, int argc, Jim_Obj *const *argv) |
bool | jimcmd_is_oocd_command (Jim_Cmd *cmd) |
Return true if the command cmd is registered by OpenOCD. More... | |
static bool | jimcmd_is_proc (Jim_Cmd *cmd) |
void * | jimcmd_privdata (Jim_Cmd *cmd) |
Return the pointer to the command's private data specified during the registration of command cmd . More... | |
void | process_jim_events (struct command_context *cmd_ctx) |
static struct command * | register_command (struct command_context *context, const char *cmd_prefix, const struct command_registration *cr) |
static int | run_command (struct command_context *context, struct command *c, const char **words, unsigned num_words) |
static char ** | script_command_args_alloc (unsigned argc, Jim_Obj *const *argv, unsigned *nwords) |
static void | script_command_args_free (char **words, unsigned nwords) |
static void | script_debug (Jim_Interp *interp, unsigned int argc, Jim_Obj *const *argv) |
static void | tcl_output (void *privData, const char *file, unsigned line, const char *function, const char *string) |
int | unregister_all_commands (struct command_context *context, const char *cmd_prefix) |
Unregisters all commands from the specified context. More... | |
static int | unregister_command (struct command_context *context, const char *cmd_prefix, const char *name) |
Variables | |
static const struct command_registration | command_builtin_handlers [] |
static const struct command_registration | command_subcommand_handlers [] |
struct command_context * | global_cmd_ctx |
#define DEFINE_PARSE_LONGLONG | ( | name, | |
type, | |||
min, | |||
max | |||
) | DEFINE_PARSE_WRAPPER(name, type, min, max, long long, _llong) |
#define DEFINE_PARSE_ULONGLONG | ( | name, | |
type, | |||
min, | |||
max | |||
) | DEFINE_PARSE_WRAPPER(name, type, min, max, unsigned long long, _ullong) |
|
static |
Definition at line 362 of file command.c.
References __THIS__FILE__, alloc_printf(), alloc_vprintf(), command_find_from_name(), ERROR_FAIL, ERROR_OK, help_del_command(), LOG_DEBUG, name, and NULL.
int __register_commands | ( | struct command_context * | cmd_ctx, |
const char * | cmd_prefix, | ||
const struct command_registration * | cmds, | ||
void * | data, | ||
struct target * | override_target | ||
) |
Definition at line 316 of file command.c.
References alloc_printf(), command_registration::chain, ERROR_FAIL, ERROR_OK, command::jim_handler_data, command::jim_override_target, command_registration::name, name, NULL, register_command(), and unregister_command().
Referenced by register_commands(), register_commands_override_target(), and register_commands_with_data().
|
static |
Definition at line 866 of file command.c.
References alloc_printf(), LOG_ERROR, and NULL.
Referenced by jim_command_mode().
|
static |
Definition at line 498 of file command.c.
References COMMAND_ANY, COMMAND_CONFIG, COMMAND_EXEC, LOG_ERROR, command_context::mode, command::mode, and command::name.
Referenced by jim_command_dispatch().
int command_context_mode | ( | struct command_context * | cmd_ctx, |
enum command_mode | mode | ||
) |
Definition at line 1290 of file command.c.
References ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, command_context::mode, and mode.
Referenced by COMMAND_HANDLER(), and openocd_main().
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.
context | The command_context that will be destroyed. |
Definition at line 651 of file command.c.
Referenced by add_connection(), command_exit(), remove_connection(), and setup_command_handler().
void command_exit | ( | struct command_context * | context | ) |
Shutdown a command context.
Free the command context and the associated Jim interpreter.
context | The command_context that will be destroyed. |
Definition at line 1280 of file command.c.
References command_done(), command_context::help_list, and command_context::interp.
Referenced by openocd_main().
|
static |
Find a openocd command from fullname.
Definition at line 209 of file command.c.
References cmd, jimcmd_is_oocd_command(), jimcmd_is_proc(), jimcmd_privdata(), name, and NULL.
Referenced by __attribute__(), and register_command().
|
static |
Definition at line 261 of file command.c.
References command::name, and priv.
Referenced by register_command().
COMMAND_HANDLER | ( | handle_echo | ) |
Definition at line 675 of file command.c.
References CMD_ARGC, CMD_ARGV, ERROR_FAIL, ERROR_OK, LOG_USER, and LOG_USER_N.
COMMAND_HANDLER | ( | handle_help_add_command | ) |
Definition at line 1109 of file command.c.
References CMD_ARGC, CMD_ARGV, CMD_CTX, help_entry::cmd_name, CMD_NAME, ERROR_COMMAND_SYNTAX_ERROR, help_entry::help, help_add_command(), LOG_ERROR, NULL, and help_entry::usage.
COMMAND_HANDLER | ( | handle_help_command | ) |
Definition at line 837 of file command.c.
References alloc_printf(), CALL_COMMAND_HANDLER, CMD_ARGC, CMD_ARGV, CMD_NAME, and LOG_ERROR.
|
static |
Definition at line 738 of file command.c.
References LOG_USER_N.
Referenced by command_help_show_wrap().
|
static |
Definition at line 743 of file command.c.
References command_help_show_indent(), HELP_LINE_WIDTH, and LOG_USER.
Referenced by COMMAND_HELPER().
|
static |
Definition at line 763 of file command.c.
References alloc_printf(), CMD_CTX, help_entry::cmd_name, COMMAND_ANY, COMMAND_CONFIG, COMMAND_EXEC, command_help_show_wrap(), COMMAND_UNKNOWN, ERROR_FAIL, ERROR_OK, help_entry::help, LOG_ERROR, mode, NULL, and help_entry::usage.
|
static |
Definition at line 727 of file command.c.
References CALL_COMMAND_HANDLER, CMD_CTX, ERROR_OK, lh(), and list_for_each_entry.
COMMAND_HELPER | ( | handle_command_parse_bool | , |
bool * | out, | ||
const char * | label | ||
) |
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 1245 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().
|
static |
Definition at line 108 of file command.c.
References length, log_remove_callback(), state, and tcl_output().
Referenced by jim_capture().
|
static |
Definition at line 71 of file command.c.
References log_capture_state::interp, log_add_callback(), LOG_ERROR, NULL, state, and tcl_output().
Referenced by jim_capture().
|
static |
Definition at line 224 of file command.c.
References command::handler, command_registration::handler, command_registration::help, help_add_command(), command::jim_handler, command_registration::jim_handler, LOG_ERROR, command::mode, command_registration::mode, command::name, command_registration::name, NULL, and command_registration::usage.
Referenced by register_command().
void command_output_text | ( | struct command_context * | context, |
const char * | data | ||
) |
Definition at line 444 of file command.c.
References command_context::output_handler.
Referenced by command_run_line(), target_asciimsg(), and target_hexmsg().
|
static |
Definition at line 1372 of file command.c.
References ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.
Referenced by command_parse_bool_arg().
int command_parse_bool_arg | ( | const char * | in, |
bool * | out | ||
) |
Definition at line 1384 of file command.c.
References command_parse_bool(), ERROR_COMMAND_SYNTAX_ERROR, and ERROR_OK.
Referenced by COMMAND_HELPER().
void command_print | ( | struct command_invocation * | cmd, |
const char * | format, | ||
... | |||
) |
Definition at line 473 of file command.c.
References alloc_vprintf(), and cmd.
Referenced by a64_disassemble(), adiv6_dap_read_baseptr(), arm7a_handle_l2x_cache_info_command(), arm920t_verify_pointer(), arm926ejs_verify_pointer(), arm946e_verify_pointer(), arm966e_verify_pointer(), armv4_5_handle_cache_info_command(), armv7a_handle_cache_info_command(), armv8_handle_cache_info_command(), armv8_handle_inner_cache_info_command(), binprint(), COMMAND_HANDLER(), COMMAND_HELPER(), cortex_m_verify_pointer(), dap_devtype_display(), dap_info_ap_header(), dap_info_cs_component(), dap_info_mem_ap_header(), dap_info_rom_table_entry(), esirisc_trace_analyze(), esirisc_trace_analyze_buffer(), esirisc_trace_analyze_full(), esirisc_trace_analyze_memory(), esirisc_trace_analyze_simple(), esirisc_trace_dump(), esirisc_trace_dump_buffer(), esirisc_trace_dump_memory(), esp_semihosting_basedir_command(), etmv1_analyze_trace(), find_target(), handle_bp_command_list(), handle_bp_command_set(), handle_iod_output(), mips32_verify_pointer(), mips_m4k_verify_pointer(), nand_fileio_start(), nand_list_walker(), PLD_DEVICE_COMMAND_HANDLER(), show_config(), show_config_ip_address(), show_config_mac_address(), show_config_target_power(), show_config_usb_address(), target_handle_md_output(), target_process_reset(), xscale_analyze_trace(), xscale_display_instruction(), and xscale_verify_pointer().
void command_print_sameline | ( | struct command_invocation * | cmd, |
const char * | format, | ||
... | |||
) |
Definition at line 450 of file command.c.
References alloc_vprintf(), and cmd.
Referenced by avrf_info(), binprint(), cfi_get_info(), cfi_intel_info(), cfi_spansion_info(), COMMAND_HANDLER(), esirisc_flash_info(), faux_info(), fm4_get_info_command(), get_ambiqmicro_info(), get_at91sam7_info(), get_efm32x_info(), get_info(), get_lpc2000_info(), get_lpcspifi_info(), get_mdr_info(), get_niietcm4_info(), get_psoc4_info(), get_stellaris_info(), get_stm32l4_info(), get_stm32x_info(), get_stmqspi_info(), get_stmsmi_info(), get_str7x_info(), get_tms470_info(), get_w600_info(), kinetis_info(), kinetis_ke_info(), mrvlqspi_get_info(), msp432_info(), nrf5_info(), pic32mx_info(), psoc5lp_eeprom_get_info_command(), psoc5lp_get_info_command(), psoc5lp_nvl_get_info_command(), psoc6_get_info(), sam4_info(), samv_get_info(), sh_qspi_get_info(), sim3x_flash_info(), stm32x_get_info(), virtual_info(), xcf_info(), xmc1xxx_get_info_command(), and xmc4xxx_get_info_command().
|
static |
Definition at line 129 of file command.c.
References ERROR_OK, and log_capture_state::interp.
Referenced by exec_command().
int command_run_line | ( | struct command_context * | context, |
char * | line | ||
) |
Definition at line 554 of file command.c.
References command_output_text(), command_context::current_target_override, ERROR_COMMAND_CLOSE_CONNECTION, ERROR_FAIL, ERROR_OK, command_context::interp, LOG_USER, and NULL.
Referenced by COMMAND_HANDLER(), command_run_linef(), openocd_thread(), parse_config_file(), server_loop(), tcl_input(), and telnet_exec_line().
int command_run_linef | ( | struct command_context * | context, |
const char * | format, | ||
... | |||
) |
Definition at line 620 of file command.c.
References alloc_vprintf(), command_run_line(), and ERROR_FAIL.
Referenced by gdb_restart_inferior(), jim_arm_tpiu_swo_init(), parse_cmdline_args(), register_command(), and run_command().
void command_set_output_handler | ( | struct command_context * | context, |
command_output_handler_t | output_handler, | ||
void * | priv | ||
) |
Definition at line 635 of file command.c.
References command_context::output_handler, command_context::output_handler_priv, and priv.
Referenced by gdb_new_connection(), openocd_main(), and telnet_new_connection().
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.
cmd_ctx | The command_context that will be copied. |
Definition at line 642 of file command.c.
Referenced by add_connection().
struct command_context* current_command_context | ( | Jim_Interp * | interp | ) |
Definition at line 187 of file command.c.
References global_cmd_ctx, and command_context::interp.
Referenced by arm_tpiu_swo_create(), arm_tpiu_swo_handle_event(), cti_create(), dap_create(), jim_aice_arp_init_reset(), jim_arc_add_reg(), jim_arc_add_reg_type_flags(), jim_arc_add_reg_type_struct(), jim_arc_get_aux_reg(), jim_arc_get_core_reg(), jim_arc_get_reg_field(), jim_arc_set_aux_reg(), jim_arm_tpiu_swo_enable(), jim_arm_tpiu_swo_init(), jim_command_dispatch(), jim_command_mode(), jim_jtag_arp_init(), jim_jtag_arp_init_reset(), jim_nds32_bulk_read(), jim_nds32_bulk_write(), jim_nds32_multi_write(), jim_nds32_read_edm_sr(), jim_nds32_write_edm_sr(), jim_target_array2mem(), jim_target_configure(), jim_target_current(), jim_target_current_state(), jim_target_examine(), jim_target_examine_deferred(), jim_target_halt(), jim_target_halt_gdb(), jim_target_invoke_event(), jim_target_mem2array(), jim_target_poll(), jim_target_reset(), jim_target_wait_state(), jim_target_was_examined(), target_configure(), target_create(), target_handle_event(), target_jim_get_reg(), target_jim_read_memory(), target_jim_set_reg(), and target_jim_write_memory().
|
static |
Definition at line 892 of file command.c.
References command_retval_set(), command::jim_handler, run_command(), script_command_args_alloc(), and script_command_args_free().
Referenced by jim_command_dispatch().
|
static |
Definition at line 1056 of file command.c.
References help_entry::cmd_name, ERROR_FAIL, ERROR_OK, help_entry::help, command_context::help_list, help_entry::lh, lh(), list_add(), list_for_each_entry_reverse, LOG_ERROR, and help_entry::usage.
Referenced by COMMAND_HANDLER(), and command_new().
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'.
cmd_ctx | The context that will be cleared of registered helps. |
Definition at line 1024 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().
|
static |
Definition at line 1038 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, and help_entry::usage.
Referenced by __attribute__().
|
static |
Definition at line 692 of file command.c.
References __THIS__FILE__, command_log_capture_finish(), command_log_capture_start(), log_capture_state::interp, jtag_poll_mask(), jtag_poll_unmask(), NULL, and state.
|
static |
Definition at line 909 of file command.c.
References alloc_printf(), cmd, command_can_run(), current_command_context(), command_context::current_target_override, exec_command(), command::handler, command_context::interp, command::jim_handler, command::jim_override_target, jim_to_command(), command::name, NULL, script_debug(), and target_call_timer_callbacks_now().
Referenced by jimcmd_is_oocd_command(), and register_command().
|
static |
Definition at line 975 of file command.c.
References alloc_concatenate_strings(), cmd, COMMAND_ANY, COMMAND_CONFIG, COMMAND_EXEC, current_command_context(), command_context::interp, jimcmd_is_oocd_command(), jimcmd_is_proc(), jimcmd_privdata(), command_context::mode, command::mode, and mode.
|
static |
Definition at line 660 of file command.c.
References find_file(), command_context::interp, and NULL.
bool jimcmd_is_oocd_command | ( | Jim_Cmd * | cmd | ) |
Return true if the command cmd
is registered by OpenOCD.
Definition at line 54 of file command.c.
References cmd, and jim_command_dispatch().
Referenced by command_find_from_name(), jim_command_mode(), and telnet_auto_complete().
|
inlinestatic |
Definition at line 49 of file command.c.
References cmd.
Referenced by command_find_from_name(), and jim_command_mode().
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 59 of file command.c.
Referenced by command_find_from_name(), jim_command_mode(), and telnet_auto_complete().
void process_jim_events | ( | struct command_context * | cmd_ctx | ) |
Definition at line 1299 of file command.c.
References command_context::interp.
Referenced by server_loop().
|
static |
Definition at line 269 of file command.c.
References alloc_printf(), command_find_from_name(), command_free(), command_new(), command_run_linef(), command_context::interp, jim_command_dispatch(), LOG_DEBUG, command_registration::name, and NULL.
Referenced by __register_commands().
|
static |
Definition at line 522 of file command.c.
References cmd, command_run_linef(), ERROR_COMMAND_CLOSE_CONNECTION, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, command::handler, command_context::interp, LOG_DEBUG, and command::name.
Referenced by exec_command().
|
static |
Definition at line 166 of file command.c.
References NULL, and script_command_args_free().
Referenced by exec_command().
|
static |
Definition at line 159 of file command.c.
Referenced by exec_command(), and script_command_args_alloc().
|
static |
Definition at line 142 of file command.c.
References alloc_printf(), debug_level, LOG_DEBUG, and LOG_LVL_DEBUG.
Referenced by jim_command_dispatch().
|
static |
Definition at line 64 of file command.c.
References state.
Referenced by command_log_capture_finish(), and command_log_capture_start().
int unregister_all_commands | ( | struct command_context * | cmd_ctx, |
const char * | cmd_prefix | ||
) |
Unregisters all commands from the specified context.
cmd_ctx | The context that will be cleared of registered commands. |
cmd_prefix | If given, only clear commands from under this one command. |
Definition at line 416 of file command.c.
References ERROR_OK.
Referenced by openocd_main().
|
static |
Definition at line 432 of file command.c.
References ERROR_COMMAND_SYNTAX_ERROR, and name.
Referenced by __register_commands().
|
static |
Definition at line 1127 of file command.c.
Referenced by command_init().
|
static |
|
extern |
Definition at line 292 of file openocd.c.
Referenced by current_command_context().