Rizin
unix-like reverse engineering framework and cli tools
|
#include <tree_sitter/api.h>
#include <rz_core.h>
#include <rz_cons.h>
#include <rz_cmd.h>
#include "core_private.h"
Go to the source code of this file.
Classes | |
struct | autocmplt_data_t |
struct | autocmplt_cmdidentifier_t |
struct | guess_data_t |
Enumerations | |
enum | autocmplt_type_t { AUTOCMPLT_UNKNOWN = 0 , AUTOCMPLT_CMD_ID , AUTOCMPLT_CMD_ARG , AUTOCMPLT_AT_STMT , AUTOCMPLT_RZNUM , AUTOCMPLT_ARCH , AUTOCMPLT_BITS , AUTOCMPLT_FILE , AUTOCMPLT_FLAG_SPACE , AUTOCMPLT_REG , AUTOCMPLT_EVAL_FULL , AUTOCMPLT_FLAG , AUTOCMPLT_FUNCTION } |
enum autocmplt_type_t |
Describe what needs to be autocompleted.
Enumerator | |
---|---|
AUTOCMPLT_UNKNOWN | Unknown, nothing will be autocompleted. |
AUTOCMPLT_CMD_ID | A command identifier (aka command name) needs to be autocompleted. |
AUTOCMPLT_CMD_ARG | The argument of an arged_stmt (see grammar.js) needs to be autocompleted. |
AUTOCMPLT_AT_STMT | A temporary modifier operator like |
AUTOCMPLT_RZNUM | A expression that can be parsed by RzNum (e.g. "flag+3") |
AUTOCMPLT_ARCH | An architecture supported by Rizin (e.g. x86, arm, etc.) |
AUTOCMPLT_BITS | A bits value supported by the currently selected architecture (e asm.bits=?) |
AUTOCMPLT_FILE | A file needs to be autocompleted. |
AUTOCMPLT_FLAG_SPACE | A flag space needs to be autocompleted. |
AUTOCMPLT_REG | A cpu register needs to be autocompleted. |
AUTOCMPLT_EVAL_FULL | A name=value of a evaluable variable (e.g. |
AUTOCMPLT_FLAG | A flag item needs to be autocompleted. |
AUTOCMPLT_FUNCTION | A function name needs to be autocompleted. |
Definition at line 14 of file cautocmpl.c.
|
static |
Definition at line 190 of file cautocmpl.c.
References autocmplt_bits_plugin(), rz_line_ns_completion_result_t::end_string, len, rz_asm_plugin_t::name, rz_core_t::rasm, autocmplt_cmdidentifier_t::res, rz_asm_get_plugins(), rz_line_ns_completion_result_add(), rz_return_if_fail, rz_sub_str_rchr(), s, and rz_line_ns_completion_result_t::start.
|
static |
Definition at line 123 of file cautocmpl.c.
References rz_line_ns_completion_result_t::end_string, len, NULL, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), and s.
|
static |
Definition at line 220 of file cautocmpl.c.
References autocmplt_bits_plugin(), rz_asm_t::cur, len, rz_core_t::rasm, autocmplt_cmdidentifier_t::res, rz_return_if_fail, and s.
|
static |
Definition at line 179 of file cautocmpl.c.
References rz_asm_plugin_t::bits, bits(), i, len, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_strf, and s.
Referenced by autocmplt_arch(), and autocmplt_bits().
|
static |
Fill res
with all the available options for the argument i_arg-th of the command cd
. This is based on the type of argument a command may accept.
Definition at line 667 of file cautocmpl.c.
References autocmplt_cmd_arg_alias_type(), autocmplt_cmd_arg_any_type(), autocmplt_cmd_arg_choices(), autocmplt_cmd_arg_enum_type(), autocmplt_cmd_arg_env(), autocmplt_cmd_arg_eval_full(), autocmplt_cmd_arg_eval_key(), autocmplt_cmd_arg_fcn(), autocmplt_cmd_arg_fcn_var(), autocmplt_cmd_arg_file(), autocmplt_cmd_arg_flag(), autocmplt_cmd_arg_global_var(), autocmplt_cmd_arg_macro(), autocmplt_cmd_arg_reg_filter(), autocmplt_cmd_arg_reg_type(), autocmplt_cmd_arg_rznum(), autocmplt_cmd_arg_struct_type(), autocmplt_cmd_arg_union_type(), cd, len, rz_core_t::rcmd, autocmplt_cmdidentifier_t::res, RZ_CMD_ARG_TYPE_ALIAS_TYPE, RZ_CMD_ARG_TYPE_ANY_TYPE, RZ_CMD_ARG_TYPE_CHOICES, RZ_CMD_ARG_TYPE_ENUM_TYPE, RZ_CMD_ARG_TYPE_ENV, RZ_CMD_ARG_TYPE_EVAL_FULL, RZ_CMD_ARG_TYPE_EVAL_KEY, RZ_CMD_ARG_TYPE_FCN, RZ_CMD_ARG_TYPE_FCN_VAR, RZ_CMD_ARG_TYPE_FILE, RZ_CMD_ARG_TYPE_FLAG, RZ_CMD_ARG_TYPE_GLOBAL_VAR, RZ_CMD_ARG_TYPE_MACRO, RZ_CMD_ARG_TYPE_REG_FILTER, RZ_CMD_ARG_TYPE_REG_TYPE, RZ_CMD_ARG_TYPE_RZNUM, RZ_CMD_ARG_TYPE_STRUCT_TYPE, RZ_CMD_ARG_TYPE_UNION_TYPE, rz_cmd_desc_get_arg(), and s.
|
static |
Definition at line 398 of file cautocmpl.c.
References rz_core_t::analysis, len, list(), autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_list_free(), rz_type_db_typedef_names(), s, and rz_analysis_t::typedb.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 410 of file cautocmpl.c.
References rz_core_t::analysis, len, list(), autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_list_free(), rz_type_db_all(), s, and rz_analysis_t::typedb.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 520 of file cautocmpl.c.
References c, free(), len, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), and s.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 362 of file cautocmpl.c.
References rz_core_t::analysis, len, list(), autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_list_free(), rz_type_db_enum_names(), s, and rz_analysis_t::typedb.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 307 of file cautocmpl.c.
References rz_line_ns_completion_result_t::end_string, env, eq, free(), len, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_str_ndup(), rz_sys_get_environ(), s, and strdup().
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 546 of file cautocmpl.c.
References autocmplt_cmd_arg_eval_key(), rz_core_t::config, rz_line_ns_completion_result_t::end_string, eq, err, free(), k, len, NULL, rz_config_node_t::options, autocmplt_cmdidentifier_t::res, rz_config_node_get(), rz_config_node_is_bool(), rz_line_ns_completion_result_add(), rz_list_length(), rz_str_ndup(), rz_sub_str_rchr(), s, rz_line_ns_completion_result_t::start, and v.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 536 of file cautocmpl.c.
References rz_core_t::config, len, rz_config_node_t::name, rz_config_t::nodes, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), and s.
Referenced by autocmplt_cmd_arg(), and autocmplt_cmd_arg_eval_full().
|
static |
Definition at line 350 of file cautocmpl.c.
References rz_core_t::analysis, rz_analysis_t::fcns, free(), len, autocmplt_cmdidentifier_t::res, rz_core_analysis_fcn_name(), rz_line_ns_completion_result_add(), and s.
Referenced by autocmplt_cmd_arg(), and autocmplt_cmd_arg_rznum().
|
static |
Definition at line 589 of file cautocmpl.c.
References rz_core_t::analysis, len, rz_analysis_var_t::name, rz_core_t::offset, autocmplt_cmdidentifier_t::res, rz_analysis_get_fcn_in(), rz_analysis_var_all_list(), rz_line_ns_completion_result_add(), rz_list_free(), and s.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 253 of file cautocmpl.c.
References basename, rz_line_ns_completion_result_t::end_string, free(), input(), len, autocmplt_cmdidentifier_t::res, rz_file_basename(), rz_file_dirname(), rz_file_is_abspath(), rz_file_is_directory(), rz_file_path_join(), rz_line_ns_completion_result_add(), rz_list_free(), rz_path_home_expand(), RZ_STR_ISEMPTY, rz_str_ndup(), rz_str_newf(), rz_str_replace_ch(), rz_str_startswith(), RZ_SYS_DIR, rz_sys_dir(), s, strdup(), and autogen_x86imm::tmp.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 331 of file cautocmpl.c.
References rz_core_t::flags, len, list(), rz_flag_item_t::name, autocmplt_cmdidentifier_t::res, rz_flag_all_list(), rz_line_ns_completion_result_add(), rz_list_free(), and s.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 422 of file cautocmpl.c.
References rz_core_t::analysis, len, list(), rz_analysis_var_global_t::name, autocmplt_cmdidentifier_t::res, rz_analysis_var_global_get_all(), rz_line_ns_completion_result_add(), rz_list_free(), and s.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 486 of file cautocmpl.c.
References len, autocmplt_cmdidentifier_t::res, rz_core_help_vars_get(), rz_line_ns_completion_result_add(), and s.
Referenced by autocmplt_cmd_arg_rznum().
|
static |
Definition at line 320 of file cautocmpl.c.
References len, rz_cmd_t::macro, rz_cmd_macro_t::macros, rz_cmd_macro_item_t::name, p, rz_core_t::rcmd, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), and s.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 435 of file cautocmpl.c.
References rz_core_t::analysis, cd, rz_core_t::dbg, len, rz_reg_item_t::name, reg, rz_analysis_t::reg, rz_debug_t::reg, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_propose(), rz_reg_get_role(), rz_reg_get_type(), RZ_REG_NAME_LAST, RZ_REG_TYPE_LAST, s, and type.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 480 of file cautocmpl.c.
References len, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_propose(), rz_reg_get_type(), RZ_REG_TYPE_LAST, and s.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 501 of file cautocmpl.c.
References autocmplt_cmd_arg_fcn(), autocmplt_cmd_arg_help_var(), rz_core_t::flags, is_op_ch(), len, offset_prompt_add_flag(), p, autocmplt_cmdidentifier_t::res, rz_flag_foreach_prefix(), s, and rz_line_ns_completion_result_t::start.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 374 of file cautocmpl.c.
References rz_core_t::analysis, len, list(), autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_list_free(), rz_type_db_struct_names(), s, and rz_analysis_t::typedb.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 386 of file cautocmpl.c.
References rz_core_t::analysis, len, list(), autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), rz_list_free(), rz_type_db_union_names(), s, and rz_analysis_t::typedb.
Referenced by autocmplt_cmd_arg().
|
static |
Definition at line 114 of file cautocmpl.c.
References do_autocmplt_cmdidentifier(), len, NULL, rz_core_t::rcmd, autocmplt_cmdidentifier_t::res, rz_cmd_foreach_cmdname(), and s.
|
static |
Definition at line 226 of file cautocmpl.c.
References rz_core_t::flags, len, rz_space_t::name, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), and s.
|
static |
Definition at line 240 of file cautocmpl.c.
References len, rz_reg_item_t::name, reg, regs, autocmplt_cmdidentifier_t::res, rz_core_reg_default(), rz_line_ns_completion_result_add(), rz_reg_get_list(), RZ_REG_TYPE_ANY, and s.
Definition at line 106 of file cautocmpl.c.
References desc, autocmplt_cmdidentifier_t::len, autocmplt_cmdidentifier_t::res, rz_line_ns_completion_result_add(), and autocmplt_cmdidentifier_t::s.
Referenced by autocmplt_cmdidentifier().
|
static |
Definition at line 734 of file cautocmpl.c.
References test_evm::end, NULL, autocmplt_data_t::res, rz_line_ns_completion_result_new(), start, type, and autocmplt_data_t::type.
Referenced by fill_autocmplt_data_at_stmt(), fill_autocmplt_data_cmdid(), find_autocmplt_type_arg_identifier(), and find_autocmplt_type_at_stmt_op().
|
static |
Fill the ad
structure with all the data required to autocomplete a tmp stmt (@, @(, :, etc.) or a iter stmt (@, @., @i, etc.)
Definition at line 775 of file cautocmpl.c.
References AUTOCMPLT_AT_STMT, test_evm::end, fill_autocmplt_data(), and start.
Referenced by find_autocmplt_type_at_stmt().
|
static |
Fill the ad
structure with all the data required to autocomplete the argument of a command. This includes the command descriptor of the command and the position of the argument that needs to be auto completed.
Definition at line 753 of file cautocmpl.c.
References AUTOCMPLT_CMD_ARG, autocmplt_data_t::cd, test_evm::end, get_arg_number(), get_cd_from_arg(), autocmplt_data_t::i_arg, NULL, rz_core_t::rcmd, autocmplt_data_t::res, rz_cmd_desc_get_arg(), rz_line_ns_completion_result_new(), s, start, and autocmplt_data_t::type.
Referenced by find_autocmplt_type(), find_autocmplt_type_arg_identifier(), find_autocmplt_type_newcmd_or_arg(), and find_autocmplt_type_quoted_arg().
|
static |
Fill the ad
structure with all the data required to autocomplete the cmdidentifier of a command.
Definition at line 744 of file cautocmpl.c.
References AUTOCMPLT_CMD_ID, test_evm::end, fill_autocmplt_data(), and start.
Referenced by find_autocmplt_type(), and find_autocmplt_type_newcmd_or_arg().
|
static |
Returns true and a properly filled ad
when something to autocomplete was discovered.
If possible, determine the type to autocomplete based on the syntax tree returned by the rizin parser. However, sometimes the autocompletion has to guess what type needs to be autocompleted, because the syntax tree contain errors (as you write a command it may still be invalid) or it does not have yet the token you want to autocomplete.
Definition at line 969 of file cautocmpl.c.
References AUTOCMPLT_ARCH, AUTOCMPLT_BITS, AUTOCMPLT_EVAL_FULL, AUTOCMPLT_FILE, AUTOCMPLT_FLAG, AUTOCMPLT_FLAG_SPACE, AUTOCMPLT_FUNCTION, AUTOCMPLT_REG, AUTOCMPLT_RZNUM, rz_line_ns_completion_result_t::end_string, fill_autocmplt_data_cmdarg(), fill_autocmplt_data_cmdid(), find_autocmplt_type_arg_identifier(), find_autocmplt_type_at_stmt(), find_autocmplt_type_at_stmt_op(), find_autocmplt_type_newcmd_or_arg(), find_autocmplt_type_quoted_arg(), autocmplt_data_t::res, root, RZ_LOG_DEBUG, ts_node_end_byte(), ts_node_named_child_count(), ts_node_start_byte(), and ts_node_type().
|
static |
Definition at line 937 of file cautocmpl.c.
References AUTOCMPLT_ARCH, AUTOCMPLT_BITS, AUTOCMPLT_EVAL_FULL, AUTOCMPLT_FILE, AUTOCMPLT_FLAG_SPACE, AUTOCMPLT_REG, AUTOCMPLT_RZNUM, fill_autocmplt_data(), fill_autocmplt_data_cmdarg(), get_arg_parent(), root, ts_node_is_null(), and ts_node_type().
Referenced by find_autocmplt_type().
|
static |
Definition at line 815 of file cautocmpl.c.
References fill_autocmplt_data_at_stmt(), g, guess_data_free(), guess_next_autocmplt_token(), setup::idx, is_arg_identifier_in_tmp_stmt(), p, RZ_LINE_BUFSIZE, start, ts_node_end_byte(), ts_node_start_byte(), and ts_node_type().
Referenced by find_autocmplt_type().
|
static |
Definition at line 902 of file cautocmpl.c.
References fill_autocmplt_data(), g, get_arg_parent(), guess_data_free(), guess_next_autocmplt_token(), ts_node_end_byte(), ts_node_is_null(), ts_node_start_byte(), and ts_node_type().
Referenced by find_autocmplt_type().
|
static |
Definition at line 779 of file cautocmpl.c.
References fill_autocmplt_data_cmdarg(), fill_autocmplt_data_cmdid(), g, guess_data_free(), guess_next_autocmplt_token(), is_arg_type(), autocmplt_cmdidentifier_t::res, ts_node_start_byte(), and ts_node_type().
Referenced by find_autocmplt_type().
|
static |
Definition at line 922 of file cautocmpl.c.
References fill_autocmplt_data_cmdarg(), g, guess_data_free(), guess_next_autocmplt_token(), ts_node_end_byte(), ts_node_has_error(), ts_node_start_byte(), and ts_node_type().
Referenced by find_autocmplt_type().
Definition at line 647 of file cautocmpl.c.
References ts_node_is_null(), ts_node_parent(), ts_node_prev_sibling(), and ts_node_type().
Referenced by fill_autocmplt_data_cmdarg().
Definition at line 795 of file cautocmpl.c.
References is_arg_type(), guess_data_t::node, ts_node_is_null(), ts_node_parent(), and ts_node_type().
Referenced by find_autocmplt_type_arg_identifier(), find_autocmplt_type_at_stmt_op(), and is_arg_identifier_in_tmp_stmt().
Definition at line 620 of file cautocmpl.c.
References arg(), get_cd_from_cmdid(), is_arg_type(), NULL, ts_node_is_null(), ts_node_named_child(), ts_node_parent(), and ts_node_type().
Referenced by fill_autocmplt_data_cmdarg().
Definition at line 611 of file cautocmpl.c.
References cd, free(), rz_core_t::rcmd, rz_cmd_desc_get_exec(), rz_cmd_get_desc(), rz_str_ndup(), ts_node_end_byte(), and ts_node_start_byte().
Referenced by get_cd_from_arg().
|
static |
Definition at line 61 of file cautocmpl.c.
References free(), g, ts_parser_delete(), and ts_tree_delete().
Referenced by find_autocmplt_type_at_stmt(), find_autocmplt_type_at_stmt_op(), find_autocmplt_type_newcmd_or_arg(), and find_autocmplt_type_quoted_arg().
|
static |
Modify the input in buf
to add additional characters, trying to detect what token could go in the current position of the buffer. For example, to detect that a CMD_ID is expected at * ?e $(<TAB>
, you could try inserting a letter and see what would be the new syntax tree.
Definition at line 74 of file cautocmpl.c.
References err, free(), g, rz_cmd_t::language, malloc(), memcpy(), guess_data_t::node, NULL, cmd_descs_generate::parser, rz_core_t::rcmd, root, RZ_LOG_DEBUG, RZ_NEW0, autogen_x86imm::tmp, guess_data_t::tree, ts_node_is_null(), ts_node_named_descendant_for_byte_range(), ts_parser_delete(), ts_parser_new(), ts_parser_parse_string(), ts_parser_set_language(), ts_tree_delete(), and ts_tree_root_node().
Referenced by find_autocmplt_type_at_stmt(), find_autocmplt_type_at_stmt_op(), find_autocmplt_type_newcmd_or_arg(), and find_autocmplt_type_quoted_arg().
Definition at line 802 of file cautocmpl.c.
References get_arg_parent(), is_arg_type(), guess_data_t::node, rz_str_endswith(), rz_str_startswith(), ts_node_is_null(), and ts_node_type().
Referenced by find_autocmplt_type_at_stmt().
Definition at line 605 of file cautocmpl.c.
References type.
Referenced by find_autocmplt_type_newcmd_or_arg(), get_arg_parent(), get_cd_from_arg(), and is_arg_identifier_in_tmp_stmt().
|
static |
|
static |
Definition at line 344 of file cautocmpl.c.
References rz_flag_item_t::name, autocmplt_cmdidentifier_t::res, and rz_line_ns_completion_result_add().
Referenced by autocmplt_cmd_arg_rznum().
RZ_API RzLineNSCompletionResult* rz_core_autocomplete_rzshell | ( | RzCore * | core, |
RzLineBuffer * | buf, | ||
RzLinePromptType | prompt_type | ||
) |
Returns a RzLineNSCompletionResult
structure containing all the info to autocomplete what is currently in buf
.
Definition at line 1048 of file cautocmpl.c.
Referenced by rzshell_autocomplete().