From 9f1e714016dde85b55720930e05af30cf26813a0 Mon Sep 17 00:00:00 2001 From: pancake Date: Tue, 24 Mar 2015 00:16:00 +0100 Subject: [PATCH] Fix ac? help --- libr/anal/p/anal_x86_cs.c | 1 + libr/core/cmd_anal.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libr/anal/p/anal_x86_cs.c b/libr/anal/p/anal_x86_cs.c index 802d3c466f..7f77cd762a 100644 --- a/libr/anal/p/anal_x86_cs.c +++ b/libr/anal/p/anal_x86_cs.c @@ -144,6 +144,7 @@ static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) { case 32: regsz = 4; break; } memset (op, '\0', sizeof (RAnalOp)); + op->cycles = 1; // aprox op->type = R_ANAL_OP_TYPE_NULL; op->jump = UT64_MAX; op->fail = UT64_MAX; diff --git a/libr/core/cmd_anal.c b/libr/core/cmd_anal.c index 4b69b326d3..f58bb418bb 100644 --- a/libr/core/cmd_anal.c +++ b/libr/core/cmd_anal.c @@ -92,7 +92,9 @@ static int var_cmd(RCore *core, const char *str) { *new_name++ = 0; char *old_name = strdup (str); r_str_split(old_name, ' '); - r_anal_var_rename (core->anal, fcn->addr, R_ANAL_VAR_SCOPE_LOCAL, (char)type, old_name, new_name); + r_anal_var_rename (core->anal, fcn->addr, + R_ANAL_VAR_SCOPE_LOCAL, (char)type, + old_name, new_name); free (old_name); goto end; case 'j': @@ -2403,20 +2405,24 @@ static int cmd_anal(void *data, const char *input) { } break; case 'c': - if (1) { + if (input[1]=='?') { + eprintf ("Usage: ac [cycles] # analyze instructions that fit in N cycles\n"); + } else { + RList *hooks ; + RListIter *iter; + RAnalCycleHook *hook; char *instr_tmp = NULL; int ccl = input[1]? r_num_math (core->num, &input[2]):0; //get cycles to look for int cr = r_config_get_i (core->config, "asm.cmtright"); int fun = r_config_get_i (core->config, "asm.functions"); int li = r_config_get_i (core->config, "asm.lines"); int xr = r_config_get_i (core->config, "asm.xrefs"); + r_config_set_i (core->config, "asm.cmtright", R_TRUE); r_config_set_i (core->config, "asm.functions", R_FALSE); r_config_set_i (core->config, "asm.lines", R_FALSE); r_config_set_i (core->config, "asm.xrefs", R_FALSE); - RList *hooks ; - RListIter *iter; - RAnalCycleHook *hook; + r_cons_break (NULL, NULL); hooks = r_core_anal_cycles (core, ccl); //analyse r_cons_break_end (); @@ -2428,6 +2434,7 @@ static int cmd_anal(void *data, const char *input) { free (instr_tmp); } r_list_free (hooks); + r_config_set_i (core->config, "asm.cmtright", cr); //reset settings r_config_set_i (core->config, "asm.functions", fun); r_config_set_i (core->config, "asm.lines", li);