mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-04 11:43:39 +00:00
Fix aeab and add V (values) in aea outputs ##anal
This commit is contained in:
parent
446727b1f8
commit
00bf84610d
@ -256,7 +256,8 @@ static const char *help_msg_aea[] = {
|
||||
"A", "", "all regs accessed",
|
||||
"R", "", "register values read",
|
||||
"W", "", "registers written",
|
||||
"N", "", "not written",
|
||||
"N", "", "read but never written",
|
||||
"V", "", "values",
|
||||
"@R", "", "memreads",
|
||||
"@W", "", "memwrites",
|
||||
"NOTE:", "", "mem{reads,writes} with PIC only fetch the offset",
|
||||
@ -4997,6 +4998,7 @@ typedef struct {
|
||||
RList *regs;
|
||||
RList *regread;
|
||||
RList *regwrite;
|
||||
RList *regvalues;
|
||||
RList *inputregs;
|
||||
} AeaStats;
|
||||
|
||||
@ -5004,6 +5006,7 @@ static void aea_stats_init (AeaStats *stats) {
|
||||
stats->regs = r_list_newf (free);
|
||||
stats->regread = r_list_newf (free);
|
||||
stats->regwrite = r_list_newf (free);
|
||||
stats->regvalues = r_list_newf (free);
|
||||
stats->inputregs = r_list_newf (free);
|
||||
}
|
||||
|
||||
@ -5087,6 +5090,11 @@ static int myregwrite(RAnalEsil *esil, const char *name, ut64 *val) {
|
||||
if (!contains (stats->regwrite, name)) {
|
||||
r_list_push (stats->regwrite, strdup (name));
|
||||
}
|
||||
char *v = r_str_newf ("%"PFMT64d, *val);
|
||||
if (!contains (stats->regvalues, v)) {
|
||||
r_list_push (stats->regvalues, strdup (v));
|
||||
}
|
||||
free (v);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -5296,6 +5304,10 @@ static bool cmd_aea(RCore* core, int mode, ut64 addr, int length) {
|
||||
showregs_json (stats.regread, pj);
|
||||
pj_k (pj, "W");
|
||||
showregs_json (stats.regwrite, pj);
|
||||
if (!r_list_empty (stats.regvalues)) {
|
||||
pj_k (pj, "V");
|
||||
showregs_json (stats.regvalues, pj);
|
||||
}
|
||||
if (!r_list_empty (regnow)){
|
||||
pj_k (pj, "N");
|
||||
showregs_json (regnow, pj);
|
||||
@ -5315,15 +5327,27 @@ static bool cmd_aea(RCore* core, int mode, ut64 addr, int length) {
|
||||
} else if ((mode >> 5) & 1) {
|
||||
// nothing
|
||||
} else {
|
||||
r_cons_printf (" I: ");
|
||||
showregs (stats.inputregs);
|
||||
r_cons_printf (" A: ");
|
||||
showregs (stats.regs);
|
||||
r_cons_printf (" R: ");
|
||||
showregs (stats.regread);
|
||||
r_cons_printf (" W: ");
|
||||
showregs (stats.regwrite);
|
||||
if (r_list_length (regnow)){
|
||||
if (!r_list_empty (stats.inputregs)) {
|
||||
r_cons_printf (" I: ");
|
||||
showregs (stats.inputregs);
|
||||
}
|
||||
if (!r_list_empty (stats.regs)) {
|
||||
r_cons_printf (" A: ");
|
||||
showregs (stats.regs);
|
||||
}
|
||||
if (!r_list_empty (stats.regread)) {
|
||||
r_cons_printf (" R: ");
|
||||
showregs (stats.regread);
|
||||
}
|
||||
if (!r_list_empty (stats.regwrite)) {
|
||||
r_cons_printf (" W: ");
|
||||
showregs (stats.regwrite);
|
||||
}
|
||||
if (!r_list_empty (stats.regvalues)) {
|
||||
r_cons_printf (" V: ");
|
||||
showregs (stats.regvalues);
|
||||
}
|
||||
if (!r_list_empty (regnow)){
|
||||
r_cons_printf (" N: ");
|
||||
showregs (regnow);
|
||||
}
|
||||
@ -5990,18 +6014,16 @@ static void cmd_anal_esil(RCore *core, const char *input) {
|
||||
cmd_aea (core, 1<<4, core->offset, r_num_math (core->num, input+2));
|
||||
} else if (input[1] == '*') {
|
||||
cmd_aea (core, 1<<5, core->offset, r_num_math (core->num, input+2));
|
||||
} else if (input[1] == 'b') {
|
||||
ut64 addr = r_num_math (core->num, input + 2);
|
||||
RAnalBlock *b = r_anal_get_block_at (core->anal, addr);
|
||||
if (b) {
|
||||
switch (input[2]) {
|
||||
case 'j': // "aeabj"
|
||||
cmd_aea (core, 1<<4, b->addr, b->addr + b->size);
|
||||
break;
|
||||
default:
|
||||
cmd_aea (core, 1<<4, b->addr, b->addr + b->size);
|
||||
break;
|
||||
}
|
||||
} else if (input[1] == 'b') { // "aeab"
|
||||
bool json = input[2] == 'j';
|
||||
int a = json? 3: 2;
|
||||
ut64 addr = (input[a] == ' ')? r_num_math (core->num, input + a): core->offset;
|
||||
RList *l = r_anal_get_blocks_in (core->anal, addr);
|
||||
RAnalBlock *b;
|
||||
RListIter *iter;
|
||||
r_list_foreach (l, iter, b) {
|
||||
int mode = json? (1<<4): 1;
|
||||
cmd_aea (core, mode, b->addr, b->size);
|
||||
break;
|
||||
}
|
||||
} else if (input[1] == 'f') {
|
||||
|
@ -3421,10 +3421,10 @@ static void core_cmd_dbi (RCore *core, const char *input, ut64 idx) {
|
||||
#endif
|
||||
|
||||
#define DB_ARG(x) r_str_word_get0(str, x)
|
||||
static void add_breakpoint(RCore *core, char *input, bool hwbp, bool watch) {
|
||||
static void add_breakpoint(RCore *core, const char *input, bool hwbp, bool watch) {
|
||||
RBreakpointItem *bpi;
|
||||
ut64 addr;
|
||||
int rw = 0, i = 0;
|
||||
int i = 0;
|
||||
|
||||
char *str = strdup (r_str_trim_ro (input + 1));
|
||||
int sl = r_str_word_set0 (str);
|
||||
@ -3433,6 +3433,7 @@ static void add_breakpoint(RCore *core, char *input, bool hwbp, bool watch) {
|
||||
if (*DB_ARG (i) == '-') {
|
||||
r_bp_del (core->dbg->bp, r_num_math (core->num, DB_ARG (i) + 1));
|
||||
} else {
|
||||
int rw = 0;
|
||||
if (watch) {
|
||||
if (sl % 2 == 0) {
|
||||
if (!strcmp (DB_ARG (i + 1), "r")) {
|
||||
@ -3485,7 +3486,6 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
|
||||
const char *p;
|
||||
bool hex_format;
|
||||
bool watch = false;
|
||||
int rw = 0;
|
||||
RList *list;
|
||||
ut64 addr, idx;
|
||||
p = strchr (input, ' ');
|
||||
@ -3884,7 +3884,7 @@ static void r_core_cmd_bp(RCore *core, const char *input) {
|
||||
add_breakpoint (core, input + 1, true, watch);
|
||||
break;
|
||||
case ' ': // "db"
|
||||
add_breakpoint (core, input++, hwbp, watch);
|
||||
add_breakpoint (core, input + 1, hwbp, watch);
|
||||
break;
|
||||
case 'i':
|
||||
core_cmd_dbi (core, input, idx);
|
||||
|
Loading…
Reference in New Issue
Block a user