diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-07-09 14:20:28 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-07-10 14:57:24 +0200 |
| commit | f08ef523e0a30f89c5e05c894541d180e871fd1c (patch) | |
| tree | 00f29558bdcee14fa475ecf17d7badd45f029de4 | |
| parent | 7479f169ac9ae1546e4f77f581563e12a1690336 (diff) | |
| download | miasm-f08ef523e0a30f89c5e05c894541d180e871fd1c.tar.gz miasm-f08ef523e0a30f89c5e05c894541d180e871fd1c.zip | |
IR: rename DiGraphIR=>IRCFG
| -rw-r--r-- | miasm2/analysis/data_flow.py | 11 | ||||
| -rw-r--r-- | miasm2/analysis/depgraph.py | 4 | ||||
| -rw-r--r-- | miasm2/ir/ir.py | 31 | ||||
| -rw-r--r-- | test/ir/reduce_graph.py | 2 |
4 files changed, 30 insertions, 18 deletions
diff --git a/miasm2/analysis/data_flow.py b/miasm2/analysis/data_flow.py index b3c4df88..d0f2a0b1 100644 --- a/miasm2/analysis/data_flow.py +++ b/miasm2/analysis/data_flow.py @@ -121,7 +121,7 @@ class DiGraphDefUse(DiGraph): def __init__(self, reaching_defs, deref_mem=False, *args, **kwargs): - """Instanciate a DiGraphIR + """Instanciate a DiGraph @blocks: IR blocks """ self._edge_attr = {} @@ -271,7 +271,7 @@ def dead_simp(irarch, ircfg): def _test_merge_next_block(ircfg, loc_key): """ Test if the irblock at @loc_key can be merge with its son - @ircfg: DiGraphIR instance + @ircfg: IRCFG instance @loc_key: LocKey instance of the candidate parent irblock """ @@ -287,6 +287,7 @@ def _test_merge_next_block(ircfg, loc_key): return None return son + def _do_merge_blocks(ircfg, loc_key, son_loc_key): """ Merge two irblocks at @loc_key and @son_loc_key @@ -376,7 +377,7 @@ def _remove_to_son(ircfg, loc_key, son_loc_key): - irblock at @loc_key is a pure jump block - @loc_key is not an entry point (can be removed) - @irblock: DiGraphIR + @irblock: IRCFG instance @loc_key: LocKey instance of the parent irblock @son_loc_key: LocKey instance of the son irblock """ @@ -450,7 +451,7 @@ def merge_blocks(ircfg, loc_key_entries): Return True if at least an irblock has been modified - @ircfg: DiGraphIR instance + @ircfg: IRCFG instance @loc_key_entries: loc_key to keep """ @@ -490,7 +491,7 @@ def remove_empty_assignblks(ircfg): Remove empty assignblks in irblocks of @ircfg Return True if at least an irblock has been modified - @ircfg: DiGraphIR + @ircfg: IRCFG instance """ modified = False for loc_key, block in ircfg.blocks.iteritems(): diff --git a/miasm2/analysis/depgraph.py b/miasm2/analysis/depgraph.py index 93b3edb5..a5f3f0fd 100644 --- a/miasm2/analysis/depgraph.py +++ b/miasm2/analysis/depgraph.py @@ -452,7 +452,7 @@ class DependencyGraph(object): follow_call=True): """Create a DependencyGraph linked to @ircfg - @ircfg: DiGraphIR instance + @ircfg: IRCFG instance @implicit: (optional) Track IRDst for each block in the resulting path Following arguments define filters used to generate dependencies @@ -590,7 +590,7 @@ class DependencyGraph(object): def get(self, loc_key, elements, line_nb, heads): """Compute the dependencies of @elements at line number @line_nb in - the block named @loc_key in the current DiGraphIR, before the execution of + the block named @loc_key in the current IRCFG, before the execution of this line. Dependency check stop if one of @heads is reached @loc_key: LocKey instance @element: set of Expr instances diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index 9f797199..721101e2 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -451,12 +451,12 @@ class irbloc(IRBlock): super(irbloc, self).__init__(loc_key, irs) -class DiGraphIR(DiGraph): +class IRCFG(DiGraph): """DiGraph for IR instances""" def __init__(self, irdst, loc_db, blocks=None, *args, **kwargs): - """Instanciate a DiGraphIR + """Instanciate a IRCFG @loc_db: LocationDB instance @blocks: IR blocks """ @@ -465,7 +465,7 @@ class DiGraphIR(DiGraph): blocks = {} self._blocks = blocks self._irdst = irdst - super(DiGraphIR, self).__init__(*args, **kwargs) + super(IRCFG, self).__init__(*args, **kwargs) @property def IRDst(self): @@ -477,7 +477,7 @@ class DiGraphIR(DiGraph): def add_irblock(self, irblock): """ - Add the @irblock to the current DiGraphIR + Add the @irblock to the current IRCFG @irblock: IRBlock instance """ self.blocks[irblock.loc_key] = irblock @@ -547,7 +547,7 @@ class DiGraphIR(DiGraph): node """ self._dot_offset = offset - return super(DiGraphIR, self).dot() + return super(IRCFG, self).dot() def get_loc_key(self, addr): """Transforms an ExprId/ExprInt/loc_key/int into a loc_key @@ -676,6 +676,17 @@ class DiGraphIR(DiGraph): return done +class DiGraphIR(IRCFG): + """ + DEPRECATED object + Use IRCFG instead of DiGraphIR + """ + + def __init__(self, irdst, loc_db, blocks=None, *args, **kwargs): + warnings.warn('DEPRECATION WARNING: use "IRCFG" instead of "DiGraphIR"') + super(IRCFG, self).__init__(irdst, loc_db, blocks=None, *args, **kwargs) + + class IntermediateRepresentation(object): """ Intermediate representation object @@ -696,17 +707,17 @@ class IntermediateRepresentation(object): def new_ircfg(self, *args, **kwargs): """ - Return a new instance of DiGraphIR + Return a new instance of IRCFG """ - return DiGraphIR(self.IRDst, self.loc_db, *args, **kwargs) + return IRCFG(self.IRDst, self.loc_db, *args, **kwargs) def new_ircfg_from_asmcfg(self, asmcfg, *args, **kwargs): """ - Return a new instance of DiGraphIR from an @asmcfg + Return a new instance of IRCFG from an @asmcfg @asmcfg: AsmCFG instance """ - ircfg = DiGraphIR(self.IRDst, self.loc_db, *args, **kwargs) + ircfg = IRCFG(self.IRDst, self.loc_db, *args, **kwargs) for block in asmcfg.blocks: self.add_asmblock_to_ircfg(block, ircfg) return ircfg @@ -770,7 +781,7 @@ class IntermediateRepresentation(object): """ Add a native block to the current IR @block: native assembly block - @ircfg: DiGraphIR instance + @ircfg: IRCFG instance @gen_pc_updt: insert PC update effects between instructions """ diff --git a/test/ir/reduce_graph.py b/test/ir/reduce_graph.py index c9db1002..d8b78c90 100644 --- a/test/ir/reduce_graph.py +++ b/test/ir/reduce_graph.py @@ -6,7 +6,7 @@ from miasm2.expression.expression import ExprId, ExprInt, ExprAff, ExprCond, \ from miasm2.core.locationdb import LocationDB from miasm2.ir.analysis import ira -from miasm2.ir.ir import IRBlock, AssignBlock, DiGraphIR +from miasm2.ir.ir import IRBlock, AssignBlock, IRCFG from miasm2.analysis.data_flow import merge_blocks loc_db = LocationDB() |