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

Add possibility to diff states in dumping symbexec state #1311

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions miasm/ir/symbexec.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,14 +965,15 @@ def modified(self, init_state=None, ids=True, mems=True):
continue
yield mem, value

def dump(self, ids=True, mems=True):
def dump(self,init_state_engine=None, ids=True, mems=True):
"""
Display modififed variables
@init_state_engine: StateEngine instance
@ids: display modified ids
@mems: display modified memory
"""

for variable, value in self.modified(None, ids, mems):
for variable, value in self.modified(dict(init_state_engine if init_state_engine is not None else {}), ids, mems):
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the patch be better with:

 def dump(self,init_state=None, ids=True, mems=True)
    ...
    if init_state is None:
        init_state ={}
    ...
    for variable, value in self.modified(init_state, ids, mems):
        ....

Is it ok for you ?

Copy link
Author

Choose a reason for hiding this comment

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

Hmmm just note that modified doesnt take in a state instance as the name implies but a base dictionary as its commented in the source code (so a dict(state) )
@init_state: a base dictionary linking variables to their initial values

So I guess passing dict() of a StateEngine or correcting the modified func as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, as the state is a kind of dictionary, I may keep the dictionary as argument if you are ok with this (the .symbols return a dictionary as well)

Copy link
Author

Choose a reason for hiding this comment

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

All goodie then !

print("%-18s" % variable, "=", "%s" % value)

def eval_assignblk(self, assignblk):
Expand Down