Refactor to replace sr and aei calls with the API ##refactor

This commit is contained in:
Aswin C 2021-02-13 23:20:11 +05:30 committed by GitHub
parent f5a8be350d
commit ebb33e303a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 12 deletions

View file

@ -4238,10 +4238,12 @@ RZ_API int rz_core_visual_graph(RzCore *core, RzAGraph *g, RzAnalysisFunction *_
break;
// Those hardcoded keys are useful only for aegi, should add subcommand of ag to set key actions
case '1':
rz_core_cmd0(core, "so;.aeg*");
rz_core_seek_opcode(core, 1, false);
rz_core_cmd0(core, ".aeg*");
break;
case '2':
rz_core_cmd0(core, "so -1;.aeg*");
rz_core_seek_opcode(core, -1, false);
rz_core_cmd0(core, ".aeg*");
break;
case '=': { // TODO: edit
showcursor(core, true);

View file

@ -4225,7 +4225,7 @@ RZ_API int rz_core_analysis_all(RzCore *core) {
rz_core_analysis_fcn(core, item->offset, -1, RZ_ANALYSIS_REF_TYPE_NULL, depth - 1);
rz_core_cmdf(core, "afn entry0 0x%08" PFMT64x, item->offset);
} else {
rz_core_cmd0(core, "af");
rz_core_analysis_function_add(core, NULL, core->offset, false);
}
rz_core_task_yield(&core->tasks);
@ -5182,7 +5182,7 @@ RZ_API void rz_core_analysis_esil(RzCore *core, const char *str, const char *tar
esilbreak_last_read = UT64_MAX;
rz_io_read_at(core->io, start, buf, iend + 1);
if (!ESIL) {
rz_core_cmd0(core, "aei");
rz_core_analysis_esil_init(core);
ESIL = core->analysis->esil;
if (!ESIL) {
eprintf("ESIL not initialized\n");

View file

@ -183,7 +183,7 @@ RZ_API int rz_core_file_reopen(RzCore *core, const char *args, int perm, int loa
if (isdebug) {
rz_core_cmd0(core, ".dm*");
rz_core_debug_regs2flags(core, 0);
rz_core_cmd0(core, "sr PC");
rz_core_seek_to_register(core, "PC", false);
} else {
loadGP(core);
}

View file

@ -41,7 +41,7 @@ RZ_API int rz_core_setup_debugger(RzCore *r, const char *debugbackend, bool atta
}
}
}
rz_core_cmd(r, "sr PC", 0);
rz_core_seek_to_register(r, "PC", false);
/* set the prompt if it's not been set already by the callbacks */
prompt = rz_config_get(r->config, "cmd.prompt");

View file

@ -371,7 +371,8 @@ static bool lastcmd_repeat(RzCore *core, int next) {
switch (core->lastcmd[1]) {
case 's':
case 'c':
rz_core_cmd0(core, "sr PC;pd 1");
rz_core_seek_to_register(core, "PC", false);
rz_core_cmd0(core, "pd 1");
}
break;
case 'p': // print
@ -3098,7 +3099,7 @@ escape_backtick:
{
ut64 addr = rz_num_math(core->num, ptr + 2);
if (addr) {
rz_core_cmdf(core, "so %s", ptr + 2);
rz_core_seek_opcode(core, addr, false);
cmd_tmpseek = core->tmpseek = true;
}
} break;
@ -5092,7 +5093,7 @@ DEFINE_HANDLE_TS_FCN_AND_SYMBOL(tmp_reli_command) {
ut64 orig_offset = state->core->offset;
ut64 addr = rz_num_math(core->num, arg_str);
if (addr) {
rz_core_cmdf(core, "so %" PFMT64d, addr);
rz_core_seek_opcode(core, addr, false);
}
RzCmdStatus res = handle_ts_command_tmpseek(state, command);
rz_core_seek(state->core, orig_offset, true);

View file

@ -4471,7 +4471,7 @@ repeat:
if (follow > 0) {
ut64 pc = rz_debug_reg_get(core->dbg, "PC");
if ((pc < core->offset) || (pc > (core->offset + follow))) {
rz_core_cmd0(core, "sr PC");
rz_core_seek_to_register(core, "PC", false);
}
}
// check breakpoints

View file

@ -7,6 +7,7 @@
#include "rz_list.h"
#include "rz_types_base.h"
#include "cmd_search_rop.c"
#include "core_private.h"
#define USE_EMULATION 0
@ -1598,7 +1599,7 @@ static void do_esil_search(RzCore *core, struct search_parameters *param, const
}
if (!core->analysis->esil) {
// initialize esil vm
rz_core_cmd0(core, "aei");
rz_core_analysis_esil_init(core);
if (!core->analysis->esil) {
eprintf("Cannot initialize the ESIL vm\n");
return;

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-only
#include "rz_core.h"
#include "core_private.h"
#define HASRETRY 1
#define HAVE_LOCALS 1
@ -6514,7 +6515,7 @@ RZ_API int rz_core_disasm_pde(RzCore *core, int nb_opcodes, int mode) {
pj_a(pj);
}
if (!core->analysis->esil) {
rz_core_cmd0(core, "aei");
rz_core_analysis_esil_init(core);
if (!rz_config_get_b(core->config, "cfg.debug")) {
rz_core_cmd0(core, "aeim");
}