Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added esil break on invalid instruction variable #10823

Merged
merged 3 commits into from Jul 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions libr/core/cconfig.c
Expand Up @@ -2435,6 +2435,7 @@ R_API int r_core_config_init(RCore *core) {
SETI ("esil.stack.addr", 0x100000, "Number of elements that can be pushed on the esilstack");
SETPREF ("esil.stack.pattern", "0", "Specify fill pattern to initialize the stack (0, w, d, i)");
SETI ("esil.addr.size", 64, "Maximum address size in accessed by the ESIL VM");
SETPREF ("esil.breakoninvalid", "false", "Break esil execution when instruction is invalid");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe good to try to have this enabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try, but in r2 it's less important than in cutter since you can always ^C when it starts sledding on invalids.


/* asm */
//asm.os needs to be first, since other asm.* depend on it
Expand Down
5 changes: 5 additions & 0 deletions libr/core/cmd_anal.c
Expand Up @@ -3236,6 +3236,7 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
RAnalOp op = {0};
RAnalEsil *esil = core->anal->esil;
const char *name = r_reg_get_name (core->anal->reg, R_REG_NAME_PC);
bool breakoninvalid = r_config_get_i (core->config, "esil.breakoninvalid");
if (!esil) {
// TODO inititalizeEsil (core);

Expand Down Expand Up @@ -3310,6 +3311,10 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
// update the esil pointer because RAnal.op() can change it
esil = core->anal->esil;
if (op.size < 1 || ret < 0) {
if (breakoninvalid) {
r_cons_printf ("[ESIL] Stopped execution in an invalid instruction (see e??esil.breakoninvalid)\n");
return_tail (0);
}
if (esil->cmd && esil->cmd_todo) {
esil->cmd (esil, esil->cmd_todo, addr, 0);
}
Expand Down