Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4dd01aa
Move code from esil_trace refactor to type_trace
condret Apr 4, 2025
e974109
bvhjik
condret Apr 22, 2025
08c559d
56ftgyhuji
condret Apr 22, 2025
d50bc23
Stack map setup + esil interfaces for type trace
condret Apr 23, 2025
7fda9a1
Finish refactoring tps_{init/fini} for now
condret Apr 24, 2025
5f47371
Some more refactoring
condret Apr 24, 2025
9f25150
Add missing LOC
condret Apr 25, 2025
ae454d1
wooooops
condret Apr 25, 2025
706c340
Add type_trace_loopcount functions
condret Apr 28, 2025
4fb6e64
Avoid use of r_core_esil_step in type_trace
condret Apr 28, 2025
1992e4d
Use type_trace_op instead of r_esil_parse in type propagation
condret Apr 28, 2025
2261b27
blub
condret Apr 28, 2025
c61d46e
tyfvguhbjnkm
condret Apr 28, 2025
9ac3a4f
tfygvuhbijnkm
condret Apr 28, 2025
2da6df3
fix segfault
condret Apr 28, 2025
f19c968
Fix another segfault
condret Apr 28, 2025
9fa7b96
Fix 2 more segfaults
condret Apr 28, 2025
ac1a787
Remove unused type_trace_restore helpers
condret Apr 29, 2025
88b2c36
Remove a bunch of crap and overall speedup typetrace
condret Apr 29, 2025
debbf39
Hackfix
condret Apr 29, 2025
db9e677
disable forgotten unused function to stop compiler bitching
condret Apr 29, 2025
cf1f2df
use new esil api to see what happens
condret Apr 30, 2025
0f8e0d8
Fix some bugz
condret Apr 30, 2025
a104931
Prepare esil_dfg for switch to new esil api
condret May 2, 2025
e0c3a8d
Prepare vmenus for switch to new esil api
condret May 2, 2025
2bd7951
Prepare cmd_search for switch to new esil api
condret May 3, 2025
8a57266
Fix esil_dfg unit tests for new api
condret May 5, 2025
4dea179
Prepare anal for switch to new esil api
condret May 5, 2025
7504913
Fix annoying warning when using new esil api
condret May 5, 2025
21b75db
Fix esil_toc for switch to new esil api
condret May 5, 2025
9637dd6
Prepare esil_cost in cmd_anal.inc.c for switch to new esil api
condret May 7, 2025
522c793
Fix esil_toc
condret May 7, 2025
280df66
Continue massaging cmd_anal.inc.c for new esil api
condret Mar 15, 2026
de61469
Add anal specific esil mem and reg interfaces
condret May 8, 2025
303e6ad
Use esil->reg_if.is_reg in not_a_number (libr/esil/esil.c) if new esi…
condret May 8, 2025
3ea34fd
Further massage cmd_anal.inc.c for new esil api
condret May 8, 2025
b5f6e08
Add mdev and ioer support to core_esil
condret May 9, 2025
9ccb68e
Add cmd_step and cmd_step_out support to core_esil
condret May 10, 2025
7c97d2f
Implement step back capabilities in RCoreEsil
condret May 11, 2025
eb77517
Add esil back step config var
condret May 26, 2025
8b1e05d
Initialize core_esil on core init and autoupdate on arch config changes
condret May 27, 2025
93d90c0
Start rewriting r_core_esil_step
condret Jun 5, 2025
1406207
Add r_core_esil_run_expr_at and fix some things pointed out by @trufae
condret Jun 10, 2025
8fb5549
Rewrite r_core_esil_step{_back} using new esil api
condret Jun 20, 2025
ffe2fdb
Add sanity check
condret Jun 28, 2025
a687ab6
Fix build
condret Mar 15, 2026
aaed7b9
Rewrite esil_bits and make it revertible in core_esil
condret Mar 15, 2026
632cdfe
Add reg_alias to esil reg interface and corresponding voyeurs to core…
condret Mar 15, 2026
8c4327e
Move r_esil_mem_read from esil_ops.c to esil.c
condret Mar 16, 2026
5d46c56
Use new esil api in r_core_anal_esil_function
condret Mar 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions libr/anal/anal.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,98 @@ static void r_meta_item_free(void *_item) {
}
}

#if USE_NEW_ESIL
static bool anal_esil_mem_switch (void *mem, ut32 idx) {
RAnal *anal = mem;
if (!anal || !anal->iob.init) {
R_LOG_WARN ("anal->iob is not setup");
return false;
}
return anal->iob.bank_use (anal->iob.io, idx);
}

static bool anal_esil_mem_read (void *mem, ut64 addr, ut8 *buf, int len) {
RAnal *anal = mem;
if (!anal || !anal->iob.init) {
R_LOG_WARN ("anal->iob is not setup");
return false;
}
return anal->iob.read_at (anal->iob.io, addr, buf, len);
}

static bool anal_esil_mem_write (void *mem, ut64 addr, const ut8 *buf, int len) {
RAnal *anal = mem;
if (!anal || !anal->iob.init) {
R_LOG_WARN ("anal->iob is not setup");
return false;
}
return anal->iob.write_at (anal->iob.io, addr, buf, len);
}

REsilMemInterface anal_esil_mem_if = {
.mem_switch = anal_esil_mem_switch,
.mem_read = anal_esil_mem_read,
.mem_write = anal_esil_mem_write
};

static bool anal_esil_is_reg (void *user, const char *name) {
RRegItem *ri = r_reg_get (((RAnal *)user)->reg, name, -1);
if (!ri) {
return false;
}
r_unref (ri);
return true;
}

