Rizin
unix-like reverse engineering framework and cli tools
cmd_regs.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Florian Märkl <info@florianmaerkl.de>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_core.h>
5 #include "../core_private.h"
6 
8 
9 #define SYNC_READ(type, failed) \
10  do { \
11  failed = false; \
12  if (sync_cb && !sync_cb(core, type, false)) { \
13  RZ_LOG_ERROR("Failed to read registers.\n"); \
14  failed = true; \
15  } \
16  } while (0)
17 #define SYNC_READ_LIST(ritems, failed) \
18  do { \
19  failed = false; \
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); \
24  } \
25  } while (0)
26 #define SYNC_WRITE(type, failed) \
27  do { \
28  failed = false; \
29  if (sync_cb && !sync_cb(core, type, true)) { \
30  RZ_LOG_ERROR("Failed to write registers.\n"); \
31  failed = true; \
32  } \
33  rz_core_reg_update_flags(core); \
34  } while (0)
35 
38  // default
39  if (RZ_STR_ISEMPTY(filter)) {
40  // default selection (only gpr, omit smaller regs that are fully covered by larger ones)
41  return rz_reg_filter_items_covered(reg->regset[RZ_REG_TYPE_GPR].regs);
42  }
43  // all
44  if (!strcmp(filter, "all")) {
45  return rz_list_clone(reg->allregs);
46  }
47  // bit size
48  char *end = NULL;
49  unsigned long bits = strtoul(filter, &end, 0);
50  if (!*end) {
51  RzList *ret = rz_list_new();
52  if (!ret) {
53  return NULL;
54  }
56  RzRegItem *ri;
57  rz_list_foreach (reg->regset[RZ_REG_TYPE_GPR].regs, iter, ri) {
58  if (ri->size == bits) {
59  rz_list_push(ret, ri);
60  }
61  }
62  return ret;
63  }
64  // type
66  if (type >= 0) {
67  return rz_list_clone(reg->regset[type].regs);
68  }
69  // role
70  int role = rz_reg_role_by_name(filter);
71  if (role >= 0) {
72  const char *itemname = rz_reg_get_name(reg, role);
73  if (!itemname) {
74  return NULL;
75  }
76  filter = itemname; // fallthrough to the below query with the resolved reg name
77  }
78  // single register name
80  if (!ri) {
81  return NULL;
82  }
83  return rz_list_new_from_array((const void **)&ri, 1);
84 }
85 
87 static void format_reg_value(RzReg *reg, RzRegItem *item, char *out, size_t out_size) {
88  // TODO: This could be done much nicer with RzBitVector, but it's not in RzUtil yet :-(
89  if (item->size < 80) {
90  ut64 value = rz_reg_get_value(reg, item);
91  snprintf(out, out_size, "0x%08" PFMT64x, value);
92  } else {
93  utX valueBig;
94  rz_reg_get_value_big(reg, item, &valueBig);
95  switch (item->size) {
96  case 80:
97  snprintf(out, out_size, "0x%04x%016" PFMT64x "", valueBig.v80.High, valueBig.v80.Low);
98  break;
99  case 96:
100  snprintf(out, out_size, "0x%08x%016" PFMT64x "", valueBig.v96.High, valueBig.v96.Low);
101  break;
102  case 128:
103  snprintf(out, out_size, "0x%016" PFMT64x "%016" PFMT64x "", valueBig.v128.High, valueBig.v128.Low);
104  break;
105  case 256:
106  snprintf(out, out_size, "0x%016" PFMT64x "%016" PFMT64x "%016" PFMT64x "%016" PFMT64x "",
107  valueBig.v256.High.High, valueBig.v256.High.Low, valueBig.v256.Low.High, valueBig.v256.Low.Low);
108  break;
109  default:
110  snprintf(out, out_size, "ERROR");
111  }
112  }
113 }
114 
116 static bool reg_has_changed(RzReg *reg, RzRegItem *item) {
117  ut64 value = rz_reg_get_value(reg, item);
118  rz_reg_arena_swap(reg, false);
119  ut64 old = rz_reg_get_value(reg, item);
120  rz_reg_arena_swap(reg, false);
121  return old != value;
122 }
123 
124 static void print_reg_not_found(const char *arg) {
125  RZ_LOG_ERROR("No such register or register type: \"%s\"\n", rz_str_get(arg));
126 }
127 
138 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) {
139  rz_return_val_if_fail(core && reg && name, false);
141  if (!ri) {
142  return false;
143  }
144  bool failed;
145  SYNC_READ(ri->type, failed);
146  if (failed) {
147  return false;
148  }
149  rz_reg_set_value(reg, ri, val);
150  SYNC_WRITE(ri->type, failed);
151  return true;
152 }
153 
159 static RzCmdStatus assign_reg(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, RZ_NONNULL const char *arg, size_t eq_pos) {
160  char *str = strdup(arg);
161  if (!str) {
162  return RZ_CMD_STATUS_ERROR;
163  }
164  str[eq_pos] = 0;
165  char *val = str + eq_pos + 1;
166  rz_str_trim(str);
167  rz_str_trim(val);
168  ut64 nval = rz_num_math(core->num, val);
169  return rz_core_reg_assign_sync(core, reg, sync_cb, str, nval) ? RZ_CMD_STATUS_OK : RZ_CMD_STATUS_ERROR;
170 }
171 
172 static const char *get_reg_color(RzCore *core, RzReg *reg, RzRegItem *item) {
173  if (!rz_config_get_i(core->config, "scr.color")) {
174  return NULL;
175  }
176  if (reg_has_changed(reg, item)) {
177  return (core->cons && core->cons->context->pal.creg)
178  ? core->cons->context->pal.creg
179  : Color_BWHITE;
180  }
181  return NULL;
182 }
183 
184 static const char *get_reg_role_name(RzReg *reg, RzRegItem *item) {
185  for (int i = 0; i < RZ_REG_NAME_LAST; i++) {
186  const char *t = rz_reg_get_name(reg, i);
187  if (t && !strcmp(t, item->name)) {
188  return rz_reg_get_role(i);
189  }
190  }
191  return NULL;
192 }
193 
203 RZ_API RZ_OWN RzList /*<RzRegItem *>*/ *rz_core_reg_filter_items_sync(RZ_NONNULL RzCore *core, RZ_NONNULL RzReg *reg, RzCmdRegSync sync_cb, RZ_NULLABLE const char *filter) {
204  rz_return_val_if_fail(core && reg, NULL);
205  RzList *ritems = filter_reg_items(reg, filter);
206  if (!ritems) {
207  return NULL;
208  }
209 
210  bool failed;
211  SYNC_READ_LIST(ritems, failed);
212  if (failed) {
213  rz_list_free(ritems);
214  return NULL;
215  }
216  return ritems;
217 }
218 
219 static RzCmdStatus show_regs_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, const char *filter, RzCmdStateOutput *state) {
220  RzList *ritems = rz_core_reg_filter_items_sync(core, reg, sync_cb, filter);
221  if (!ritems) {
223  return RZ_CMD_STATUS_ERROR;
224  }
225 
226  if (state->mode == RZ_OUTPUT_MODE_TABLE) {
227  rz_table_set_columnsf(state->d.t, "ssXxs", "role", "name", "value", "size", "type");
228  } else if (state->mode == RZ_OUTPUT_MODE_JSON) {
229  pj_o(state->d.pj);
230  }
231 
232  RzListIter *iter;
233  RzRegItem *item;
234  char buf[256] = { 0 };
235  rz_list_foreach (ritems, iter, item) {
236  switch (state->mode) {
238  format_reg_value(reg, item, buf, sizeof(buf));
239  const char *color = get_reg_color(core, reg, item);
240  if (color) {
241  rz_cons_print(color);
242  }
243  rz_cons_printf("%s = %s", item->name, buf);
244  if (color) {
245  rz_cons_print(Color_RESET);
246  }
247  rz_cons_print("\n");
248  break;
249  }
251  format_reg_value(reg, item, buf, sizeof(buf));
252  rz_cons_printf("%s\n", buf);
253  break;
255  format_reg_value(reg, item, buf, sizeof(buf));
256  rz_cons_printf("ar %s = %s\n", item->name, buf);
257  break;
259  rz_table_add_rowf(state->d.t, "ssXxs",
261  item->name, rz_reg_get_value(reg, item), (ut64)item->size, rz_reg_get_type(item->type));
262  break;
263  case RZ_OUTPUT_MODE_JSON:
264  if (item->size <= 64) {
265  pj_kn(state->d.pj, item->name, rz_reg_get_value(reg, item));
266  } else {
267  format_reg_value(reg, item, buf, sizeof(buf));
268  pj_ks(state->d.pj, item->name, buf);
269  }
270  break;
271  default:
272  break;
273  }
274  }
275  rz_list_free(ritems);
276 
277  if (state->mode == RZ_OUTPUT_MODE_JSON) {
278  pj_end(state->d.pj);
279  }
280  return RZ_CMD_STATUS_OK;
281 }
282 
283 RZ_IPI RzCmdStatus rz_regs_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzCmdStateOutput *state) {
284  const char *filter = argc > 1 ? argv[1] : NULL;
285 
286  // check if the argument is an assignment like reg=0x42
287  if (filter) {
288  char *eq = strchr(filter, '=');
289  if (eq) {
290  return assign_reg(core, reg, sync_cb, filter, eq - filter);
291  }
292  }
293 
294  // just show
295  return show_regs_handler(core, reg, sync_cb, filter, state);
296 }
297 
298 RZ_IPI RzCmdStatus rz_regs_columns_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
299  const char *filter = argc > 1 ? argv[1] : NULL;
300  RzList *ritems = rz_core_reg_filter_items_sync(core, reg, sync_cb, filter);
301  if (!ritems) {
303  return RZ_CMD_STATUS_ERROR;
304  }
305 
306  int cols = 4; // how many registers in a row
307  int colwidth = 24;
308  RzListIter *iter;
309  RzRegItem *item;
310  char whites[32], content[300];
311  char strvalue[256] = { 0 };
312  size_t idx = 0;
313  rz_list_foreach (ritems, iter, item) {
314  const char *color = get_reg_color(core, reg, item);
315  if (color) {
316  rz_cons_print(color);
317  }
318  format_reg_value(reg, item, strvalue, sizeof(strvalue));
319  int len = snprintf(content, sizeof(content), "%7s %s", item->name, strvalue);
320  if (len < 0) {
321  break;
322  }
323  rz_cons_print(content);
324  if (color) {
325  rz_cons_print(Color_RESET);
326  }
327  if ((idx + 1) % cols) {
328  int rem = colwidth - strlen(content);
329  rem = RZ_MIN(sizeof(whites) - 1, RZ_MAX(0, rem));
330  memset(whites, ' ', rem);
331  whites[rem] = 0;
332  rz_cons_print(whites);
333  } else {
334  rz_cons_print("\n");
335  }
336  idx++;
337  }
338  if (idx % cols) {
339  // only print newline if not already done in the loop above
340  rz_cons_print("\n");
341  }
342  rz_list_free(ritems);
343  return RZ_CMD_STATUS_OK;
344 }
345 
346 static RzCmdStatus references_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, RzList *ritems, RzOutputMode mode) {
347  bool failed;
348  SYNC_READ_LIST(ritems, failed);
349  if (failed) {
350  return RZ_CMD_STATUS_ERROR;
351  }
352 
353  int use_colors = rz_config_get_i(core->config, "scr.color");
354 
355  int had_colors = use_colors;
356  if (use_colors && mode == RZ_OUTPUT_MODE_JSON) {
357  use_colors = 0;
358  // for rz_core_analysis_hasrefs() below
359  rz_config_set_i(core->config, "scr.color", 0);
360  }
361 
362  RzTable *t = rz_core_table(core);
363  rz_table_set_columnsf(t, "ssss", "role", "reg", "value", "refstr");
364  RzListIter *iter;
365  RzRegItem *r;
366  rz_list_foreach (ritems, iter, r) {
368  const char *color = mode == RZ_OUTPUT_MODE_JSON ? NULL : get_reg_color(core, reg, r);
369  char *namestr = rz_str_newf("%s%s%s", rz_str_get(color), r->name, color ? Color_RESET : "");
370  char *valuestr = rz_str_newf("%s0x%" PFMT64x "%s", rz_str_get(color), value, color ? Color_RESET : "");
371  char *rrstr = rz_core_analysis_hasrefs(core, value, true);
372  rz_table_add_rowf(t, "ssss", rz_str_get(get_reg_role_name(reg, r)), namestr, valuestr, rz_str_get(rrstr));
373  free(namestr);
374  free(valuestr);
375  free(rrstr);
376  }
377 
378  if (mode == RZ_OUTPUT_MODE_JSON && had_colors) {
379  rz_config_set_i(core->config, "scr.color", had_colors);
380  }
381 
383  rz_cons_print(s);
384  if (mode == RZ_OUTPUT_MODE_JSON) {
385  rz_cons_print("\n");
386  }
387  free(s);
388  rz_table_free(t);
389  return RZ_CMD_STATUS_OK;
390 }
391 
392 RZ_IPI RzCmdStatus rz_regs_references_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzOutputMode mode) {
393  const char *filter = argc > 1 ? argv[1] : NULL;
394  RzList *ritems = filter_reg_items(reg, filter);
395  if (!ritems) {
397  return RZ_CMD_STATUS_ERROR;
398  }
399  RzCmdStatus r = references_handler(core, reg, sync_cb, ritems, mode);
400  rz_list_free(ritems);
401  return r;
402 }
403 
404 static int valgroup_regcmp(const void *a, const void *b) {
405  const ut64 *A = (const ut64 *)a;
406  const ut64 *B = (const ut64 *)b;
407  if (*A > *B) {
408  return 1;
409  }
410  if (*A == *B) {
411  return 0;
412  }
413  return -1;
414 }
415 
416 static bool valgroup_regcb(void *u, const ut64 k, const void *v) {
417  RzList *sorted = (RzList *)u;
418  ut64 *n = ut64_new(k);
420  return true;
421 }
422 
423 RZ_IPI void rz_regs_show_valgroup(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, const RzList *list) {
424  int use_colors = rz_config_get_i(core->config, "scr.color");
425 
426  RzListIter *iter;
427  RzRegItem *r;
428  HtUP *db = ht_up_new0();
429  rz_list_foreach (list, iter, r) {
430  if (r->size != core->rasm->bits) {
431  continue;
432  }
434  RzList *list = ht_up_find(db, value, NULL);
435  if (!list) {
437  ht_up_update(db, value, list);
438  }
439  rz_list_append(list, r->name);
440  }
441 
442  RzList *sorted = rz_list_newf(free);
443  ht_up_foreach(db, valgroup_regcb, sorted);
444  ut64 *addr;
445  rz_list_foreach (sorted, iter, addr) {
446  rz_cons_printf("0x%08" PFMT64x " ", *addr);
447  RzList *list = ht_up_find(db, *addr, NULL);
448  if (list) {
449  RzListIter *iter;
450  const char *r;
451  if (use_colors) {
453  }
454  rz_list_foreach (list, iter, r) {
455  rz_cons_printf(" %s", r);
456  }
457  if (use_colors) {
459  }
460  char *rrstr = rz_core_analysis_hasrefs(core, *addr, true);
461  if (rrstr && *rrstr && strchr(rrstr, 'R')) {
462  rz_cons_printf(" ;%s%s", rrstr, use_colors ? Color_RESET : "");
463  }
464  rz_cons_newline();
465  }
466  }
467  rz_list_free(sorted);
468  ht_up_free(db);
469 }
470 
471 RZ_IPI RzCmdStatus rz_regs_valgroup_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
472  const char *filter = argc > 1 ? argv[1] : NULL;
474  if (!list) {
476  return RZ_CMD_STATUS_ERROR;
477  }
478  rz_regs_show_valgroup(core, reg, sync_cb, list);
480  return RZ_CMD_STATUS_OK;
481 }
482 
483 RZ_IPI RzCmdStatus rz_reg_arenas_handler(RzCore *core, RzReg *reg, int argc, const char **argv) {
484  int i, j;
485  RzRegArena *a;
486  RzListIter *iter;
487  for (i = 0; i < RZ_REG_TYPE_LAST; i++) {
488  RzRegSet *rs = &reg->regset[i];
489  j = 0;
490  rz_list_foreach (rs->pool, iter, a) {
491  rz_cons_printf("%s %p %d %d %s %d\n",
492  (a == rs->arena) ? "*" : ".", a,
493  i, j, rz_reg_get_type(i), a->size);
494  j++;
495  }
496  }
497  return RZ_CMD_STATUS_OK;
498 }
499 
500 RZ_IPI RzCmdStatus rz_reg_arenas_push_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
501  bool failed;
502  SYNC_READ(RZ_REG_TYPE_ANY, failed);
503  if (failed) {
504  return RZ_CMD_STATUS_ERROR;
505  }
507  SYNC_WRITE(RZ_REG_TYPE_ANY, failed);
508  return failed ? RZ_CMD_STATUS_ERROR : RZ_CMD_STATUS_OK;
509 }
510 
511 RZ_IPI RzCmdStatus rz_reg_arenas_pop_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
513  bool failed;
514  SYNC_WRITE(RZ_REG_TYPE_ANY, failed);
515  return failed ? RZ_CMD_STATUS_ERROR : RZ_CMD_STATUS_OK;
516 }
517 
518 RZ_IPI RzCmdStatus rz_reg_arenas_swap_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
519  bool failed;
520  SYNC_READ(RZ_REG_TYPE_ANY, failed);
521  if (failed) {
522  return RZ_CMD_STATUS_ERROR;
523  }
524  rz_reg_arena_swap(reg, false);
525  SYNC_WRITE(RZ_REG_TYPE_ANY, failed);
526  return failed ? RZ_CMD_STATUS_ERROR : RZ_CMD_STATUS_OK;
527 }
528 
529 RZ_IPI RzCmdStatus rz_reg_arenas_zero_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
530  int t = RZ_REG_TYPE_ANY;
531  if (argc > 1) {
532  t = rz_reg_type_by_name(argv[1]);
533  if (t < 0) {
534  RZ_LOG_ERROR("No such register type: \"%s\"\n", argv[2]);
535  return RZ_CMD_STATUS_ERROR;
536  }
537  }
539  bool failed;
540  SYNC_WRITE(t, failed);
541  return failed ? RZ_CMD_STATUS_ERROR : RZ_CMD_STATUS_OK;
542 }
543 
544 RZ_IPI RzCmdStatus rz_reg_arenas_hexdump_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
545  int t = RZ_REG_TYPE_GPR;
546  if (argc > 1) {
547  t = rz_reg_type_by_name(argv[1]);
548  if (t < 0) {
549  RZ_LOG_ERROR("No such register type: \"%s\"\n", argv[2]);
550  return RZ_CMD_STATUS_ERROR;
551  }
552  }
553  bool failed;
554  SYNC_READ(t, failed);
555  if (failed) {
556  return RZ_CMD_STATUS_ERROR;
557  }
558  int len = 0;
559  ut8 *buf = rz_reg_get_bytes(reg, t, &len);
560  if (buf) {
561  rz_core_print_hexdump(core, 0LL, buf, len, 32, 4, 1);
562  free(buf);
563  }
564  return RZ_CMD_STATUS_OK;
565 }
566 
568  rz_cons_printf("%d\n", (int)rz_list_length(reg->regset[0].pool));
569  return RZ_CMD_STATUS_OK;
570 }
571 
572 RZ_IPI RzCmdStatus rz_reg_arenas_write_hex_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
575  if (argc > 2) {
577  if (type < 0 || type >= RZ_REG_TYPE_LAST) {
578  RZ_LOG_ERROR("No such register type: \"%s\"\n", argv[2]);
579  return RZ_CMD_STATUS_ERROR;
580  }
581  }
582  bool failed;
583  SYNC_READ(type, failed);
584  if (failed) {
585  return RZ_CMD_STATUS_ERROR;
586  }
587  const char *hex = argv[1];
588  size_t maxsz = (strlen(hex) + 1) / 2;
589  if (!maxsz) {
590  return RZ_CMD_STATUS_ERROR;
591  }
592  ut8 *buf = malloc(maxsz);
593  if (!buf) {
594  return RZ_CMD_STATUS_ERROR;
595  }
596  int sz = rz_hex_str2bin(hex, buf);
597  if (sz <= 0) {
598  RZ_LOG_ERROR("Invalid hex string given.\n");
599  free(buf);
600  return RZ_CMD_STATUS_ERROR;
601  }
602  RzRegArena *a = reg->regset[type].arena;
603  if (!a || !a->bytes) {
604  free(buf);
605  // nothing to write, this is fine
606  return RZ_CMD_STATUS_OK;
607  }
608  memcpy(a->bytes, buf, RZ_MIN(sz, a->size));
609  free(buf);
610  SYNC_WRITE(type, failed);
611  return failed ? RZ_CMD_STATUS_ERROR : RZ_CMD_STATUS_OK;
612 }
613 
614 RZ_IPI RzCmdStatus rz_regs_args_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzOutputMode mode) {
615  RzList *ritems = rz_list_new();
616  if (!ritems) {
617  return RZ_CMD_STATUS_ERROR;
618  }
619  for (int i = RZ_REG_NAME_A0; i <= RZ_REG_NAME_A9; i++) {
620  const char *name = rz_reg_get_name(reg, i);
621  if (!name) {
622  break;
623  }
625  if (!item) {
626  continue;
627  }
628  rz_list_push(ritems, item);
629  }
631  if (rz_list_empty(ritems)) {
632  eprintf("No argument roles defined.\n");
633  } else {
634  r = references_handler(core, reg, sync_cb, ritems, mode);
635  }
636  rz_list_free(ritems);
637  return r;
638 }
639 
640 RZ_IPI RzCmdStatus rz_reg_types_handler(RzCore *core, RzReg *reg, int argc, const char **argv) {
641  for (int i = 0; i < RZ_REG_TYPE_LAST; i++) {
643  }
644  return RZ_CMD_STATUS_OK;
645 }
646 
647 RZ_IPI RzCmdStatus rz_reg_roles_handler(RzCore *core, RzReg *reg, int argc, const char **argv) {
648  for (int i = 0; i < RZ_REG_NAME_LAST; i++) {
649  rz_cons_print(rz_reg_get_role(i));
650  if (reg->name[i]) {
651  rz_cons_printf(" -> %s", reg->name[i]);
652  }
653  rz_cons_print("\n");
654  }
655  return RZ_CMD_STATUS_OK;
656 }
657 
658 RZ_IPI RzCmdStatus rz_reg_flags_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, bool unset) {
659  const char *filter = argc > 1 && *argv[1] ? argv[1] : NULL;
660  RzList *ritems;
661  if (filter) {
662  ritems = filter_reg_items(reg, filter);
663  if (!ritems) {
665  return RZ_CMD_STATUS_ERROR;
666  }
667  } else {
668  ritems = rz_core_reg_flags_candidates(core, reg);
669  if (!ritems) {
670  return RZ_CMD_STATUS_ERROR;
671  }
672  }
673  if (!unset) {
674  rz_cons_print("fss+ " RZ_FLAGS_FS_REGISTERS "\n");
675  bool failed;
676  SYNC_READ_LIST(ritems, failed);
677  if (failed) {
678  rz_list_free(ritems);
679  return RZ_CMD_STATUS_ERROR;
680  }
681  }
682  RzListIter *iter;
683  RzRegItem *item;
684  rz_list_foreach (ritems, iter, item) {
685  if (!unset) {
686  ut64 v = rz_reg_get_value(reg, item);
687  rz_cons_printf("f+ %s @ 0x%" PFMT64x "\n", item->name, v);
688  } else {
689  rz_cons_printf("f- %s\n", item->name);
690  }
691  }
692  if (!unset) {
693  rz_cons_print("fss-\n");
694  }
695  rz_list_free(ritems);
696  return RZ_CMD_STATUS_OK;
697 }
698 
700  switch (state->mode) {
702  if (reg->reg_profile_str) {
703  rz_cons_println(reg->reg_profile_str);
704  } else {
705  eprintf("No register profile defined.\n");
706  }
707  break;
708  case RZ_OUTPUT_MODE_JSON: {
709  RzListIter *iter;
710  RzRegItem *r;
711  int i;
712  PJ *pj = state->d.pj;
713  pj_o(pj);
714  pj_k(pj, "alias_info");
715  pj_a(pj);
716  for (i = 0; i < RZ_REG_NAME_LAST; i++) {
717  if (reg->name[i]) {
718  pj_o(pj);
719  pj_kn(pj, "role", i);
720  pj_ks(pj, "role_str", rz_reg_get_role(i));
721  pj_ks(pj, "reg", reg->name[i]);
722  pj_end(pj);
723  }
724  }
725  pj_end(pj);
726  pj_k(pj, "reg_info");
727  pj_a(pj);
728  for (i = 0; i < RZ_REG_TYPE_LAST; i++) {
729  rz_list_foreach (reg->regset[i].regs, iter, r) {
730  pj_o(pj);
731  pj_kn(pj, "type", r->type);
732  pj_ks(pj, "type_str", rz_reg_get_type(r->type));
733  pj_ks(pj, "name", r->name);
734  pj_kn(pj, "size", r->size);
735  pj_kn(pj, "offset", r->offset);
736  pj_end(pj);
737  }
738  }
739  pj_end(pj);
740  pj_end(pj);
741  break;
742  }
743  default:
744  break;
745  }
746  return RZ_CMD_STATUS_OK;
747 }
748 
750  if (reg->reg_profile_cmt) {
751  rz_cons_println(reg->reg_profile_cmt);
752  }
753  return RZ_CMD_STATUS_OK;
754 }
755 
759  return RZ_CMD_STATUS_OK;
760 }
761 
764  char *rz_profile = rz_reg_parse_gdb_profile(argv[1]);
765  if (!rz_profile) {
766  RZ_LOG_ERROR("Cannot parse gdb profile.\n");
767  core->num->value = 1;
768  return RZ_CMD_STATUS_ERROR;
769  }
770  rz_cons_println(rz_profile);
771  core->num->value = 0;
772  free(rz_profile);
773  return RZ_CMD_STATUS_OK;
774 }
775 
776 RZ_IPI RzCmdStatus rz_reg_cond_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
777  bool failed;
778  SYNC_READ(RZ_REG_TYPE_ANY, failed);
779  if (failed) {
780  return RZ_CMD_STATUS_ERROR;
781  }
783  if (!rf) {
784  return RZ_CMD_STATUS_ERROR;
785  }
786  rz_cons_printf("| s:%d z:%d c:%d o:%d p:%d\n",
787  rf->s, rf->z, rf->c, rf->o, rf->p);
788  for (int i = 0; i < RZ_REG_COND_LAST; i++) {
789  rz_cons_printf("%d %s\n",
790  rz_reg_cond_bits(reg, i, rf),
792  }
793  free(rf);
794  return RZ_CMD_STATUS_OK;
795 }
796 
797 RZ_IPI RzCmdStatus rz_reg_cc_handler(RzCore *core, RzReg *reg, int argc, const char **argv) {
798  char *s = rz_reg_profile_to_cc(reg);
799  if (s) {
800  rz_cons_printf("%s\n", s);
801  free(s);
802  }
803  return RZ_CMD_STATUS_OK;
804 }
805 
806 RZ_IPI RzCmdStatus rz_regs_diff_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
807  bool failed;
808  SYNC_READ(RZ_REG_TYPE_ANY, failed);
809  if (failed) {
810  return RZ_CMD_STATUS_ERROR;
811  }
812  rz_core_reg_print_diff(reg, reg->allregs);
813  return RZ_CMD_STATUS_OK;
814 }
815 
817  const char *filter = argc > 1 ? argv[1] : NULL;
818  rz_reg_arena_swap(reg, false);
819  RzCmdStatus r = show_regs_handler(core, reg, NULL, filter, state); // sync_cb = NULL on purpose to not overwrite
820  rz_reg_arena_swap(reg, false);
821  return r;
822 }
823 
824 RZ_IPI RzCmdStatus rz_regs_fpu_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv) {
825  // TODO: everything here needs to be rewritten. It was taken from the old "drf" command.
826  bool failed;
827  if (argc <= 1) {
828  // TODO: Do not use this hack to print fpu register:
829  // By sending a negative value, this is signalling all the way through to the debug plugin,
830  // which then does the printing.
831  // This should be rewritten directly above the RzReg.
832  SYNC_READ(-RZ_REG_TYPE_FPU, failed);
833  if (failed) {
834  return RZ_CMD_STATUS_ERROR;
835  }
836  return RZ_CMD_STATUS_OK;
837  }
838  char *name = rz_str_trim_dup(argv[1]);
839  char *eq = strchr(name, '=');
840  if (eq) {
841  *eq++ = 0;
842  }
843  char *p = strchr(name, ' ');
844  if (p) {
845  *p++ = 0;
846  }
848  SYNC_READ(RZ_REG_TYPE_GPR, failed);
849  if (failed) {
850  goto error;
851  }
852  SYNC_READ(RZ_REG_TYPE_FPU, failed);
853  if (failed) {
854  goto error;
855  }
856  RzRegItem *item = rz_reg_get(reg, name, -1);
857  if (item) {
858  if (eq) {
859  long double val = 0.0f;
860 #if __windows__
861  double dval = 0.0f;
862  sscanf(eq, "%lf", (double *)&dval);
863  val = dval;
864 #else
865  sscanf(eq, "%Lf", &val);
866 #endif
867  rz_reg_set_double(reg, item, val);
868  SYNC_WRITE(RZ_REG_TYPE_GPR, failed);
869  if (failed) {
870  goto error;
871  }
872  SYNC_WRITE(RZ_REG_TYPE_FPU, failed);
873  if (failed) {
874  goto error;
875  }
876  } else {
877  long double res = rz_reg_get_longdouble(reg, item);
878  rz_cons_printf("%Lf\n", res);
879  }
880  } else {
881  /* note, that negative type forces sync to print the regs from the backend */
882  eprintf("cannot find multimedia register '%s'\n", name);
883  }
884 
885 error:
886  free(name);
887  return ret;
888 }
size_t len
Definition: 6502dis.c:15
#define rs()
#define RZ_IPI
Definition: analysis_wasm.c:11
lzma_index ** i
Definition: index.h:629
#define A(x)
Definition: arc.h:165
#define B(x)
Definition: arc.h:166
RZ_API int rz_reg_arena_push(RzReg *reg)
Definition: arena.c:236
RZ_API ut8 * rz_reg_get_bytes(RzReg *reg, int type, int *size)
Definition: arena.c:8
RZ_API void rz_reg_arena_pop(RzReg *reg)
Definition: arena.c:216
RZ_API void rz_reg_arena_zero(RzReg *reg, RzRegisterType type)
Definition: arena.c:261
RZ_API void rz_reg_arena_swap(RzReg *reg, int copy)
Definition: arena.c:196
ut16 val
Definition: armass64_const.h:6
int bits(struct state *s, int need)
Definition: blast.c:72
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
static int value
Definition: cmd_api.c:93
RZ_IPI RzCmdStatus rz_reg_profile_comments_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:749
RZ_IPI RzCmdStatus rz_reg_cond_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:776
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
Definition: cmd_regs.c:159
#define SYNC_READ_LIST(ritems, failed)
Definition: cmd_regs.c:17
RZ_IPI RzCmdStatus rz_reg_arenas_zero_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:529
RZ_IPI RzCmdStatus rz_regs_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzCmdStateOutput *state)
Definition: cmd_regs.c:283
RZ_IPI RzCmdStatus rz_reg_profile_gdb_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:762
RZ_IPI RzCmdStatus rz_reg_roles_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:647
RZ_IPI RzCmdStatus rz_reg_types_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:640
RZ_IPI RzCmdStatus rz_regs_fpu_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:824
#define SYNC_WRITE(type, failed)
Definition: cmd_regs.c:26
static void print_reg_not_found(const char *arg)
Definition: cmd_regs.c:124
static RzCmdStatus references_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, RzList *ritems, RzOutputMode mode)
Definition: cmd_regs.c:346
static bool valgroup_regcb(void *u, const ut64 k, const void *v)
Definition: cmd_regs.c:416
RZ_IPI RzCmdStatus rz_regs_args_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzOutputMode mode)
Definition: cmd_regs.c:614
static const char * get_reg_color(RzCore *core, RzReg *reg, RzRegItem *item)
Definition: cmd_regs.c:172
RZ_IPI RzCmdStatus rz_reg_arenas_hexdump_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:544
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)
Definition: cmd_regs.c:203
static RzList * filter_reg_items(RzReg *reg, RZ_NULLABLE const char *filter)
Definition: cmd_regs.c:36
RZ_IPI void rz_regs_show_valgroup(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, const RzList *list)
Definition: cmd_regs.c:423
RZ_IPI RzCmdStatus rz_regs_columns_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:298
RZ_IPI RzCmdStatus rz_regs_valgroup_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:471
RZ_IPI RzCmdStatus rz_reg_arenas_push_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:500
static const char * get_reg_role_name(RzReg *reg, RzRegItem *item)
Definition: cmd_regs.c:184
RZ_IPI RzCmdStatus rz_reg_arenas_swap_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:518
RZ_IPI RzCmdStatus rz_regs_diff_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:806
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)
Definition: cmd_regs.c:138
RZ_IPI RzCmdStatus rz_reg_arenas_write_hex_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:572
static RzCmdStatus show_regs_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, const char *filter, RzCmdStateOutput *state)
Definition: cmd_regs.c:219
RZ_IPI RzCmdStatus rz_reg_arenas_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:483
RZ_IPI RzCmdStatus rz_regs_prev_handler(RzCore *core, RzReg *reg, int argc, const char **argv, RzCmdStateOutput *state)
Definition: cmd_regs.c:816
RZ_IPI RzCmdStatus rz_regs_references_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, RzOutputMode mode)
Definition: cmd_regs.c:392
HEAPTYPE(ut64)
static int valgroup_regcmp(const void *a, const void *b)
Definition: cmd_regs.c:404
RZ_IPI RzCmdStatus rz_reg_arenas_pop_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv)
Definition: cmd_regs.c:511
#define SYNC_READ(type, failed)
Definition: cmd_regs.c:9
RZ_IPI RzCmdStatus rz_reg_profile_handler(RzCore *core, RzReg *reg, int argc, const char **argv, RzCmdStateOutput *state)
Definition: cmd_regs.c:699
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.
Definition: cmd_regs.c:87
static bool reg_has_changed(RzReg *reg, RzRegItem *item)
Check whether the given item's value has changed in the last step.
Definition: cmd_regs.c:116
RZ_IPI RzCmdStatus rz_reg_cc_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:797
RZ_IPI RzCmdStatus rz_reg_arenas_stack_size_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:567
RZ_IPI RzCmdStatus rz_reg_profile_open_handler(RzCore *core, RzReg *reg, int argc, const char **argv)
Definition: cmd_regs.c:756
RZ_IPI RzCmdStatus rz_reg_flags_handler(RzCore *core, RzReg *reg, RzCmdRegSync sync_cb, int argc, const char **argv, bool unset)
Definition: cmd_regs.c:658
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
Definition: config.c:419
RZ_API void rz_cons_strcat(const char *str)
Definition: cons.c:1263
RZ_API void rz_cons_newline(void)
Definition: cons.c:1274
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API void rz_cons_println(const char *str)
Definition: cons.c:233
#define RZ_API
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)
Definition: cprint.c:161
RZ_IPI RzList * rz_core_reg_flags_candidates(RzCore *core, RzReg *reg)
Definition: creg.c:60
RZ_IPI void rz_core_reg_print_diff(RzReg *reg, RzList *items)
Print registers that have changed since the last step (drd/ard)
Definition: creg.c:116
#define NULL
Definition: cris-opc.c:27
#define r
Definition: crypto_rc6.c:12
RZ_API bool rz_reg_set_double(RzReg *reg, RzRegItem *item, double value)
Definition: double.c:40
RZ_API long double rz_reg_get_longdouble(RzReg *reg, RzRegItem *item)
Definition: double.c:67
const char * k
Definition: dsignal.c:11
const char * v
Definition: dsignal.c:12
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
const char int mode
Definition: ioapi.h:137
voidpf void * buf
Definition: ioapi.h:138
snprintf
Definition: kernel.h:364
#define reg(n)
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
RZ_API RzTable * rz_core_table(RzCore *core)
Definition: core.c:3449
RZ_API char * rz_core_analysis_hasrefs(RzCore *core, ut64 value, int mode)
Definition: core.c:1805
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API RZ_OWN RzList * rz_list_clone(RZ_NONNULL const RzList *list)
Shallow copies of the list (but doesn't free its elements)
Definition: list.c:496
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.
Definition: list.c:260
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
Definition: list.c:235
RZ_API RZ_BORROW RzListIter * rz_list_push(RZ_NONNULL RzList *list, void *item)
Alias for rz_list_append.
Definition: list.c:60
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
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.
Definition: list.c:518
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
void * malloc(size_t size)
Definition: malloc.c:123
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
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")
int n
Definition: mipsasm.c:19
int type
Definition: mipsasm.c:17
int idx
Definition: setup.py:197
static const char hex[16]
Definition: print.c:21
RZ_API char * rz_reg_parse_gdb_profile(const char *profile_file)
Definition: profile.c:631
RZ_API bool rz_reg_set_profile(RzReg *reg, const char *profile)
Definition: profile.c:486
RZ_API char * rz_reg_profile_to_cc(RzReg *reg)
Definition: profile.c:652
RZ_API int rz_reg_cond_bits(RzReg *r, int type, RzRegFlags *f)
Definition: rcond.c:102
RZ_API RzRegFlags * rz_reg_cond_retrieve(RzReg *r, RzRegFlags *f)
Definition: rcond.c:219
RZ_API const char * rz_reg_cond_to_string(int n)
Definition: rcond.c:48
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
Definition: reg.c:344
RZ_API const char * rz_reg_get_name(RzReg *reg, int role)
Definition: reg.c:147
RZ_API int rz_reg_role_by_name(RZ_NONNULL const char *str)
Get the RzRegisterId with the given name or -1.
Definition: reg.c:180
RZ_API int rz_reg_type_by_name(const char *str)
Returns the register type for the given type abbreviation.
Definition: reg.c:83
RZ_API const char * rz_reg_get_type(int idx)
Definition: reg.c:68
RZ_API const char * rz_reg_get_role(int role)
Definition: reg.c:172
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.
Definition: reg.c:489
#define eprintf(x, y...)
Definition: rlcc.c:7
static RzSocket * s
Definition: rtr.c:28
RZ_API ut64 rz_reg_get_value_big(RzReg *reg, RzRegItem *item, utX *val)
Definition: rvalue.c:60
RZ_API bool rz_reg_set_value(RzReg *reg, RzRegItem *item, ut64 value)
Definition: rvalue.c:186
RZ_API ut64 rz_reg_get_value(RzReg *reg, RzRegItem *item)
Definition: rvalue.c:114
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
enum rz_cmd_status_t RzCmdStatus
@ RZ_CMD_STATUS_OK
command handler exited in the right way
Definition: rz_cmd.h:24
@ RZ_CMD_STATUS_WRONG_ARGS
command handler could not handle the arguments passed to it
Definition: rz_cmd.h:25
@ RZ_CMD_STATUS_ERROR
command handler had issues while running (e.g. allocation error, etc.)
Definition: rz_cmd.h:26
#define Color_RESET
Definition: rz_cons.h:617
#define Color_BWHITE
Definition: rz_cons.h:644
#define Color_YELLOW
Definition: rz_cons.h:631
#define RZ_FLAGS_FS_REGISTERS
Definition: rz_core.h:61
RZ_API int rz_hex_str2bin(const char *in, ut8 *out)
Convert an input string in into the binary form in out.
Definition: hex.c:444
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API ut64 rz_num_math(RzNum *num, const char *str)
Definition: unum.c:456
RZ_API PJ * pj_k(PJ *j, const char *k)
Definition: pj.c:104
RZ_API PJ * pj_end(PJ *j)
Definition: pj.c:87
RZ_API PJ * pj_o(PJ *j)
Definition: pj.c:75
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
Definition: pj.c:170
RZ_API PJ * pj_kn(PJ *j, const char *k, ut64 n)
Definition: pj.c:121
RZ_API PJ * pj_a(PJ *j)
Definition: pj.c:81
RzRegisterType
Definition: rz_reg.h:20
@ RZ_REG_TYPE_GPR
Definition: rz_reg.h:21
@ RZ_REG_TYPE_LAST
Definition: rz_reg.h:34
@ RZ_REG_TYPE_ANY
Definition: rz_reg.h:35
@ RZ_REG_TYPE_FPU
Definition: rz_reg.h:23
#define RZ_REG_COND_LAST
Definition: rz_reg.h:93
@ RZ_REG_NAME_A9
Definition: rz_reg.h:58
@ RZ_REG_NAME_LAST
Definition: rz_reg.h:71
@ RZ_REG_NAME_A0
Definition: rz_reg.h:49
static const char * rz_str_get(const char *str)
Definition: rz_str.h:187
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_trim_dup(const char *str)
Definition: str_trim.c:78
#define RZ_STR_ISEMPTY(x)
Definition: rz_str.h:67
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.
Definition: str_trim.c:190
RZ_API void rz_table_add_rowf(RzTable *t, const char *fmt,...)
Definition: table.c:316
RZ_API RZ_OWN char * rz_table_tojson(RzTable *t)
Convert RzTable to json format.
Definition: table.c:626
RZ_API void rz_table_free(RzTable *t)
Definition: table.c:114
RZ_API void rz_table_set_columnsf(RzTable *t, const char *fmt,...)
Specify the types and names of the referenced table.
Definition: table.c:234
RZ_API char * rz_table_tostring(RzTable *t)
Definition: table.c:510
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NONNULL
Definition: rz_types.h:64
RzOutputMode
Enum to describe the way data are printed.
Definition: rz_types.h:38
@ RZ_OUTPUT_MODE_TABLE
Definition: rz_types.h:46
@ RZ_OUTPUT_MODE_JSON
Definition: rz_types.h:40
@ RZ_OUTPUT_MODE_QUIET
Definition: rz_types.h:42
@ RZ_OUTPUT_MODE_RIZIN
Definition: rz_types.h:41
@ RZ_OUTPUT_MODE_STANDARD
Definition: rz_types.h:39
#define PFMT64x
Definition: rz_types.h:393
#define RZ_MIN(x, y)
#define RZ_MAX(x, y)
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41
st64 High
Definition: rz_types_base.h:53
ut64 Low
Definition: rz_types_base.h:52
ut128 Low
Definition: rz_types_base.h:56
ut128 High
Definition: rz_types_base.h:57
ut16 High
Definition: rz_types_base.h:45
ut64 Low
Definition: rz_types_base.h:44
ut64 Low
Definition: rz_types_base.h:48
ut32 High
Definition: rz_types_base.h:49
ut256 v256
Definition: rz_types_base.h:63
ut80 v80
Definition: rz_types_base.h:60
ut128 v128
Definition: rz_types_base.h:62
ut96 v96
Definition: rz_types_base.h:61
Definition: z80asm.h:102
Definition: rz_pj.h:12
int bits
Definition: rz_asm.h:100
Represent the output state of a command handler.
Definition: rz_cmd.h:91
RzConsPrintablePalette pal
Definition: rz_cons.h:491
RzConsContext * context
Definition: rz_cons.h:502
RzCons * cons
Definition: rz_core.h:312
RzAsm * rasm
Definition: rz_core.h:323
RzNum * num
Definition: rz_core.h:316
RzConfig * config
Definition: rz_core.h:300
ut64 value
Definition: rz_num.h:63
RzRegisterType type
Register type.
Definition: rz_reg.h:119
int size
in bits> 8,16,32,64 ... 128/256
Definition: rz_reg.h:120
char * name
Definition: rz_reg.h:118
Definition: dis.h:43
void error(const char *msg)
Definition: untgz.c:593
static int color
Definition: visual.c:20
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58