Skip to content

Commit

Permalink
Track last_pc in StateDescriptors (#2471)
Browse files Browse the repository at this point in the history
Start tracking `_last_pc` inside StateDescriptors. 

This is helpful for figuring out which instruction causes a state to fork.
  • Loading branch information
tcode2k16 authored Jul 22, 2021
1 parent dc5e57b commit 7144c73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions manticore/core/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ class StateDescriptor:
own_execs: typing.Optional[int] = None
#: Last program counter (if set)
pc: typing.Optional[typing.Any] = None
#: Last concrete program counter, useful when a state forks and the program counter becomes symbolic
last_pc: typing.Optional[typing.Any] = None
#: Dict mapping field names to the time that field was last updated
field_updated_at: typing.Dict[str, datetime] = field(default_factory=dict)
#: Message attached to the TerminateState exception that ended this state
Expand Down
3 changes: 2 additions & 1 deletion manticore/native/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ def invoke_model(self, model):
def _update_state_descriptor(self, descriptor, *args, **kwargs):
"""
Called on execution_intermittent to update the descriptor for this state.
This one should apply any native-specific information to the descriptor. Right now, that's just the PC
This one should apply any native-specific information to the descriptor. Right now, that's just the PC and _last_pc
:param descriptor: StateDescriptor for this state
"""
super()._update_state_descriptor(descriptor, *args, **kwargs)
descriptor.pc = self.cpu.PC
descriptor.last_pc = self.cpu._last_pc

0 comments on commit 7144c73

Please sign in to comment.