5 #include "../core_private.h"
9 #define SYNC_READ(type, failed) \
12 if (sync_cb && !sync_cb(core, type, false)) { \
13 RZ_LOG_ERROR("Failed to read registers.\n"); \
17 #define SYNC_READ_LIST(ritems, failed) \
20 if (rz_list_length(ritems) == 1) { \
21 SYNC_READ(((RzRegItem *)rz_list_head(ritems))->type, failed); \
22 } else if (rz_list_length(ritems) > 1) { \
23 SYNC_READ(RZ_REG_TYPE_ANY, failed); \
26 #define SYNC_WRITE(type, failed) \
29 if (sync_cb && !sync_cb(core, type, true)) { \
30 RZ_LOG_ERROR("Failed to write registers.\n"); \
33 rz_core_reg_update_flags(core); \
44 if (!strcmp(
filter,
"all")) {
89 if (item->
size < 80) {
165 char *
val =
str + eq_pos + 1;
187 if (t && !strcmp(t, item->
name)) {
234 char buf[256] = { 0 };
235 rz_list_foreach (ritems,
iter, item) {
236 switch (
state->mode) {
241 rz_cons_print(
color);
264 if (item->
size <= 64) {
310 char whites[32], content[300];
311 char strvalue[256] = { 0 };
313 rz_list_foreach (ritems,
iter, item) {
316 rz_cons_print(
color);
319 int len =
snprintf(content,
sizeof(content),
"%7s %s", item->
name, strvalue);
323 rz_cons_print(content);
327 if ((
idx + 1) % cols) {
328 int rem = colwidth - strlen(content);
332 rz_cons_print(whites);
355 int had_colors = use_colors;
366 rz_list_foreach (ritems,
iter,
r) {
428 HtUP *db = ht_up_new0();
445 rz_list_foreach (sorted,
iter,
addr) {
461 if (rrstr && *rrstr && strchr(rrstr,
'R')) {
490 rz_list_foreach (
rs->pool,
iter,
a) {
492 (
a ==
rs->arena) ?
"*" :
".",
a,
588 size_t maxsz = (strlen(
hex) + 1) / 2;
603 if (!
a || !
a->bytes) {
631 if (rz_list_empty(ritems)) {
632 eprintf(
"No argument roles defined.\n");
684 rz_list_foreach (ritems,
iter, item) {
693 rz_cons_print(
"fss-\n");
700 switch (
state->mode) {
702 if (
reg->reg_profile_str) {
705 eprintf(
"No register profile defined.\n");
714 pj_k(pj,
"alias_info");
726 pj_k(pj,
"reg_info");
729 rz_list_foreach (
reg->regset[
i].regs,
iter,
r) {
731 pj_kn(pj,
"type",
r->type);
733 pj_ks(pj,
"name",
r->name);
734 pj_kn(pj,
"size",
r->size);
735 pj_kn(pj,
"offset",
r->offset);
750 if (
reg->reg_profile_cmt) {
787 rf->
s, rf->
z, rf->
c, rf->
o, rf->
p);
839 char *
eq = strchr(
name,
'=');
843 char *
p = strchr(
name,
' ');
859 long double val = 0.0f;
862 sscanf(
eq,
"%lf", (
double *)&dval);
865 sscanf(
eq,
"%Lf", &
val);
882 eprintf(
"cannot find multimedia register '%s'\n",
name);
RZ_API int rz_reg_arena_push(RzReg *reg)
RZ_API ut8 * rz_reg_get_bytes(RzReg *reg, int type, int *size)
RZ_API void rz_reg_arena_pop(RzReg *reg)
RZ_API void rz_reg_arena_zero(RzReg *reg, RzRegisterType type)
RZ_API void rz_reg_arena_swap(RzReg *reg, int copy)
int bits(struct state *s, int need)
const lzma_allocator const uint8_t size_t uint8_t * out
RZ_IPI RzCmdStatus rz_reg_profile_comments_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_cond_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
static RzCmdStatus assign_reg(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, RZ_NONNULL const char *arg, size_t eq_pos)
(Sub)handler for register assignments like reg=0x42
#define SYNC_READ_LIST(ritems, failed)
RZ_IPI RzCmdStatus rz_reg_arenas_zero_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_regs_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzCmdStateOutput *state)
RZ_IPI RzCmdStatus rz_reg_profile_gdb_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_roles_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_types_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_regs_fpu_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
#define SYNC_WRITE(type, failed)
static void print_reg_not_found(const char *arg)
static RzCmdStatus references_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, RzList *ritems, RzOutputMode mode)
static bool valgroup_regcb(void *u, const ut64 k, const void *v)
RZ_IPI RzCmdStatus rz_regs_args_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzOutputMode mode)
static const char * get_reg_color(RzCore *core, RzReg *reg, RzRegItem *item)
RZ_IPI RzCmdStatus rz_reg_arenas_hexdump_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
RZ_API RZ_OWN RzList * rz_core_reg_filter_items_sync(RZ_NONNULL RzCore *core, RZ_NONNULL RzReg *reg, RzCmdRegSync sync_cb, RZ_NULLABLE const char *filter)
static RzList * filter_reg_items(RzReg *reg, RZ_NULLABLE const char *filter)
RZ_IPI void rz_regs_show_valgroup(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, const RzList *list)
RZ_IPI RzCmdStatus rz_regs_columns_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_regs_valgroup_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_arenas_push_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
static const char * get_reg_role_name(RzReg *reg, RzRegItem *item)
RZ_IPI RzCmdStatus rz_reg_arenas_swap_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_regs_diff_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
RZ_API bool rz_core_reg_assign_sync(RZ_NONNULL RzCore *core, RZ_NONNULL RzReg *reg, RzCmdRegSync sync_cb, RZ_NONNULL const char *name, ut64 val)
RZ_IPI RzCmdStatus rz_reg_arenas_write_hex_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
static RzCmdStatus show_regs_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, const char *filter, RzCmdStateOutput *state)
RZ_IPI RzCmdStatus rz_reg_arenas_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_regs_prev_handler(RzCore *core, RzReg *reg, int argc, const char **argv, RzCmdStateOutput *state)
RZ_IPI RzCmdStatus rz_regs_references_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzOutputMode mode)
static int valgroup_regcmp(const void *a, const void *b)
RZ_IPI RzCmdStatus rz_reg_arenas_pop_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
#define SYNC_READ(type, failed)
RZ_IPI RzCmdStatus rz_reg_profile_handler(RzCore *core, RzReg *reg, int argc, const char **argv, RzCmdStateOutput *state)
static void format_reg_value(RzReg *reg, RzRegItem *item, char *out, size_t out_size)
Format the value of a register as a nice hex string.
static bool reg_has_changed(RzReg *reg, RzRegItem *item)
Check whether the given item's value has changed in the last step.
RZ_IPI RzCmdStatus rz_reg_cc_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_arenas_stack_size_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_profile_open_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
RZ_IPI RzCmdStatus rz_reg_flags_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, bool unset)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
RZ_API void rz_cons_strcat(const char *str)
RZ_API void rz_cons_newline(void)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API void rz_cons_println(const char *str)
RZ_IPI void rz_core_print_hexdump(RZ_NONNULL RzCore *core, ut64 addr, RZ_NONNULL const ut8 *buf, int len, int base, int step, size_t zoomsz)
RZ_IPI RzList * rz_core_reg_flags_candidates(RzCore *core, RzReg *reg)
RZ_IPI void rz_core_reg_print_diff(RzReg *reg, RzList *items)
Print registers that have changed since the last step (drd/ard)
RZ_API bool rz_reg_set_double(RzReg *reg, RzRegItem *item, double value)
RZ_API long double rz_reg_get_longdouble(RzReg *reg, RzRegItem *item)
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API RzTable * rz_core_table(RzCore *core)
RZ_API char * rz_core_analysis_hasrefs(RzCore *core, ut64 value, int mode)
static void list(RzEgg *egg)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN RzList * rz_list_clone(RZ_NONNULL const RzList *list)
Shallow copies of the list (but doesn't free its elements)
RZ_API RZ_OWN RzList * rz_list_new_from_array(RZ_NONNULL const void **arr, size_t arr_size)
Allocates a new RzList and adds an array elements to it.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
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 RZ_BORROW RzListIter * rz_list_add_sorted(RZ_NONNULL RzList *list, void *data, RZ_NONNULL RzListComparator cmp)
Adds an element to a sorted list via the RzListComparator.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char argv
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")
static const char hex[16]
RZ_API char * rz_reg_parse_gdb_profile(const char *profile_file)
RZ_API bool rz_reg_set_profile(RzReg *reg, const char *profile)
RZ_API char * rz_reg_profile_to_cc(RzReg *reg)
RZ_API int rz_reg_cond_bits(RzReg *r, int type, RzRegFlags *f)
RZ_API RzRegFlags * rz_reg_cond_retrieve(RzReg *r, RzRegFlags *f)
RZ_API const char * rz_reg_cond_to_string(int n)
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
RZ_API const char * rz_reg_get_name(RzReg *reg, int role)
RZ_API int rz_reg_role_by_name(RZ_NONNULL const char *str)
Get the RzRegisterId with the given name or -1.
RZ_API int rz_reg_type_by_name(const char *str)
Returns the register type for the given type abbreviation.
RZ_API const char * rz_reg_get_type(int idx)
RZ_API const char * rz_reg_get_role(int role)
RZ_API RZ_OWN RzList * rz_reg_filter_items_covered(RZ_BORROW RZ_NONNULL const RzList *regs)
Filter out all register items that are smaller than but covered entirely by some other register.
RZ_API ut64 rz_reg_get_value_big(RzReg *reg, RzRegItem *item, utX *val)
RZ_API bool rz_reg_set_value(RzReg *reg, RzRegItem *item, ut64 value)
RZ_API ut64 rz_reg_get_value(RzReg *reg, RzRegItem *item)
#define rz_return_val_if_fail(expr, val)
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
@ RZ_CMD_STATUS_WRONG_ARGS
command handler could not handle the arguments passed to it
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
#define RZ_FLAGS_FS_REGISTERS
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
RZ_API PJ * pj_k(PJ *j, const char *k)
RZ_API PJ * pj_end(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
static const char * rz_str_get(const char *str)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_trim_dup(const char *str)
#define RZ_STR_ISEMPTY(x)
RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str)
Removes whitespace characters (space, tab, newline etc.) from the beginning and end of a string.
RZ_API void rz_table_add_rowf(RzTable *t, const char *fmt,...)
RZ_API RZ_OWN char * rz_table_tojson(RzTable *t)
Convert RzTable to json format.
RZ_API void rz_table_free(RzTable *t)
RZ_API void rz_table_set_columnsf(RzTable *t, const char *fmt,...)
Specify the types and names of the referenced table.
RZ_API char * rz_table_tostring(RzTable *t)
RzOutputMode
Enum to describe the way data are printed.
@ RZ_OUTPUT_MODE_STANDARD
Represent the output state of a command handler.
RzConsPrintablePalette pal
RzRegisterType type
Register type.
int size
in bits> 8,16,32,64 ... 128/256
void error(const char *msg)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()