38 RZ_LOG_WARN(
"No register type for type abbreviation \"%s\".\n",
str);
60 char *at = strchr(
s,
'@');
68 def->arena_type =
def->type;
72 def->arena_type =
def->type;
76 if (
def->type < 0 ||
def->arena_type < 0) {
94 return strtoul(
s + 1,
NULL, 0);
96 return strtoul(
s,
NULL, 0) * 8;
116 }
else if (
s[0] ==
'.') {
117 def->offset = strtoul(
s + 1,
NULL, 0);
120 def->offset = strtoul(
s,
NULL, 0) * 8;
122 const char *bi = strchr(
s,
'.');
128 ut8 bit_offset = strtoul(bi + 1,
NULL, 0);
129 def->offset += bit_offset;
155 RZ_LOG_WARN(
"Failed to get alias name from token.\n");
193 goto reg_parse_error;
199 goto reg_parse_error;
205 goto reg_parse_error;
211 goto reg_parse_error;
216 goto reg_parse_error;
223 goto reg_parse_error;
225 if (comment_flag[0] ==
'#') {
278 bool is_alias =
false;
281 rz_list_foreach (def_lines, it,
line) {
290 RZ_LOG_WARN(
"Comment could not be split from register definition. Line: \"%s\"\n",
line);
306 if (rz_list_empty(toks)) {
311 if (first_tok[0] ==
'#') {
313 }
else if (first_tok[0] ==
'=') {
315 RZ_LOG_WARN(
"Invalid number of %d columns in alias \"%s\" at line %d. 2 needed.\n", toks_len,
line, l);
319 }
else if (
isalpha(first_tok[0])) {
320 if (toks_len != 5 && toks_len != 6) {
321 RZ_LOG_WARN(
"Invalid number of %d columns in definition \"%s\" at line %d. 5 or 6 needed.\n", toks_len,
line, l);
325 RZ_LOG_WARN(
"Invalid line \"%s\" at register profiles line %d.\n",
line, l);
328 bool success = is_alias
349 if (!
reg->regset[t].regs) {
352 if (!
reg->regset[t].ht_regs) {
353 reg->regset[t].ht_regs = ht_pp_new0();
357 reg->bits |= item->size;
359 ht_pp_insert(
reg->regset[t].ht_regs, item->name, item);
366 reg->regset[t].maskregstype |= ((
int)1 << item->type);
382 rz_list_foreach (
reg->reg_profile.alias, it, alias) {
389 rz_list_foreach (
reg->reg_profile.defs, it,
def) {
434 if (
reg->reg_profile_str && !strcmp(
reg->reg_profile_str, profile_str)) {
445 reg->reg_profile_str =
strdup(profile_str);
451 RZ_LOG_WARN(
"Could not parse register profile string.\n");
459 rz_list_foreach_safe (
reg->reg_profile.defs, it,
tmp,
def) {
461 RZ_LOG_WARN(
"Ignoring duplicated register definition '%s'.\n",
def->name);
474 if (
rs &&
rs->arena) {
475 reg->size +=
rs->arena->size;
499 eprintf(
"rz_reg_set_profile: Cannot find '%s'\n", profile);
513 char *ptr1, *gptr, *gptr1;
515 const int all = 1, gpr = 2,
save = 4, restore = 8, float_ = 16,
516 sse = 32,
vector = 64, system = 128, mmx = 256;
517 int number, rel,
offset,
size, type_bits, ret;
524 if (!(ptr = strchr(ptr,
'\n'))) {
538 if ((ptr1 = strchr(ptr,
'\n'))) {
541 eprintf(
"Could not parse line: %s (missing \\n)\n", ptr);
545 ret = sscanf(ptr,
" %s %d %d %d %d %s %s",
name, &number, &rel,
550 eprintf(
"Could not parse line: %s\n", ptr);
577 if ((gptr1 = strchr(gptr,
','))) {
587 type_bits |= restore;
613 if (!(type_bits & sse) && !(type_bits & float_)) {
619 ((type_bits & mmx) || (type_bits & float_) || (type_bits & sse)) ?
"fpu" :
"gpr",
648 eprintf(
"rz_reg_parse_gdb_profile: Cannot find '%s'\n", profile_file);
660 RZ_LOG_WARN(
"It is mandatory to have at least one argument register defined in the register profile.\n");
666 if (a3 && a2 && a1) {
RZ_API int rz_reg_fit_arena(RzReg *reg)
RZ_API int rz_reg_arena_push(RzReg *reg)
RZ_API void rz_reg_arena_pop(RzReg *reg)
RZ_API void rz_reg_arena_shrink(RzReg *reg)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec vector
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_BORROW void * rz_list_get_bottom(RZ_NONNULL const RzList *list)
Returns the first element of the list.
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
RZ_API RZ_BORROW void * rz_list_get_top(RZ_NONNULL const RzList *list)
Returns the last element of the list.
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
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.
static bool parse_alias(RZ_OUT RzList *alias_list, RZ_BORROW RzList *tokens)
Parses a register alias.
static ut32 parse_size(char *s)
Parses the size of a register definition. Sizes with . in front are in bits. Otherwise in bytes.
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.
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.
static void rz_reg_profile_def_free(RzRegProfileDef *def)
static void rz_reg_profile_alias_free(RzRegProfileAlias *alias)
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.
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.
static char * gdb_to_rz_profile(const char *gdb)
RZ_API char * rz_reg_parse_gdb_profile(const char *profile_file)
RZ_API bool rz_reg_set_profile(RzReg *reg, const char *profile)
static bool parse_def(RZ_OUT RzList *def_list, RZ_BORROW RzList *tokens)
Parses a register definition.
RZ_API char * rz_reg_profile_to_cc(RzReg *reg)
RZ_API void rz_reg_reindex(RzReg *reg)
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
RZ_API const char * rz_reg_get_name_by_type(RzReg *reg, const char *alias_name)
RZ_API int rz_reg_get_name_idx(const char *type)
RZ_API int rz_reg_type_by_name(const char *str)
Returns the register type for the given type abbreviation.
RZ_API void rz_reg_free_internal(RzReg *reg, bool init)
RZ_API void rz_reg_item_free(RzRegItem *item)
RZ_API bool rz_reg_set_name(RZ_NONNULL RzReg *reg, RzRegisterId role, RZ_NONNULL const char *name)
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API RZ_OWN char * rz_file_slurp(const char *str, RZ_NULLABLE size_t *usz)
void(* RzListFree)(void *ptr)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API char * rz_str_appendf(char *ptr, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API RZ_OWN RzList * rz_str_split_duplist_n_regex(RZ_NONNULL const char *_str, RZ_NONNULL const char *r, int n, bool trim)
Split the string str according to the regex r and returns a RzList with the result.
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_append(char *ptr, const char *string)
#define RZ_STR_ISEMPTY(x)
RZ_API char * rz_str_prepend(char *ptr, const char *string)
RZ_API const char * rz_str_trim_head_ro(const char *str)
RZ_API const char * rz_str_strchr(RZ_NONNULL const char *str, RZ_NONNULL const char *c)
Returns a pointer to the first occurrence of UTF-8 character c in the string s.
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API RzList * rz_str_split_duplist_n(const char *str, const char *c, int n, bool trim)
Split the string str according to the substring c and returns a RzList with the result.
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API void rz_strbuf_free(RzStrBuf *sb)
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
RzRegisterId role
Register role (PC, Argument etc.)
char * reg_name
Real register name of alias.
char * alias
Alias of register.
RzRegisterType type
Register type.
int size
in bits> 8,16,32,64 ... 128/256
int arena
In which arena is this reg living. Usually equals type.
int packed_size
0 means no packed register, 1byte pack, 2b pack...
int offset
Offset into register profile in bits.
char * comment
Comment to register.
int def(FILE *source, FILE *dest, int level)