static bool anal_esil_reg_read (void *user, const char *name, ut64 *val) {
RRegItem *ri = r_reg_get (((RAnal *)user)->reg, name, -1);
if (!ri) {
return false;
}
*val = r_reg_get_value (((RAnal *)user)->reg, ri);
r_unref (ri);
return true;
}

static bool anal_esil_reg_write (void *user, const char *name, ut64 val) {
return r_reg_setv (((RAnal *)user)->reg, name, val);
}

static ut32 anal_esil_reg_size (void *user, const char *name) {
RRegItem *ri = r_reg_get (((RAnal *)user)->reg, name, -1);
if (!ri) {
return 0;
}
const ut32 size = ri->size;
r_unref (ri);
return size;
}

static bool anal_esil_reg_alias (void *user, const char *name, const char *alias) {
int alias_type = r_reg_alias_fromstring (alias);
if (alias_type < 0) {
return false;
}
return r_reg_alias_setname (((RAnal *)user)->reg, alias_type, name);
}

static REsilRegInterface anal_esil_reg_if = {
.is_reg = anal_esil_is_reg,
.reg_read = anal_esil_reg_read,
.reg_write = anal_esil_reg_write,
.reg_size = anal_esil_reg_size,
.reg_alias = anal_esil_reg_alias
};

static bool anal_esil_set_bits (void *user, int bits) {
return r_anal_set_triplet ((RAnal *)user, NULL, NULL, bits);
}

static REsilUtilInterface anal_esil_util_if = {
.set_bits = anal_esil_set_bits
};
#endif

// Take nullable RArchConfig as argument?
R_API RAnal *r_anal_new(void) {
int i;
Expand Down Expand Up @@ -176,7 +268,14 @@ R_API RAnal *r_anal_new(void) {
anal->sdb_classes_attrs = sdb_ns (anal->sdb_classes, "attrs", 1);
anal->zign_path = strdup ("");
anal->cb_printf = (PrintfCallback) printf;
#if USE_NEW_ESIL
anal_esil_reg_if.reg = anal;
anal_esil_mem_if.mem = anal;
anal_esil_util_if.user = anal;
anal->esil = r_esil_new_ex (4096, 0, 1, &anal_esil_reg_if, &anal_esil_mem_if, &anal_esil_util_if);
#else
anal->esil = r_esil_new (4096, 0, 1);
#endif
anal->esil->anal = anal;
(void)r_anal_pin_init (anal);
(void)r_anal_xrefs_init (anal);
Expand Down
8 changes: 8 additions & 0 deletions libr/anal/esil_dfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,11 @@ R_API RAnalEsilDFG *r_anal_esil_dfg_new(RAnal *anal, bool use_map_info, bool use
free (dfg);
return NULL;
}
#if USE_NEW_ESIL
dfg->esil = r_esil_new_simple (1, anal->reg, &anal->iob);
#else
dfg->esil = r_esil_new (4096, 0, 1);
#endif
if (!dfg->esil) {
r_reg_free (dfg->reg);
free (dfg);
Expand Down Expand Up @@ -1641,7 +1645,11 @@ R_API void r_anal_esil_dfg_free(RAnalEsilDFG *dfg) {
R_API RAnalEsilDFG *r_anal_esil_dfg_expr(RAnal *anal, RAnalEsilDFG *R_NULLABLE dfg, const char *expr,
bool use_map_info, bool use_maps) {
R_RETURN_VAL_IF_FAIL (anal && expr, NULL);
#if USE_NEW_ESIL
REsil *esil = r_esil_new_simple (1, anal->reg, &anal->iob);
#else
REsil *esil = r_esil_new (4096, 0, 1);
#endif
if (!esil) {
return NULL;
}
Expand Down
11 changes: 10 additions & 1 deletion libr/anal/p/anal_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,14 @@ static ut32 tt_reg_size(void *reg, const char *name) {
return size;
}

static bool tt_reg_alias(void *reg, const char *name, const char *alias) {
int alias_type = r_reg_alias_fromstring (alias);
if (alias_type < 0) {
return false;
}
return r_reg_alias_setname (reg, alias_type, name);
}

static bool tt_mem_read(void *mem, ut64 addr, ut8 *buf, int len) {
TPState *tps = (TPState *)mem;
if (tps->anal->iob.read_at) {
Expand Down Expand Up @@ -1306,14 +1314,15 @@ static TPState *tps_init(RAnal *anal) {
tps->reg_if.reg_read = tt_reg_read;
tps->reg_if.reg_write = (REsilRegWrite)r_reg_setv;
tps->reg_if.reg_size = tt_reg_size;
tps->reg_if.reg_alias = tt_reg_alias;
tps->mem_if.mem = tps;
tps->mem_if.mem_read = tt_mem_read;
tps->mem_if.mem_write = tt_mem_write;
ut64 sp = tps->stack_base + stack_size - (stack_size % align) - align * 8;
// todo: this probably needs some boundary checks
r_reg_setv (reg, "SP", sp);
r_reg_setv (reg, "BP", sp);
if (!r_esil_init (&tps->esil, 4096, false, anal->config->bits, &tps->reg_if, &tps->mem_if)) {
if (!r_esil_init (&tps->esil, 4096, false, anal->config->bits, &tps->reg_if, &tps->mem_if, NULL)) {
r_reg_free (reg);
if (anal->iob.fd_close) {
anal->iob.fd_close (io, tps->stack_fd);
Expand Down
Loading
Loading