Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Private Attributes | List of all members
miasm2.analysis.depgraph.DependencyResult Class Reference
+ Inheritance diagram for miasm2.analysis.depgraph.DependencyResult:
+ Collaboration diagram for miasm2.analysis.depgraph.DependencyResult:

Public Member Functions

def __init__
 
def graph
 
def history
 
def unresolved
 
def relevant_nodes
 
def relevant_labels
 
def input
 
def has_loop
 
def emul
 

Private Attributes

 _ira
 
 _depdict
 
 _input_depnodes
 
 _graph
 
 _has_loop
 

Detailed Description

Container and methods for DependencyGraph results

Definition at line 463 of file depgraph.py.

Constructor & Destructor Documentation

def miasm2.analysis.depgraph.DependencyResult.__init__ (   self,
  ira,
  final_depdict,
  input_depnodes 
)
Instance a DependencyResult
@ira: IRAnalysis instance
@final_depdict: DependencyDict instance
@input_depnodes: set of DependencyNode instance

Definition at line 467 of file depgraph.py.

468  def __init__(self, ira, final_depdict, input_depnodes):
469  """Instance a DependencyResult
470  @ira: IRAnalysis instance
471  @final_depdict: DependencyDict instance
472  @input_depnodes: set of DependencyNode instance
473  """
474  # Store arguments
475  self._ira = ira
476  self._depdict = final_depdict
477  self._input_depnodes = input_depnodes
478 
479  # Init lazy elements
480  self._graph = None
481  self._has_loop = None

Member Function Documentation

def miasm2.analysis.depgraph.DependencyResult.emul (   self,
  ctx = None,
  step = False 
)
Symbolic execution of relevant nodes according to the history
Return the values of input nodes' elements
@ctx: (optional) Initial context as dictionnary
@step: (optional) Verbose execution

Warning: The emulation is not sound if the input nodes depend on loop
variant.

Definition at line 539 of file depgraph.py.

540  def emul(self, ctx=None, step=False):
541  """Symbolic execution of relevant nodes according to the history
542  Return the values of input nodes' elements
543  @ctx: (optional) Initial context as dictionnary
544  @step: (optional) Verbose execution
545 
546  Warning: The emulation is not sound if the input nodes depend on loop
547  variant.
548  """
549  # Init
550  ctx_init = self._ira.arch.regs.regs_init
551  if ctx is not None:
552  ctx_init.update(ctx)
553  depnodes = self.relevant_nodes
554  affects = []
555 
556  # Build a single affectation block according to history
557  for label in self.relevant_labels[::-1]:
558  affected_lines = set(depnode.line_nb for depnode in depnodes
559  if depnode.label == label)
560  irs = self._ira.blocs[label].irs
561  for line_nb in sorted(affected_lines):
562  affects.append(irs[line_nb])
563 
564  # Eval the block
565  temp_label = asm_label("Temp")
566  symb_exec = symbexec(self._ira, ctx_init)
567  symb_exec.emulbloc(irbloc(temp_label, affects), step=step)
568 
569  # Return only inputs values (others could be wrongs)
570  return {depnode.element: symb_exec.symbols[depnode.element]
571  for depnode in self.input}
572 

+ Here is the call graph for this function:

def miasm2.analysis.depgraph.DependencyResult.graph (   self)
Returns a DiGraph instance representing the DependencyGraph

Definition at line 483 of file depgraph.py.

484  def graph(self):
485  """Returns a DiGraph instance representing the DependencyGraph"""
486  if self._graph is None:
487  self._graph = self._depdict.as_graph(self._input_depnodes)
488  return self._graph
def miasm2.analysis.depgraph.DependencyResult.has_loop (   self)
True if current dictionnary has a loop

Definition at line 532 of file depgraph.py.

533  def has_loop(self):
534  """True if current dictionnary has a loop"""
535  if self._has_loop is None:
536  self._has_loop = (len(self.relevant_labels) !=
537  len(set(self.relevant_labels)))
538  return self._has_loop

+ Here is the call graph for this function:

def miasm2.analysis.depgraph.DependencyResult.history (   self)
List of depdict corresponding to the blocks encountered in the
analysis

Definition at line 490 of file depgraph.py.

491  def history(self):
492  """List of depdict corresponding to the blocks encountered in the
493  analysis"""
494  return list(self._depdict.history) + [self._depdict]

+ Here is the caller graph for this function:

def miasm2.analysis.depgraph.DependencyResult.input (   self)
Set of DependencyGraph start nodes

Definition at line 527 of file depgraph.py.

528  def input(self):
529  """Set of DependencyGraph start nodes"""
530  return self._input_depnodes

+ Here is the caller graph for this function:

def miasm2.analysis.depgraph.DependencyResult.relevant_labels (   self)
List of labels containing nodes influencing @self.input_depnodes.
The history order is preserved.

Definition at line 511 of file depgraph.py.

512  def relevant_labels(self):
513  """List of labels containing nodes influencing @self.input_depnodes.
514  The history order is preserved.
515  """
516  # Get used labels
517  used_labels = set(depnode.label for depnode in self.relevant_nodes)
518 
519  # Keep history order
520  output = []
521  for label in [depdict.label for depdict in self.history]:
522  if label in used_labels:
523  output.append(label)
524 
525  return output

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.analysis.depgraph.DependencyResult.relevant_nodes (   self)
Set of nodes directly and indirectly influencing
@self.input_depnodes

Definition at line 502 of file depgraph.py.

503  def relevant_nodes(self):
504  """Set of nodes directly and indirectly influencing
505  @self.input_depnodes"""
506  output = set()
507  for depnodes in self._depdict.cache.values():
508  output.update(depnodes)
509  return output

+ Here is the caller graph for this function:

def miasm2.analysis.depgraph.DependencyResult.unresolved (   self)
Set of nodes whose dependencies weren't found

Definition at line 496 of file depgraph.py.

497  def unresolved(self):
498  """Set of nodes whose dependencies weren't found"""
499  return set(node.nostep_repr for node in self._depdict.pending
500  if node.element != self._ira.IRDst)

Member Data Documentation

miasm2.analysis.depgraph.DependencyResult._depdict
private

Definition at line 475 of file depgraph.py.

miasm2.analysis.depgraph.DependencyResult._graph
private

Definition at line 479 of file depgraph.py.

miasm2.analysis.depgraph.DependencyResult._has_loop
private

Definition at line 480 of file depgraph.py.

miasm2.analysis.depgraph.DependencyResult._input_depnodes
private

Definition at line 476 of file depgraph.py.

miasm2.analysis.depgraph.DependencyResult._ira
private

Definition at line 474 of file depgraph.py.


The documentation for this class was generated from the following file: