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)) |
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_find) | |
COMMAND_HANDLER (handle_help_add_command) | |
COMMAND_HANDLER (handle_help_command) | |
COMMAND_HANDLER (handle_sleep_command) | |
static void | command_help_show_indent (unsigned int n) |
static void | command_help_show_wrap (const char *str, unsigned int n, unsigned int 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 (command_parse_str_to_buf, const char *str, void *buf, unsigned int buf_len) | |
Parse a number (base 10, base 16 or base 8) and store the result into a bit buffer. More... | |
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 *context, 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) |
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 void | script_debug (Jim_Interp *interp, unsigned int argc, Jim_Obj *const *argv) |
static void | tcl_output (void *privData, const char *file, unsigned int 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 332 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 286 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 859 of file command.c.
References alloc_printf(), LOG_ERROR, and NULL.
Referenced by jim_command_mode().
|
static |
Definition at line 468 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 1254 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 644 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 1244 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 179 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 231 of file command.c.
References command::name, and priv.
Referenced by register_command().
COMMAND_HANDLER | ( | handle_echo | ) |
Definition at line 668 of file command.c.
References CMD_ARGC, CMD_ARGV, ERROR_FAIL, ERROR_OK, LOG_USER, and LOG_USER_N.
COMMAND_HANDLER | ( | handle_find | ) |
Definition at line 653 of file command.c.
References CMD, CMD_ARGC, CMD_ARGV, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, and find_file().
COMMAND_HANDLER | ( | handle_help_add_command | ) |
Definition at line 1073 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 830 of file command.c.
References alloc_printf(), CALL_COMMAND_HANDLER, CMD_ARGC, CMD_ARGV, CMD_NAME, and LOG_ERROR.
|
static |
Definition at line 731 of file command.c.
References LOG_USER_N.
Referenced by command_help_show_wrap().
|
static |
Definition at line 736 of file command.c.
References command_help_show_indent(), HELP_LINE_WIDTH, and LOG_USER.
Referenced by COMMAND_HELPER().
|
static |
Definition at line 756 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 720 of file command.c.
References CALL_COMMAND_HANDLER, CMD_CTX, ERROR_OK, lh(), and list_for_each_entry.
COMMAND_HELPER | ( | command_parse_str_to_buf | , |
const char * | str, | ||
void * | buf, | ||
unsigned int | buf_len | ||
) |
Parse a number (base 10, base 16 or base 8) and store the result into a bit buffer.
Use the prefixes '0' and '0x' for base 8 and 16, otherwise defaults to base 10.
In case of parsing error, a user-readable error message is produced.
Definition at line 1363 of file command.c.
References CMD, command_print(), ERROR_COMMAND_ARGUMENT_INVALID, ERROR_INVALID_NUMBER, ERROR_NUMBER_EXCEEDS_BUFFER, ERROR_OK, and str_to_buf().
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 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().
|
static |
Definition at line 104 of file command.c.
References log_remove_callback(), state, and tcl_output().
Referenced by jim_capture().
|
static |
Definition at line 68 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 194 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 414 of file command.c.
References command_context::output_handler.
Referenced by command_run_line(), target_asciimsg(), and target_hexmsg().
|
static |
Definition at line 1336 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 1348 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 443 of file command.c.
References alloc_vprintf(), and cmd.
Referenced by __COMMAND_HANDLER(), 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(), esp32_apptrace_cmd_ctx_init(), esp32_apptrace_cmd_init(), esp32_apptrace_connect_targets(), esp32_cmd_apptrace_generic(), esp32_sysview_cmd_init(), esp_semihosting_basedir_command(), etmv1_analyze_trace(), find_target(), get_target_with_common_rtos_type(), handle_bp_command_list(), handle_bp_command_set(), handle_iod_output(), mips32_cp0_get_all_regs(), mips32_cp0_get_reg_by_name(), mips32_cp0_get_reg_by_number(), mips32_cp0_set_reg_by_name(), mips32_cp0_set_reg_by_number(), mips32_dsp_get_all_regs(), mips32_dsp_get_register(), mips32_dsp_set_register(), mips32_verify_pointer(), mips_m4k_verify_pointer(), nand_fileio_start(), nand_list_walker(), nvp_unknown_command_print(), PLD_CREATE_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 420 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(), nvp_unknown_command_print(), pic32mx_info(), psoc5lp_eeprom_get_info_command(), psoc5lp_get_info_command(), psoc5lp_nvl_get_info_command(), psoc6_get_info(), qn908x_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 128 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 547 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 613 of file command.c.
References alloc_vprintf(), command_run_line(), and ERROR_FAIL.
Referenced by COMMAND_HANDLER(), exec_command(), gdb_restart_inferior(), parse_cmdline_args(), and register_command().
void command_set_output_handler | ( | struct command_context * | context, |
command_output_handler_t | output_handler, | ||
void * | priv | ||
) |
Definition at line 628 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 635 of file command.c.
Referenced by add_connection().
struct command_context* current_command_context | ( | Jim_Interp * | interp | ) |
Definition at line 157 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_command_dispatch(), jim_command_mode(), jim_target_configure(), jim_target_invoke_event(), target_configure(), target_create(), target_handle_event(), target_jim_get_reg(), and target_jim_write_memory().
|
static |
Definition at line 492 of file command.c.
References command_invocation::argc, command_invocation::argv, cmd, command_retval_set(), command_run_linef(), ERROR_COMMAND_CLOSE_CONNECTION, ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, command::handler, command_context::interp, command::jim_handler, LOG_DEBUG, LOG_ERROR, command::name, and NULL.
Referenced by jim_command_dispatch().
|
static |
Definition at line 1020 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 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().
|
static |
Definition at line 1002 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 685 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 885 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(), NULL, script_debug(), and target_call_timer_callbacks().
Referenced by jimcmd_is_oocd_command(), and register_command().
|
static |
Definition at line 939 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.
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().
|
inlinestatic |
Definition at line 46 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 56 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 1263 of file command.c.
References command_context::interp.
Referenced by server_loop().
|
static |
Definition at line 239 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 141 of file command.c.
References alloc_printf(), debug_level, LOG_DEBUG, LOG_LVL_DEBUG, and NULL.
Referenced by jim_command_dispatch().
|
static |
Definition at line 61 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 386 of file command.c.
References ERROR_OK.
Referenced by openocd_main().
|
static |
Definition at line 402 of file command.c.
References ERROR_COMMAND_SYNTAX_ERROR, and name.
Referenced by __register_commands().
|
static |
Definition at line 1091 of file command.c.
Referenced by command_init().
|
static |
|
extern |
Definition at line 233 of file openocd.c.
Referenced by current_command_context().