Rizin
unix-like reverse engineering framework and cli tools
cdebug.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2009-2020 pancake <pancake@nopcode.org>
2 // SPDX-FileCopyrightText: 2021 Anton Kochkov <anton.kochkov@gmail.com>
3 // SPDX-FileCopyrightText: 2021 ret2libc <sirmy15@gmail.com>
4 // SPDX-License-Identifier: LGPL-3.0-only
5 
6 #include <rz_core.h>
7 #include <rz_debug.h>
8 #include "core_private.h"
9 
14  return core->bin->is_debugger;
15 }
16 
17 static bool is_x86_call(RzDebug *dbg, ut64 addr) {
18  ut8 buf[3];
19  ut8 *op = buf;
21  switch (buf[0]) { /* Segment override prefixes */
22  case 0x65:
23  case 0x64:
24  case 0x26:
25  case 0x3e:
26  case 0x36:
27  case 0x2e:
28  op++;
29  }
30  if (op[0] == 0xe8) {
31  return true;
32  }
33  if (op[0] == 0xff /* bits 4-5 (from right) of next byte must be 01 */
34  && (op[1] & 0x30) == 0x10) {
35  return true;
36  }
37  /* ... */
38  return false;
39 }
40 
41 static bool is_x86_ret(RzDebug *dbg, ut64 addr) {
42  ut8 buf[1];
44  switch (buf[0]) {
45  case 0xc3:
46  case 0xcb:
47  case 0xc2:
48  case 0xca:
49  return true;
50  default:
51  return false;
52  }
53  /* Possibly incomplete with regard to instruction prefixes */
54 }
55 
57  if (rz_core_is_debug(core)) {
58  rz_reg_arena_swap(core->dbg->reg, true);
59  // sync registers for BSD PT_STEP/PT_CONT
60  rz_debug_reg_sync(core->dbg, RZ_REG_TYPE_GPR, false);
61  ut64 pc = rz_debug_reg_get(core->dbg, "PC");
62  rz_debug_trace_pc(core->dbg, pc);
63  if (!rz_debug_step(core->dbg, times)) {
64  eprintf("Step failed\n");
66  core->break_loop = true;
67  return false;
68  }
70  } else {
71  int i = 0;
72  do {
73  rz_core_esil_step(core, UT64_MAX, NULL, NULL, false);
75  i++;
76  } while (i < times);
77  }
78  return true;
79 }
80 
82  if (rz_core_is_debug(core)) {
84  rz_reg_arena_swap(core->dbg->reg, true);
85 #if __linux__
86  core->dbg->continue_all_threads = true;
87 #endif
88  rz_debug_continue(core->dbg);
92  } else {
93  rz_core_esil_step(core, UT64_MAX, "0", NULL, false);
95  }
96 }
97 
99  ut64 pc;
100  if (!strcmp(core->dbg->btalgo, "trace") && core->dbg->arch && !strcmp(core->dbg->arch, "x86") && core->dbg->bits == 4) {
101  unsigned long steps = 0;
102  long level = 0;
103  const char *pc_name = core->dbg->reg->name[RZ_REG_NAME_PC];
104  ut64 prev_pc = UT64_MAX;
105  bool prev_call = false;
106  bool prev_ret = false;
107  const char *sp_name = core->dbg->reg->name[RZ_REG_NAME_SP];
108  ut64 old_sp, cur_sp;
110  rz_list_free(core->dbg->call_frames);
111  core->dbg->call_frames = rz_list_new();
112  core->dbg->call_frames->free = free;
113  rz_debug_reg_sync(core->dbg, RZ_REG_TYPE_GPR, false);
114  old_sp = rz_debug_reg_get(core->dbg, sp_name);
115  while (true) {
116  rz_debug_reg_sync(core->dbg, RZ_REG_TYPE_GPR, false);
117  pc = rz_debug_reg_get(core->dbg, pc_name);
118  if (prev_call) {
119  ut32 ret_addr;
121  cur_sp = rz_debug_reg_get(core->dbg, sp_name);
122  (void)core->dbg->iob.read_at(core->dbg->iob.io, cur_sp, (ut8 *)&ret_addr,
123  sizeof(ret_addr));
124  frame->addr = ret_addr;
125  frame->size = old_sp - cur_sp;
126  frame->sp = cur_sp;
127  frame->bp = old_sp;
128  rz_list_prepend(core->dbg->call_frames, frame);
129  eprintf("%ld Call from 0x%08" PFMT64x " to 0x%08" PFMT64x " ret 0x%08" PFMT32x "\n",
130  level, prev_pc, pc, ret_addr);
131  level++;
132  old_sp = cur_sp;
133  prev_call = false;
134  } else if (prev_ret) {
136  if (head && head->addr != pc) {
137  eprintf("*");
138  } else {
140  eprintf("%ld", level);
141  level--;
142  }
143  eprintf(" Ret from 0x%08" PFMT64x " to 0x%08" PFMT64x "\n",
144  prev_pc, pc);
145  prev_ret = false;
146  }
147  if (steps % 500 == 0 || pc == addr) {
148  eprintf("At 0x%08" PFMT64x " after %lu steps\n", pc, steps);
149  }
150  if (rz_cons_is_breaked() || rz_debug_is_dead(core->dbg) || pc == addr) {
151  break;
152  }
153  if (is_x86_call(core->dbg, pc)) {
154  prev_pc = pc;
155  prev_call = true;
156  } else if (is_x86_ret(core->dbg, pc)) {
157  prev_pc = pc;
158  prev_ret = true;
159  }
160  rz_debug_step(core->dbg, 1);
161  steps++;
162  }
165  return true;
166  }
167  eprintf("Continue until 0x%08" PFMT64x "\n", addr);
168  rz_reg_arena_swap(core->dbg->reg, true);
169  if (rz_bp_add_sw(core->dbg->bp, addr, 0, RZ_PERM_X)) {
170  if (rz_debug_is_dead(core->dbg)) {
171  RZ_LOG_ERROR("Cannot continue, run ood?\n");
172  } else {
173  rz_debug_continue(core->dbg);
175  }
176  rz_bp_del(core->dbg->bp, addr);
177  } else {
178  RZ_LOG_ERROR("Cannot set breakpoint for continuing until 0x%08" PFMT64x "\n", addr);
179  return false;
180  }
181  return true;
182 }
183 
185  if (rz_core_is_debug(core)) {
186  ut64 asm_bits = rz_config_get_i(core->config, "asm.bits");
187  if (asm_bits != core->dbg->bits * 8) {
188  rz_config_set_i(core->config, "asm.bits", core->dbg->bits * 8);
189  }
190  }
191 }
192 
194  if (rz_core_is_debug(core)) {
195  if (core->print->cur_enabled) {
196  rz_core_debug_continue_until(core, core->offset, core->offset + core->print->cur);
197  core->print->cur_enabled = 0;
198  } else {
199  rz_core_debug_step_one(core, 1);
200  }
201  } else {
202  rz_core_esil_step(core, UT64_MAX, NULL, NULL, false);
204  }
205 }
206 
208  bool io_cache = rz_config_get_b(core->config, "io.cache");
209  rz_config_set_b(core->config, "io.cache", false);
210  if (rz_core_is_debug(core)) {
211  if (core->print->cur_enabled) {
213  rz_reg_arena_swap(core->dbg->reg, true);
218  core->print->cur_enabled = 0;
219  } else {
220  rz_core_debug_step_over(core, 1);
223  }
224  } else {
226  }
227  rz_config_set_b(core->config, "io.cache", io_cache);
228 }
229 
236  rz_return_if_fail(core && core->dbg);
237  RzBreakpointItem *bpi = rz_bp_get_at(core->dbg->bp, addr);
238  if (bpi) {
239  rz_bp_del(core->dbg->bp, addr);
240  } else {
241  int hwbp = (int)rz_config_get_i(core->config, "dbg.hwbp");
242  bpi = rz_debug_bp_add(core->dbg, addr, hwbp, false, 0, NULL, 0);
243  if (!bpi) {
244  eprintf("Cannot set breakpoint at 0x%" PFMT64x "\n", addr);
245  }
246  }
247  rz_bp_enable(core->dbg->bp, addr, true, 0);
248 }
249 
258  if (!symbols) {
259  RZ_LOG_ERROR("Unable to find symbols in the binary\n");
260  return;
261  }
262  RzBinSymbol *symbol;
263  RzListIter *iter;
264  RzBreakpointItem *bp;
265  int hwbp = rz_config_get_i(core->config, "dbg.hwbp");
266  rz_list_foreach (symbols, iter, symbol) {
267  if (symbol->type && !strcmp(symbol->type, RZ_BIN_TYPE_FUNC_STR)) {
268  if (rz_analysis_noreturn_at(core->analysis, symbol->vaddr)) {
269  bp = rz_debug_bp_add(core->dbg, symbol->vaddr, hwbp, false, 0, NULL, 0);
270  if (!bp) {
271  RZ_LOG_ERROR("Unable to add a breakpoint into a noreturn function %s at addr 0x%" PFMT64x "\n", symbol->name, symbol->vaddr);
272  return;
273  }
274  char *name = rz_str_newf("%s.%s", "sym", symbol->name);
275  if (!rz_bp_item_set_name(bp, name)) {
276  RZ_LOG_ERROR("Failed to set name for breakpoint at 0x%" PFMT64x "\n", symbol->vaddr);
277  }
278  free(name);
279  }
280  }
281  }
282 }
283 
285  char buf[20];
286 
288  if (pid > 0) {
289  rz_debug_attach(core->dbg, pid);
290  } else {
291  if (core->file && core->io) {
292  rz_debug_attach(core->dbg, rz_io_fd_get_pid(core->io, core->file->fd));
293  }
294  }
295  rz_debug_select(core->dbg, core->dbg->pid, core->dbg->tid);
296  rz_config_set_i(core->config, "dbg.swstep", (core->dbg->cur && !core->dbg->cur->canstep));
297  rz_io_system(core->io, rz_strf(buf, "pid %d", core->dbg->pid));
298 }
299 
301  PJ *pj = state->d.pj;
302  switch (state->mode) {
303  case RZ_OUTPUT_MODE_QUIET: {
304  rz_cons_printf("%s\n", plugin->name);
305  break;
306  }
307  case RZ_OUTPUT_MODE_JSON: {
308  pj_o(pj);
309  pj_ks(pj, "arch", plugin->arch);
310  pj_ks(pj, "name", plugin->name);
311  pj_ks(pj, "license", plugin->license);
312  pj_end(pj);
313  break;
314  }
316  rz_cons_printf("%d %s %s %s%s\n",
317  count, (plugin == dbg->cur) ? "dbg" : "---",
318  plugin->name, spaces, plugin->license);
319  break;
320  }
321  default: {
324  }
325  }
326  return RZ_CMD_STATUS_OK;
327 }
328 
330  int count = 0;
331  char spaces[16];
332  memset(spaces, ' ', 15);
333  spaces[15] = 0;
334  RzDebug *dbg = core->dbg;
335  RzListIter *iter;
336  RzDebugPlugin *plugin;
338  if (!dbg) {
339  return RZ_CMD_STATUS_ERROR;
340  }
342  rz_list_foreach (dbg->plugins, iter, plugin) {
343  int sp = 8 - strlen(plugin->name);
344  spaces[sp] = 0;
346  if (status != RZ_CMD_STATUS_OK) {
347  return status;
348  }
349  spaces[sp] = ' ';
350  count++;
351  }
353  return RZ_CMD_STATUS_OK;
354 }
355 
357  RzReg *reg = rz_core_reg_default(core);
358  RzList *ritems = rz_reg_filter_items_covered(reg->allregs);
359  if (ritems) {
360  rz_core_reg_print_diff(reg, ritems);
361  rz_list_free(ritems);
362  }
363  ut64 old_address = core->offset;
366  rz_core_seek(core, old_address, true);
367  rz_cons_flush();
368 }
369 
370 /* Print out the JSON body for memory maps in the passed map region */
371 static void print_debug_map_json(RzDebugMap *map, PJ *pj) {
372  pj_o(pj);
373  if (map->name && *map->name) {
374  pj_ks(pj, "name", map->name);
375  }
376  if (map->file && *map->file) {
377  pj_ks(pj, "file", map->file);
378  }
379  pj_kn(pj, "addr", map->addr);
380  pj_kn(pj, "addr_end", map->addr_end);
381  pj_ks(pj, "type", map->user ? "u" : "s");
382  pj_ks(pj, "perm", rz_str_rwx_i(map->perm));
383  pj_end(pj);
384 }
385 
386 /* Write a single memory map line to the console */
388  char humansz[8];
389  if (mode == RZ_OUTPUT_MODE_QUIET) { // "dmq"
390  char *name = (map->name && *map->name)
391  ? rz_str_newf("%s.%s", map->name, rz_str_rwx_i(map->perm))
392  : rz_str_newf("%08" PFMT64x ".%s", map->addr, rz_str_rwx_i(map->perm));
393  rz_name_filter(name, 0, true);
394  rz_num_units(humansz, sizeof(humansz), map->addr_end - map->addr);
395  rz_cons_printf("0x%016" PFMT64x " - 0x%016" PFMT64x " %6s %5s %s\n",
396  map->addr,
397  map->addr_end,
398  humansz,
399  rz_str_rwx_i(map->perm),
400  name);
401  free(name);
402  } else {
403  const char *fmtstr = dbg->bits & RZ_SYS_BITS_64
404  ? "0x%016" PFMT64x " - 0x%016" PFMT64x " %c %s %6s %c %s %s %s%s%s\n"
405  : "0x%08" PFMT64x " - 0x%08" PFMT64x " %c %s %6s %c %s %s %s%s%s\n";
406  const char *type = map->shared ? "sys" : "usr";
407  const char *flagname = dbg->corebind.getName
408  ? dbg->corebind.getName(dbg->corebind.core, map->addr)
409  : NULL;
410  if (!flagname) {
411  flagname = "";
412  } else if (map->name) {
413  char *filtered_name = strdup(map->name);
414  rz_name_filter(filtered_name, 0, true);
415  if (!strncmp(flagname, "map.", 4) &&
416  !strcmp(flagname + 4, filtered_name)) {
417  flagname = "";
418  }
419  free(filtered_name);
420  }
421  rz_num_units(humansz, sizeof(humansz), map->size);
422  rz_cons_printf(fmtstr,
423  map->addr,
424  map->addr_end,
425  (addr >= map->addr && addr < map->addr_end) ? '*' : '-',
426  type,
427  humansz,
428  map->user ? 'u' : 's',
429  rz_str_rwx_i(map->perm),
430  map->name ? map->name : "?",
431  map->file ? map->file : "?",
432  *flagname ? " ; " : "",
433  flagname);
434  }
435 }
436 
437 static void apply_maps_as_flags(RzCore *core, RzList /*<RzDebugMap *>*/ *maps, bool print_only) {
438  RzListIter *iter;
439  RzDebugMap *map;
440  rz_list_foreach (maps, iter, map) {
441  char *name = (map->name && *map->name)
442  ? rz_str_newf("%s.%s", map->name, rz_str_rwx_i(map->perm))
443  : rz_str_newf("%08" PFMT64x ".%s", map->addr, rz_str_rwx_i(map->perm));
444  if (!name) {
445  continue;
446  }
447  rz_name_filter(name, 0, true);
448  ut64 size = map->addr_end - map->addr;
449  if (print_only) {
450  rz_cons_printf("f+ map.%s 0x%08" PFMT64x " @ 0x%08" PFMT64x "\n",
451  name, size, map->addr);
452  } else {
453  rz_flag_set_next(core->flags, name, map->addr, size);
454  }
455  free(name);
456  }
457 }
458 
463  rz_return_if_fail(core);
465  if (rz_debug_is_dead(core->dbg)) {
466  return;
467  }
468  rz_debug_map_sync(core->dbg);
469  rz_flag_space_push(core->flags, RZ_FLAGS_FS_DEBUG_MAPS);
470  RzList *maps = rz_debug_map_list(core->dbg, false);
471  if (maps) {
472  apply_maps_as_flags(core, maps, false);
473  }
474  maps = rz_debug_map_list(core->dbg, true);
475  if (maps) {
476  apply_maps_as_flags(core, maps, false);
477  }
478  rz_flag_space_pop(core->flags);
479 }
480 
482  rz_return_if_fail(core);
483  int i;
484  RzListIter *iter;
485  RzDebugMap *map;
486  PJ *pj = state->d.pj;
487  RzDebug *dbg = core->dbg;
488  if (!dbg) {
489  return;
490  }
491  RzOutputMode mode = state->mode;
493  if (mode == RZ_OUTPUT_MODE_RIZIN) {
494  rz_cons_print("fss+ " RZ_FLAGS_FS_DEBUG_MAPS "\n");
495  }
496  for (i = 0; i < 2; i++) { // Iterate over dbg::maps and dbg::maps_user
497  RzList *maps = rz_debug_map_list(dbg, (bool)i);
498  if (!maps) {
499  continue;
500  }
501  if (mode == RZ_OUTPUT_MODE_RIZIN) { // "dm*"
502  apply_maps_as_flags(core, maps, true);
503  continue;
504  }
505  rz_list_foreach (maps, iter, map) {
506  switch (mode) {
507  case RZ_OUTPUT_MODE_JSON: // "dmj"
509  break;
510  case RZ_OUTPUT_MODE_QUIET: // "dmq"
512  break;
513  case RZ_OUTPUT_MODE_LONG: // workaround for '.'
514  if (addr >= map->addr && addr < map->addr_end) {
516  }
517  break;
518  default:
520  break;
521  }
522  }
523  }
524  if (mode == RZ_OUTPUT_MODE_RIZIN) {
525  rz_cons_print("fss-\n");
526  }
528 }
529 
530 static int cmp(const void *a, const void *b) {
531  RzDebugMap *ma = (RzDebugMap *)a;
532  RzDebugMap *mb = (RzDebugMap *)b;
533  return ma->addr - mb->addr;
534 }
535 
548 static int findMinMax(RzList *maps, ut64 *min, ut64 *max, int skip, int width) {
549  RzDebugMap *map;
550  RzListIter *iter;
551  *min = UT64_MAX;
552  *max = 0;
553  rz_list_foreach (maps, iter, map) {
554  if (skip > 0) {
555  skip--;
556  continue;
557  }
558  if (map->addr < *min) {
559  *min = map->addr;
560  }
561  if (map->addr_end > *max) {
562  *max = map->addr_end;
563  }
564  }
565  return (int)(*max - *min) / width;
566 }
567 
569  ut64 mul; // The amount of address space a single console column will represent in bar graph
570  ut64 min = -1, max = 0;
571  int width = rz_cons_get_size(NULL) - 90;
572  RzListIter *iter;
573  RzDebugMap *map;
575  if (width < 1) {
576  width = 30;
577  }
579  mul = findMinMax(maps, &min, &max, 0, width);
580  ut64 last = min;
581  if (min != -1 && mul != 0) {
582  const char *color_prefix = ""; // Color escape code prefixed to string (address coloring)
583  const char *color_suffix = ""; // Color escape code appended to end of string
584  const char *fmtstr;
585  char humansz[8]; // Holds the human formatted size string [124K]
586  int skip = 0; // Number of maps to skip when re-calculating the minmax
587  rz_list_foreach (maps, iter, map) {
588  rz_num_units(humansz, sizeof(humansz), map->size); // Convert map size to human readable string
589  if (colors) {
590  color_suffix = Color_RESET;
591  if ((map->perm & 2) && (map->perm & 1)) { // Writable & Executable
592  color_prefix = pal->widget_sel;
593  } else if (map->perm & 2) { // Writable
594  color_prefix = pal->graph_false;
595  } else if (map->perm & 1) { // Executable
596  color_prefix = pal->graph_true;
597  } else {
598  color_prefix = "";
599  color_suffix = "";
600  }
601  } else {
602  color_prefix = "";
603  color_suffix = "";
604  }
605  if ((map->addr - last) > UT32_MAX) { // TODO: Comment what this is for
606  mul = findMinMax(maps, &min, &max, skip, width); // Recalculate minmax
607  }
608  skip++;
609  fmtstr = dbg->bits & RZ_SYS_BITS_64 // Prefix formatting string (before bar)
610  ? "map %4.8s %c %s0x%016" PFMT64x "%s |"
611  : "map %4.8s %c %s0x%08" PFMT64x "%s |";
612  rz_cons_printf(fmtstr, humansz,
613  (addr >= map->addr &&
614  addr < map->addr_end)
615  ? '*'
616  : '-',
617  color_prefix, map->addr, color_suffix); // * indicates map is within our current sought offset
618  int col;
619  for (col = 0; col < width; col++) { // Iterate over the available width/columns for bar graph
620  ut64 pos = min + (col * mul); // Current address space to check
621  ut64 npos = min + ((col + 1) * mul); // Next address space to check
622  if (map->addr < npos && map->addr_end > pos) {
623  rz_cons_printf("#"); // TODO: Comment what a # represents
624  } else {
625  rz_cons_printf("-");
626  }
627  }
628  fmtstr = dbg->bits & RZ_SYS_BITS_64 ? // Suffix formatting string (after bar)
629  "| %s0x%016" PFMT64x "%s %s %s\n"
630  : "| %s0x%08" PFMT64x "%s %s %s\n";
631  rz_cons_printf(fmtstr, color_prefix, map->addr_end, color_suffix,
632  rz_str_rwx_i(map->perm), map->name);
633  last = map->addr;
634  }
635  }
636 }
637 
639  if (!dbg) {
640  return;
641  }
642  int i;
643  for (i = 0; i < 2; i++) { // Iterate over dbg::maps and dbg::maps_user
644  RzList *maps = rz_debug_map_list(dbg, (bool)i);
645  if (!maps) {
646  continue;
647  }
649  }
650 }
651 
660  int tag = dbg->trace->tag;
661  RzListIter *iter;
662  RzDebugTracepoint *trace;
663  rz_list_foreach (dbg->trace->traces, iter, trace) {
664  if (trace->tag && !(tag & trace->tag)) {
665  continue;
666  }
667  switch (state->mode) {
669  rz_cons_printf("0x%" PFMT64x "\n", trace->addr);
670  break;
672  rz_cons_printf("dt+ 0x%" PFMT64x " %d\n", trace->addr, trace->times);
673  break;
675  default:
676  rz_cons_printf("0x%08" PFMT64x " size=%d count=%d times=%d tag=%d\n",
677  trace->addr, trace->size, trace->count, trace->times, trace->tag);
678  break;
679  }
680  }
681 }
682 
690  RzList *info_list = rz_debug_traces_info(dbg, offset);
691  RzTable *table = rz_table_new();
692  table->cons = rz_cons_singleton();
693  rz_table_visual_list(table, info_list, offset, 1,
695  char *s = rz_table_tostring(table);
696  rz_cons_printf("\n%s\n", s);
697  free(s);
698  rz_table_free(table);
699  rz_list_free(info_list);
700 }
701 
708  rz_return_val_if_fail(core && core->dbg, false);
709  RzDebug *dbg = core->dbg;
710  // Stop trace session
711  if (dbg->session) {
713  dbg->session = NULL;
714  }
715 #ifndef SIGKILL
716 #define SIGKILL 9
717 #endif
718  // Kill debugee and all child processes
719  if (dbg->cur && dbg->cur->pids && dbg->pid != -1) {
720  RzList *list = dbg->cur->pids(dbg, dbg->pid);
721  RzListIter *iter;
722  RzDebugPid *p;
723  if (list) {
724  rz_list_foreach (list, iter, p) {
725  rz_debug_kill(dbg, p->pid, p->pid, SIGKILL);
726  rz_debug_detach(dbg, p->pid);
727  }
728  } else {
731  }
732  }
733  // Remove the target's registers from the flag list
735  // Reopen and rebase the original file
736  rz_core_io_file_open(core, core->io->desc->fd);
737  return true;
738 }
739 
746  rz_return_val_if_fail(core && core->dbg, false);
747  int maxLoops = 200000;
748  ut64 off, now = rz_debug_reg_get(core->dbg, "SP");
750  do {
751  if (rz_cons_is_breaked()) {
752  break;
753  }
754  if (rz_debug_is_dead(core->dbg)) {
755  break;
756  }
757  // XXX (HACK!)
758  rz_debug_step_over(core->dbg, 1);
759  off = rz_debug_reg_get(core->dbg, "SP");
760  // check breakpoint here
761  if (--maxLoops < 0) {
762  RZ_LOG_INFO("step loop limit exceeded\n");
763  break;
764  }
765  } while (off <= now);
768  return true;
769 }
770 
777 RZ_API bool rz_core_debug_step_back(RzCore *core, int steps) {
778  if (!rz_core_is_debug(core)) {
779  if (!rz_core_esil_step_back(core)) {
780  RZ_LOG_ERROR("cannot step back\n");
781  return false;
782  }
783  return true;
784  }
785  if (!core->dbg->session) {
786  RZ_LOG_ERROR("session has not started\n");
787  return false;
788  }
789  if (rz_debug_step_back(core->dbg, steps) < 0) {
790  RZ_LOG_ERROR("stepping back failed\n");
791  return false;
792  }
794  return true;
795 }
796 
802 RZ_API bool rz_core_debug_step_over(RzCore *core, int steps) {
803  if (rz_config_get_i(core->config, "dbg.skipover")) {
804  rz_core_debug_step_skip(core, steps);
805  return true;
806  }
807  if (!rz_core_is_debug(core)) {
808  for (int i = 0; i < steps; i++) {
810  }
811  return true;
812  }
813  bool hwbp = rz_config_get_b(core->config, "dbg.hwbp");
814  ut64 addr = rz_debug_reg_get(core->dbg, "PC");
815  RzBreakpointItem *bpi = rz_bp_get_at(core->dbg->bp, addr);
816  rz_bp_del(core->dbg->bp, addr);
817  rz_reg_arena_swap(core->dbg->reg, true);
818  rz_debug_step_over(core->dbg, steps);
819  if (bpi) {
820  (void)rz_debug_bp_add(core->dbg, addr, hwbp, false, 0, NULL, 0);
821  }
823  return true;
824 }
825 
832  bool hwbp = rz_config_get_b(core->config, "dbg.hwbp");
833  ut64 addr = rz_debug_reg_get(core->dbg, "PC");
834  ut8 buf[64];
835  RzAnalysisOp aop;
836  RzBreakpointItem *bpi = rz_bp_get_at(core->dbg->bp, addr);
837  rz_reg_arena_swap(core->dbg->reg, true);
838  for (int i = 0; i < times; i++) {
839  rz_debug_reg_sync(core->dbg, RZ_REG_TYPE_GPR, false);
840  rz_io_read_at(core->io, addr, buf, sizeof(buf));
841  rz_analysis_op(core->analysis, &aop, addr, buf, sizeof(buf), RZ_ANALYSIS_OP_MASK_BASIC);
842  addr += aop.size;
843  }
844  rz_debug_reg_set(core->dbg, "PC", addr);
845  rz_reg_setv(core->analysis->reg, "PC", addr);
847  if (bpi) {
848  (void)rz_debug_bp_add(core->dbg, addr, hwbp, false, 0, NULL, 0);
849  }
850  return true;
851 }
852 
854  if (!bt) {
855  return;
856  }
857  free(bt->frame);
858  free(bt->desc);
859  free(bt->pcstr);
860  free(bt->spstr);
861  free(bt->flagdesc);
862  free(bt->flagdesc2);
863  free(bt);
864 }
865 
866 static void get_backtrace_info(RzCore *core, RzDebugFrame *frame, ut64 addr,
867  char **flagdesc, char **flagdesc2, char **pcstr, char **spstr) {
868  RzFlagItem *f = rz_flag_get_at(core->flags, frame->addr, true);
869  *flagdesc = NULL;
870  *flagdesc2 = NULL;
871  if (f) {
872  if (f->offset != addr) {
873  int delta = (int)(frame->addr - f->offset);
874  if (delta > 0) {
875  *flagdesc = rz_str_newf("%s+%d", f->name, delta);
876  } else if (delta < 0) {
877  *flagdesc = rz_str_newf("%s%d", f->name, delta);
878  } else {
879  *flagdesc = rz_str_newf("%s", f->name);
880  }
881  } else {
882  *flagdesc = rz_str_newf("%s", f->name);
883  }
884  if (!strchr(f->name, '.')) {
885  f = rz_flag_get_at(core->flags, frame->addr - 1, true);
886  }
887  if (f) {
888  if (f->offset != addr) {
889  int delta = (int)(frame->addr - 1 - f->offset);
890  if (delta > 0) {
891  *flagdesc2 = rz_str_newf("%s+%d", f->name, delta + 1);
892  } else if (delta < 0) {
893  *flagdesc2 = rz_str_newf("%s%d", f->name, delta + 1);
894  } else {
895  *flagdesc2 = rz_str_newf("%s+1", f->name);
896  }
897  } else {
898  *flagdesc2 = rz_str_newf("%s", f->name);
899  }
900  }
901  }
902  if (!rz_str_cmp(*flagdesc, *flagdesc2, -1)) {
903  free(*flagdesc2);
904  *flagdesc2 = NULL;
905  }
906  if (!(pcstr && spstr)) {
907  return;
908  }
909  if (core->dbg->bits & RZ_SYS_BITS_64) {
910  *pcstr = rz_str_newf("0x%-16" PFMT64x, frame->addr);
911  *spstr = rz_str_newf("0x%-16" PFMT64x, frame->sp);
912  } else if (core->dbg->bits & RZ_SYS_BITS_32) {
913  *pcstr = rz_str_newf("0x%-8" PFMT64x, frame->addr);
914  *spstr = rz_str_newf("0x%-8" PFMT64x, frame->sp);
915  } else {
916  *pcstr = rz_str_newf("0x%" PFMT64x, frame->addr);
917  *spstr = rz_str_newf("0x%" PFMT64x, frame->sp);
918  }
919 }
920 
926 RZ_API RZ_OWN RzList /*<RzBacktrace *>*/ *rz_core_debug_backtraces(RzCore *core) {
928  if (!list) {
929  return NULL;
930  }
931  RzListIter *iter;
932  RzDebugFrame *frame;
934  if (!bts) {
936  return NULL;
937  }
938  rz_list_foreach (list, iter, frame) {
940  if (!bt) {
942  rz_list_free(bts);
943  return NULL;
944  }
945  rz_list_append(bts, bt);
946  get_backtrace_info(core, frame, UT64_MAX, &bt->flagdesc, &bt->flagdesc2, &bt->pcstr, &bt->spstr);
947  bt->fcn = rz_analysis_get_fcn_in(core->analysis, frame->addr, 0);
948  bt->frame = RZ_NEWCOPY(RzDebugFrame, frame);
950  }
952  return bts;
953 }
RZ_API bool rz_analysis_noreturn_at(RzAnalysis *analysis, ut64 addr)
Definition: analysis.c:597
#define PFMT32x
#define RZ_IPI
Definition: analysis_wasm.c:11
lzma_index ** i
Definition: index.h:629
RZ_API void rz_reg_arena_swap(RzReg *reg, int copy)
Definition: arena.c:196
static RzILOpEffect * mul(cs_insn *insn, bool is_thumb)
Definition: arm_il32.c:539
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_symbols(RZ_NONNULL RzBin *bin)
Definition: bin.c:696
static RzList * maps(RzBinFile *bf)
Definition: bin_bf.c:116
RzList * symbols(RzBinFile *bf)
Definition: bin_ne.c:102
RZ_API RZ_BORROW RzBreakpointItem * rz_bp_get_at(RZ_NONNULL RzBreakpoint *bp, ut64 addr)
Get the breakpoint at exactly addr.
Definition: bp.c:102
RZ_API bool rz_bp_del(RzBreakpoint *bp, ut64 addr)
Definition: bp.c:315
RZ_API RzBreakpointItem * rz_bp_enable(RzBreakpoint *bp, ut64 addr, int set, int count)
Definition: bp.c:152
RZ_API bool rz_bp_item_set_name(RZ_NONNULL RzBreakpointItem *item, RZ_NULLABLE const char *name)
set the name for a RzBreakpointItem
Definition: bp.c:489
RZ_API RZ_BORROW RzBreakpointItem * rz_bp_add_sw(RZ_NONNULL RzBreakpoint *bp, ut64 addr, int size, int perm)
Add a software breakpoint size preferred size of the breakpoint, or 0 to determine automatically.
Definition: bp.c:280
RZ_API void rz_core_debug_bp_add_noreturn_func(RzCore *core)
Put a breakpoint into every no-return function.
Definition: cdebug.c:256
RZ_API RzCmdStatus rz_core_debug_plugin_print(RzDebug *dbg, RzDebugPlugin *plugin, RzCmdStateOutput *state, int count, char *spaces)
Definition: cdebug.c:300
static void print_debug_maps_ascii_art(RzDebug *dbg, RzList *maps, ut64 addr, int colors)
Definition: cdebug.c:568
RZ_API void rz_core_debug_map_print(RzCore *core, ut64 addr, RzCmdStateOutput *state)
Definition: cdebug.c:481
RZ_API void rz_backtrace_free(RZ_NULLABLE RzBacktrace *bt)
Definition: cdebug.c:853
static void print_debug_map_line(RzDebug *dbg, RzDebugMap *map, ut64 addr, RzOutputMode mode)
Definition: cdebug.c:387
RZ_API bool rz_core_debug_step_over(RzCore *core, int steps)
Step over.
Definition: cdebug.c:802
RZ_API void rz_core_debug_breakpoint_toggle(RZ_NONNULL RzCore *core, ut64 addr)
Toggle breakpoint.
Definition: cdebug.c:235
static bool is_x86_ret(RzDebug *dbg, ut64 addr)
Definition: cdebug.c:41
RZ_API bool rz_core_debug_step_skip(RzCore *core, int times)
Skip operations.
Definition: cdebug.c:831
RZ_API bool rz_core_debug_step_back(RzCore *core, int steps)
Step back.
Definition: cdebug.c:777
static bool is_x86_call(RzDebug *dbg, ut64 addr)
Definition: cdebug.c:17
static int cmp(const void *a, const void *b)
Definition: cdebug.c:530
RZ_IPI void rz_core_debug_print_status(RzCore *core)
Definition: cdebug.c:356
RZ_IPI void rz_core_debug_continue(RzCore *core)
Definition: cdebug.c:81
static void print_debug_map_json(RzDebugMap *map, PJ *pj)
Definition: cdebug.c:371
RZ_API bool rz_core_debug_step_until_frame(RzCore *core)
Step until end of frame.
Definition: cdebug.c:745
static void get_backtrace_info(RzCore *core, RzDebugFrame *frame, ut64 addr, char **flagdesc, char **flagdesc2, char **pcstr, char **spstr)
Definition: cdebug.c:866
RZ_API void rz_debug_trace_print(RzDebug *dbg, RzCmdStateOutput *state, ut64 offset)
Definition: cdebug.c:658
RZ_IPI void rz_core_debug_sync_bits(RzCore *core)
Definition: cdebug.c:184
RZ_API void rz_debug_map_list_visual(RzDebug *dbg, ut64 addr, const char *input, int colors)
Definition: cdebug.c:638
RZ_API RZ_OWN RzList * rz_core_debug_backtraces(RzCore *core)
Get backtraces based on dbg.btdepth and dbg.btalgo.
Definition: cdebug.c:926
RZ_API void rz_debug_traces_ascii(RzDebug *dbg, ut64 offset)
Definition: cdebug.c:688
static void apply_maps_as_flags(RzCore *core, RzList *maps, bool print_only)
Definition: cdebug.c:437
RZ_API bool rz_core_is_debug(RzCore *core)
Check whether the core is in debug mode (equivalent to cfg.debug)
Definition: cdebug.c:13
RZ_API bool rz_core_debug_continue_until(RzCore *core, ut64 addr, ut64 to)
Definition: cdebug.c:98
RZ_IPI void rz_core_debug_single_step_in(RzCore *core)
Definition: cdebug.c:193
RZ_API bool rz_core_debug_process_close(RzCore *core)
Close debug process (Kill debugee and all child processes)
Definition: cdebug.c:707
RZ_API void rz_core_debug_map_update_flags(RzCore *core)
Definition: cdebug.c:462
RZ_API RzCmdStatus rz_core_debug_plugins_print(RzCore *core, RzCmdStateOutput *state)
Definition: cdebug.c:329
#define SIGKILL
RZ_IPI void rz_core_debug_attach(RzCore *core, int pid)
Definition: cdebug.c:284
static int findMinMax(RzList *maps, ut64 *min, ut64 *max, int skip, int width)
Find the min and max addresses in an RzList of maps.
Definition: cdebug.c:548
RZ_IPI void rz_core_debug_single_step_over(RzCore *core)
Definition: cdebug.c:207
RZ_API bool rz_core_debug_step_one(RzCore *core, int times)
Definition: cdebug.c:56
RZ_API void rz_core_io_file_open(RZ_NONNULL RzCore *core, int fd)
Open file use read-only Permission.
Definition: cfile.c:1601
RZ_API void rz_core_analysis_esil_step_over(RZ_NONNULL RzCore *core)
Definition: cil.c:269
RZ_API int rz_core_esil_step_back(RzCore *core)
RZ_API int rz_core_esil_step(RzCore *core, ut64 until_addr, const char *until_expr, ut64 *prev_addr, bool stepOver)
Definition: cmd_analysis.c:860
RZ_API void rz_cmd_state_output_array_start(RzCmdStateOutput *state)
Mark the start of an array of elements in the output.
Definition: cmd_api.c:2558
RZ_API void rz_cmd_state_output_array_end(RzCmdStateOutput *state)
Mark the end of an array of elements in the output.
Definition: cmd_api.c:2572
RZ_IPI void rz_core_static_debug_stop(void *u)
Definition: cmd_debug.c:1565
RZ_API void rz_core_dbg_follow_seek_register(RzCore *core)
Seek to PC if needed.
Definition: cmd_debug.c:474
RZ_API void rz_core_debug_clear_register_flags(RzCore *core)
Definition: cmd_debug.c:1449
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:142
RZ_API RzConfigNode * rz_config_set_i(RzConfig *cfg, RZ_NONNULL const char *name, const ut64 i)
Definition: config.c:419
RZ_API RzConfigNode * rz_config_set_b(RzConfig *cfg, RZ_NONNULL const char *name, bool value)
Definition: config.c:201
RZ_API int rz_cons_get_size(int *rows)
Definition: cons.c:1446
RZ_API RzCons * rz_cons_singleton(void)
Definition: cons.c:300
RZ_API void rz_cons_break_pop(void)
Definition: cons.c:361
RZ_API void rz_cons_break_push(RzConsBreak cb, void *user)
Definition: cons.c:357
RZ_API int rz_cons_printf(const char *format,...)
Definition: cons.c:1202
RZ_API void rz_cons_flush(void)
Definition: cons.c:959
RZ_API bool rz_cons_is_breaked(void)
Definition: cons.c:373
#define RZ_API
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
RZ_API void rz_core_reg_update_flags(RzCore *core)
Update or create flags for all registers where it makes sense.
Definition: creg.c:106
RZ_API RzReg * rz_core_reg_default(RzCore *core)
Get the currently relevant RzReg.
Definition: creg.c:17
#define NULL
Definition: cris-opc.c:27
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 static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
uint32_t ut32
RzDebug * dbg
Definition: desil.c:30
RZ_API int rz_core_print_disasm_instructions(RzCore *core, int nb_bytes, int nb_opcodes)
Definition: disasm.c:6030
RZ_API RZ_BORROW RzList * rz_debug_map_list(RzDebug *dbg, bool user_map)
Get RzList* of memory maps for the process currently being debugged.
Definition: dmap.c:98
RZ_API bool rz_debug_map_sync(RzDebug *dbg)
Definition: dmap.c:33
RZ_API ut64 rz_debug_reg_get(RzDebug *dbg, const char *name)
Definition: dreg.c:99
RZ_API int rz_debug_reg_sync(RzDebug *dbg, int type, int write)
Definition: dreg.c:9
RZ_API int rz_debug_reg_set(struct rz_debug_t *dbg, const char *name, ut64 num)
Definition: dreg.c:89
RZ_API bool rz_debug_reg_profile_sync(RzDebug *dbg)
Definition: dreg.c:116
RZ_API void rz_debug_session_free(RzDebugSession *session)
Definition: dsession.c:11
int max
Definition: enough.c:225
size_t map(int syms, int left, int len)
Definition: enough.c:237
RZ_DEPRECATE RZ_API RzAnalysisFunction * rz_analysis_get_fcn_in(RzAnalysis *analysis, ut64 addr, int type)
Definition: fcn.c:1687
RZ_API void rz_flag_unset_all_in_space(RzFlag *f, const char *space_name)
Unset all flag items in the space with the given name.
Definition: flag.c:692
RZ_API RzFlagItem * rz_flag_set_next(RzFlag *f, const char *name, ut64 off, ut32 size)
Definition: flag.c:494
RZ_API RzFlagItem * rz_flag_get_at(RzFlag *f, ut64 off, bool closest)
Definition: flag.c:404
void skip(file *in, unsigned n)
Definition: gzappend.c:202
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
voidpf uLong offset
Definition: ioapi.h:144
const char int mode
Definition: ioapi.h:137
voidpf void * buf
Definition: ioapi.h:138
#define reg(n)
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
void * p
Definition: libc.cpp:67
const char * spaces(int count)
RZ_API int rz_debug_kill(RzDebug *dbg, int pid, int tid, int sig)
Definition: debug.c:1598
RZ_API int rz_debug_step_back(RzDebug *dbg, int steps)
Definition: debug.c:1121
RZ_API int rz_debug_step_over(RzDebug *dbg, int steps)
Definition: debug.c:1033
RZ_API int rz_debug_step(RzDebug *dbg, int steps)
Definition: debug.c:962
RZ_API RZ_BORROW RzBreakpointItem * rz_debug_bp_add(RZ_NONNULL RzDebug *dbg, ut64 addr, int hw, bool watch, int rw, RZ_NULLABLE const char *module, st64 m_delta)
Definition: debug.c:270
RZ_API int rz_debug_continue_until_optype(RzDebug *dbg, int type, int over)
Definition: debug.c:1345
RZ_API int rz_debug_detach(RzDebug *dbg, int pid)
Definition: debug.c:583
RZ_API int rz_debug_continue(RzDebug *dbg)
Definition: debug.c:1332
RZ_API int rz_debug_attach(RzDebug *dbg, int pid)
Definition: debug.c:445
RZ_API bool rz_debug_is_dead(RzDebug *dbg)
Definition: debug.c:1632
RZ_API bool rz_debug_select(RzDebug *dbg, int pid, int tid)
Definition: debug.c:595
RZ_API RzList * rz_debug_frames(RzDebug *dbg, ut64 at)
Definition: debug.c:1612
static void list(RzEgg *egg)
Definition: rz-gg.c:52
RZ_API RZ_BORROW RzListIter * rz_list_prepend(RZ_NONNULL RzList *list, void *data)
Appends at the beginning of the list a new element.
Definition: list.c:316
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_BORROW void * rz_list_get_bottom(RZ_NONNULL const RzList *list)
Returns the first element of the list.
Definition: list.c:467
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 void rz_list_sort(RZ_NONNULL RzList *list, RZ_NONNULL RzListComparator cmp)
Sorts via merge sort or via insertion sort a list.
Definition: list.c:743
RZ_API RZ_OWN void * rz_list_pop_head(RZ_NONNULL RzList *list)
Removes and returns the first element of the list.
Definition: list.c:401
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 void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd times
Definition: sflib.h:70
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
Definition: sflib.h:64
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 struct stat static buf struct stat static buf static vhangup int status
Definition: sflib.h:145
int type
Definition: mipsasm.c:17
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
Definition: op.c:96
int off
Definition: pal.c:13
struct @219 colors[]
#define min(a, b)
Definition: qsort.h:83
RZ_API ut64 rz_reg_setv(RzReg *reg, const char *name, ut64 val)
Definition: reg.c:326
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_by_role(RzReg *reg, RzRegisterId role)
Definition: rvalue.c:181
@ RZ_ANALYSIS_OP_MASK_BASIC
Definition: rz_analysis.h:440
@ RZ_ANALYSIS_OP_TYPE_RET
Definition: rz_analysis.h:385
#define rz_warn_if_reached()
Definition: rz_assert.h:29
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
#define RZ_BIN_TYPE_FUNC_STR
Definition: rz_bin.h:119
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_NONEXISTINGCMD
command does not exist
Definition: rz_cmd.h:28
@ 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 RZ_FLAGS_FS_DEBUG_MAPS
Definition: rz_core.h:74
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
Definition: io.c:411
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:300
RZ_API int rz_io_fd_get_pid(RzIO *io, int fd)
Definition: io_fd.c:92
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
RZ_API bool rz_name_filter(char *name, int len, bool strict)
Definition: name.c:43
RZ_API char * rz_num_units(char *buf, size_t len, ut64 number)
Definition: unum.c:108
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_REG_TYPE_GPR
Definition: rz_reg.h:21
@ RZ_REG_NAME_SP
Definition: rz_reg.h:44
@ RZ_REG_NAME_PC
Definition: rz_reg.h:43
RZ_API const char * rz_str_rwx_i(int rwx)
Definition: str.c:332
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
static const char * rz_str_get_null(const char *str)
Definition: rz_str.h:190
RZ_API int rz_str_cmp(const char *dst, const char *orig, int len)
Definition: str.c:974
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
Definition: rz_str.h:59
@ RZ_SYS_BITS_32
Definition: rz_sys.h:20
@ RZ_SYS_BITS_64
Definition: rz_sys.h:21
RZ_API void rz_table_visual_list(RzTable *table, RzList *list, ut64 seek, ut64 len, int width, bool va)
Definition: table.c:1205
RZ_API void rz_table_free(RzTable *t)
Definition: table.c:114
RZ_API char * rz_table_tostring(RzTable *t)
Definition: table.c:510
RZ_API RzTable * rz_table_new(void)
Definition: table.c:103
#define RZ_NEWCOPY(x, y)
Definition: rz_types.h:286
#define RZ_NULLABLE
Definition: rz_types.h:65
#define RZ_OWN
Definition: rz_types.h:62
#define RZ_NEW0(x)
Definition: rz_types.h:284
#define RZ_NONNULL
Definition: rz_types.h:64
#define RZ_PERM_X
Definition: rz_types.h:95
RzOutputMode
Enum to describe the way data are printed.
Definition: rz_types.h:38
@ RZ_OUTPUT_MODE_LONG
Definition: rz_types.h:44
@ 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 RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300
#define PFMT64x
Definition: rz_types.h:393
#define UT32_MAX
Definition: rz_types_base.h:99
#define UT64_MAX
Definition: rz_types_base.h:86
RZ_API bool rz_core_seek(RzCore *core, ut64 addr, bool rb)
Seek to addr.
Definition: seek.c:116
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125
static int
Definition: sfsocketcall.h:114
#define b(i)
Definition: sha256.c:42
#define f(i)
Definition: sha256.c:46
#define a(i)
Definition: sha256.c:41
void * cons
Definition: rz_table.h:53
Definition: z80asm.h:102
Definition: rz_pj.h:12
char * flagdesc2
Definition: rz_debug.h:427
char * pcstr
Definition: rz_debug.h:424
char * flagdesc
Definition: rz_debug.h:426
RzDebugFrame * frame
Definition: rz_debug.h:421
char * spstr
Definition: rz_debug.h:425
char * desc
Definition: rz_debug.h:423
RzAnalysisFunction * fcn
Definition: rz_debug.h:422
const char * type
Definition: rz_bin.h:682
char * name
Definition: rz_bin.h:675
int is_debugger
Definition: rz_bin.h:350
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
void * core
Definition: rz_bind.h:31
RzCoreGetName getName
Definition: rz_bind.h:40
bool break_loop
Definition: rz_core.h:373
RzBin * bin
Definition: rz_core.h:298
ut64 offset
Definition: rz_core.h:301
RzAnalysis * analysis
Definition: rz_core.h:322
RzDebug * dbg
Definition: rz_core.h:329
RzIO * io
Definition: rz_core.h:313
RzFlag * flags
Definition: rz_core.h:330
RzPrint * print
Definition: rz_core.h:327
RzCoreFile * file
Definition: rz_core.h:314
RzConfig * config
Definition: rz_core.h:300
const char * license
Definition: rz_debug.h:360
RzList *(* pids)(RzDebug *dbg, int pid)
Definition: rz_debug.h:376
const char * arch
Definition: rz_debug.h:364
const char * name
Definition: rz_debug.h:359
RzCoreBind corebind
Definition: rz_debug.h:314
RzDebugSession * session
Definition: rz_debug.h:311
bool continue_all_threads
Definition: rz_debug.h:272
struct rz_debug_plugin_t * cur
Definition: rz_debug.h:295
RzDebugTrace * trace
Definition: rz_debug.h:281
char * arch
Definition: rz_debug.h:242
RzReg * reg
Definition: rz_debug.h:286
RzList * call_frames
Definition: rz_debug.h:284
RzList * plugins
Definition: rz_debug.h:297
char * btalgo
Definition: rz_debug.h:258
int bits
Definition: rz_debug.h:243
RzIOBind iob
Definition: rz_debug.h:293
RzBreakpoint * bp
Definition: rz_debug.h:288
RzList * traces
Definition: rz_debug.h:220
RzIOReadAt read_at
Definition: rz_io.h:240
RzIO * io
Definition: rz_io.h:232
int fd
Definition: rz_io.h:96
struct rz_io_desc_t * desc
Definition: rz_io.h:60
int va
Definition: rz_io.h:63
RzListFree free
Definition: rz_list.h:21
bool cur_enabled
Definition: rz_print.h:130
char * name[RZ_REG_NAME_LAST]
Definition: rz_reg.h:149
Definition: dis.h:43
int pos
Definition: main.c:11
int width
Definition: main.c:10
RZ_API RZ_OWN RzList * rz_debug_traces_info(RzDebug *dbg, ut64 offset)
Definition: trace.c:218
RZ_API int rz_debug_trace_pc(RzDebug *dbg, ut64 pc)
Definition: trace.c:160
Definition: dis.c:32
static int level
Definition: vmenus.c:2424
static st64 delta
Definition: vmenus.c:2425
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int sp
Definition: z80asm.c:91
static int addr
Definition: z80asm.c:58
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)