Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_list.h>
#include <rz_util/rz_log.h>
#include <rz_util/rz_str.h>
#include <rz_reg.h>
#include <rz_util.h>
#include <rz_util/rz_assert.h>
#include <rz_lib.h>
#include <string.h>
Go to the source code of this file.
Functions | |
static void | rz_reg_profile_def_free (RzRegProfileDef *def) |
static void | rz_reg_profile_alias_free (RzRegProfileAlias *alias) |
static int | expect_reg_type_by_name (const char *str) |
static bool | parse_type (RZ_OUT RzRegProfileDef *def, const char *type_str) |
Parses a register type string. More... | |
static ut32 | parse_size (char *s) |
Parses the size of a register definition. Sizes with . in front are in bits. Otherwise in bytes. More... | |
static bool | parse_offset (const char *s, RZ_OUT RzRegProfileDef *def) |
Parses the offset of a register defintion and sets the offset in def->offset . More... | |
static bool | parse_alias (RZ_OUT RzList *alias_list, RZ_BORROW RzList *tokens) |
Parses a register alias. More... | |
static bool | parse_def (RZ_OUT RzList *def_list, RZ_BORROW RzList *tokens) |
Parses a register definition. More... | |
static bool | parse_reg_profile_str (RZ_OUT RzList *alias_list, RZ_OUT RzList *def_list, const char *profile_str) |
Parses a register profile string. Each line is either a register alias or a register definiton. More... | |
static void | add_item_to_regset (RZ_BORROW RzReg *reg, RZ_BORROW RzRegItem *item) |
RZ_API bool | rz_reg_set_reg_profile (RZ_BORROW RzReg *reg) |
Fills reg->regset with the definitions and alias of the register profile. More... | |
RZ_API bool | rz_reg_set_profile_string (RZ_NONNULL RzReg *reg, RZ_NONNULL const char *profile_str) |
Parses a register profile string and sets up all registers accordingly in reg . More... | |
RZ_API bool | rz_reg_set_profile (RzReg *reg, const char *profile) |
static char * | gdb_to_rz_profile (const char *gdb) |
RZ_API char * | rz_reg_parse_gdb_profile (const char *profile_file) |
RZ_API char * | rz_reg_profile_to_cc (RzReg *reg) |
Definition at line 345 of file profile.c.
References int, reg, rz_list_append(), rz_list_newf(), rz_reg_item_free(), RZ_REG_TYPE_ANY, rz_return_if_fail, and UT32_MAX.
Referenced by rz_reg_set_reg_profile().
Like rz_reg_type_by_name, but warn if non-existent
Definition at line 35 of file profile.c.
References r, RZ_LOG_WARN, rz_reg_type_by_name(), and cmd_descs_generate::str.
Referenced by parse_type().
|
static |
Definition at line 507 of file profile.c.
References test_group_name::all, eprintf, make_dist_html::groups, isspace, NULL, rz_return_val_if_fail, rz_str_startswith(), rz_str_trim_head_ro(), rz_strbuf_appendf(), rz_strbuf_drain(), rz_strbuf_free(), rz_strbuf_new(), save, sb, type, and vector.
Referenced by rz_reg_parse_gdb_profile().
Parses a register alias.
The alias is of the form: "=<alias> <reg name>"
reg | The RzReg struct with the register profile. |
tokens | A list with both tokens of the alias string. |
Definition at line 144 of file profile.c.
References RzRegProfileAlias::alias, free(), RzRegProfileAlias::reg_name, RzRegProfileAlias::role, rz_list_append(), rz_list_get_n(), RZ_LOG_WARN, RZ_NEW0, rz_reg_get_name_idx(), RZ_REG_NAME_LAST, rz_return_val_if_fail, and strdup().
Referenced by parse_reg_profile_str().
Parses a register definition.
reg | Register struct with the register profile. |
tokens | List of strings of a single register definition. |
Definition at line 183 of file profile.c.
References def(), parse_offset(), parse_size(), parse_type(), rz_list_append(), rz_list_get_n(), rz_list_length(), RZ_LOG_WARN, RZ_NEW0, rz_reg_profile_def_free(), rz_return_val_if_fail, strdup(), and UT32_MAX.
Referenced by parse_reg_profile_str().
|
static |
Parses the offset of a register defintion and sets the offset in def->offset
.
Offset is of the form: <byte>.<bit> .<bit> is optional.
s | Offset string. |
def | The defintion item to store the offset into def->offset in bits. |
Definition at line 111 of file profile.c.
References def(), NULL, rz_return_val_if_fail, s, and UT32_MAX.
Referenced by parse_def().
|
static |
Parses a register profile string. Each line is either a register alias or a register definiton.
A register alias string is of the following form: "=<alias> <name>\n"
A register definition string is of the following form: "(<sub-type>@)main-type <name> .<size> <byte offset>(.<bit offset>) <packed> (# <comment> OR <flags>)\n"
Elements in "()" are optional. Each "<...>" token is separated by tab or space characters.
reg | Register struct which holds all register items. |
profile | Register profile string. |
Definition at line 270 of file profile.c.
References isalpha, setup::line, NULL, parse_alias(), parse_def(), rz_list_append(), rz_list_free(), rz_list_get_bottom(), rz_list_get_n(), rz_list_get_top(), rz_list_length(), RZ_LOG_WARN, rz_return_val_if_fail, RZ_STR_ISEMPTY, rz_str_prepend(), rz_str_split_duplist_n(), rz_str_split_duplist_n_regex(), rz_str_strchr(), st32, strdup(), and autogen_x86imm::tmp.
Referenced by rz_reg_set_profile_string().
|
static |
Parses the size of a register definition. Sizes with . in front are in bits. Otherwise in bytes.
s | Size string. |
Definition at line 91 of file profile.c.
References NULL, rz_return_val_if_fail, s, and UT32_MAX.
Referenced by parse_def().
|
static |
Parses a register type string.
The type string must be of the following form:
<sub-type><main-type>
"<sub-type>@" is optional.
item | Register item whichs types are set. |
type_str | The type string. |
Definition at line 57 of file profile.c.
References def(), expect_reg_type_by_name(), free(), RZ_LOG_ERROR, RZ_REG_TYPE_FLG, RZ_REG_TYPE_GPR, rz_return_val_if_fail, s, and strdup().
Referenced by parse_def().
Definition at line 631 of file profile.c.
References eprintf, free(), gdb_to_rz_profile(), NULL, rz_file_slurp(), RZ_LIB_ENV, rz_str_appendf(), RZ_SYS_DIR, rz_sys_getenv(), and cmd_descs_generate::str.
Referenced by rz_reg_profile_gdb_handler().
|
static |
Definition at line 23 of file profile.c.
References RzRegProfileAlias::alias, free(), and RzRegProfileAlias::reg_name.
Referenced by rz_reg_set_profile_string().
|
static |
Definition at line 652 of file profile.c.
References a0, NULL, r0, reg, RZ_LOG_WARN, rz_reg_get_name_by_type(), and rz_str_newf().
Referenced by rz_core_analysis_cc_init(), and rz_reg_cc_handler().
Definition at line 486 of file profile.c.
References eprintf, file, free(), NULL, reg, rz_file_slurp(), RZ_LIB_ENV, rz_reg_set_profile_string(), rz_return_val_if_fail, rz_str_append(), rz_sys_getenv(), and cmd_descs_generate::str.
Referenced by rz_reg_profile_open_handler().
RZ_API bool rz_reg_set_profile_string | ( | RZ_NONNULL RzReg * | reg, |
RZ_NONNULL const char * | profile_str | ||
) |
Parses a register profile string and sets up all registers accordingly in reg
.
reg | The RzReg struct which should hold the register data. |
profile | The register profile string. |
Definition at line 431 of file profile.c.
References def(), i, parse_reg_profile_str(), reg, rs, rz_list_delete(), rz_list_newf(), RZ_LOG_WARN, rz_reg_arena_pop(), rz_reg_arena_push(), rz_reg_arena_shrink(), rz_reg_fit_arena(), rz_reg_free_internal(), rz_reg_get(), rz_reg_profile_alias_free(), rz_reg_profile_def_free(), rz_reg_reindex(), rz_reg_set_reg_profile(), RZ_REG_TYPE_ANY, RZ_REG_TYPE_LAST, rz_return_val_if_fail, strdup(), and autogen_x86imm::tmp.
Referenced by rz_analysis_set_reg_profile(), rz_debug_reg_profile_sync(), rz_reg_set_profile(), and setup_regs().
Fills reg->regset
with the definitions and alias of the register profile.
reg | The RzReg struct which holds the register profile and an empty reg->regset |
Definition at line 376 of file profile.c.
References add_item_to_regset(), rz_reg_item_t::arena, rz_reg_item_t::comment, def(), rz_reg_item_t::flags, rz_reg_item_t::name, rz_reg_item_t::offset, rz_reg_item_t::packed_size, reg, RzRegProfileAlias::reg_name, RzRegProfileAlias::role, RZ_LOG_WARN, RZ_NEW0, rz_reg_set_name(), rz_return_val_if_fail, rz_reg_item_t::size, strdup(), and rz_reg_item_t::type.
Referenced by rz_reg_set_profile_string().