diff options
| -rw-r--r-- | example/disasm/callback.py | 3 | ||||
| -rw-r--r-- | example/ida/ctype_propagation.py | 1 | ||||
| -rw-r--r-- | miasm2/analysis/dse.py | 1 | ||||
| -rw-r--r-- | miasm2/core/asmblock.py | 37 | ||||
| -rw-r--r-- | miasm2/jitter/jitcore.py | 2 | ||||
| -rw-r--r-- | test/core/asmblock.py | 10 |
6 files changed, 30 insertions, 24 deletions
diff --git a/example/disasm/callback.py b/example/disasm/callback.py index 5aae7f6f..63987e85 100644 --- a/example/disasm/callback.py +++ b/example/disasm/callback.py @@ -54,9 +54,6 @@ cb_x86_funcs.append(cb_x86_callpop) ## Other method: ## mdis.dis_bloc_callback = cb_x86_callpop -# Clean disassembly cache -mdis.job_done.clear() - print "=" * 40 print "With callback:\n" blocks_after = mdis.dis_multiblock(0) diff --git a/example/ida/ctype_propagation.py b/example/ida/ctype_propagation.py index a48179e9..cb342213 100644 --- a/example/ida/ctype_propagation.py +++ b/example/ida/ctype_propagation.py @@ -57,7 +57,6 @@ Dependency Graph Settings def get_block(ir_arch, mdis, addr): """Get IRBlock at address @addr""" - mdis.job_done.clear() lbl = ir_arch.get_label(addr) if not lbl in ir_arch.blocks: block = mdis.dis_block(lbl.offset) diff --git a/miasm2/analysis/dse.py b/miasm2/analysis/dse.py index 41872f5f..74cc87e9 100644 --- a/miasm2/analysis/dse.py +++ b/miasm2/analysis/dse.py @@ -297,7 +297,6 @@ class DSEEngine(object): else: ## Reset cache structures - self.mdis.job_done.clear() self.ir_arch.blocks.clear()# = {} ## Update current state diff --git a/miasm2/core/asmblock.py b/miasm2/core/asmblock.py index 6cbe37a4..5b95976f 100644 --- a/miasm2/core/asmblock.py +++ b/miasm2/core/asmblock.py @@ -1351,12 +1351,6 @@ class disasmEngine(object): + callback(arch, attrib, pool_bin, cur_bloc, offsets_to_dis, symbol_pool) - dis_bloc_callback: callback after each new disassembled block - - The engine also tracks already handled block, for performance and to avoid - infinite cycling. - Addresses of disassembled block is in the attribute `job_done`. - To force a new disassembly, the targeted offset must first be removed from - this structure. """ def __init__(self, arch, attrib, bin_stream, **kwargs): @@ -1370,7 +1364,6 @@ class disasmEngine(object): self.attrib = attrib self.bin_stream = bin_stream self.symbol_pool = AsmSymbolPool() - self.job_done = set() # Setup options self.dont_dis = [] @@ -1386,11 +1379,26 @@ class disasmEngine(object): # Override options if needed self.__dict__.update(kwargs) - def _dis_block(self, offset): + def get_job_done(self): + warnings.warn("""DEPRECATION WARNING: "job_done" is not needed anymore, support is dropped.""") + return set() + + def set_job_done(self, _): + warnings.warn("""DEPRECATION WARNING: "job_done" is not needed anymore, support is dropped.""") + return + + + # Deprecated + job_done = property(get_job_done, set_job_done) + + def _dis_block(self, offset, job_done=None): """Disassemble the block at offset @offset + @job_done: a set of already disassembled addresses Return the created AsmBlock and future offsets to disassemble """ + if job_done is None: + job_done = set() lines_cpt = 0 in_delayslot = False delayslot_count = self.arch.delayslot @@ -1405,7 +1413,7 @@ class disasmEngine(object): if offset in self.dont_dis: if not cur_block.lines: - self.job_done.add(offset) + job_done.add(offset) # Block is empty -> bad block cur_block = AsmBlockBad(label, errno=2) else: @@ -1426,7 +1434,7 @@ class disasmEngine(object): log_asmblock.debug("lines watchdog reached at %X", int(offset)) break - if offset in self.job_done: + if offset in job_done: cur_block.add_cst(offset, AsmConstraint.c_next, self.symbol_pool) break @@ -1441,7 +1449,7 @@ class disasmEngine(object): if instr is None: log_asmblock.warning("cannot disasm at %X", int(off_i)) if not cur_block.lines: - self.job_done.add(offset) + job_done.add(offset) # Block is empty -> bad block cur_block = AsmBlockBad(label, errno=0) else: @@ -1469,7 +1477,7 @@ class disasmEngine(object): add_next_offset = True break - self.job_done.add(offset) + job_done.add(offset) log_asmblock.debug("dis at %X", int(offset)) offset += instr.l @@ -1544,6 +1552,7 @@ class disasmEngine(object): merge with """ log_asmblock.info("dis bloc all") + job_done = set() if blocks is None: blocks = AsmCFG() todo = [offset] @@ -1557,9 +1566,9 @@ class disasmEngine(object): target_offset = int(todo.pop(0)) if (target_offset is None or - target_offset in self.job_done): + target_offset in job_done): continue - cur_block, nexts = self._dis_block(target_offset) + cur_block, nexts = self._dis_block(target_offset, job_done) todo += nexts blocks.add_node(cur_block) diff --git a/miasm2/jitter/jitcore.py b/miasm2/jitter/jitcore.py index 741760cd..9c35f829 100644 --- a/miasm2/jitter/jitcore.py +++ b/miasm2/jitter/jitcore.py @@ -47,7 +47,6 @@ class JitCore(object): self.log_regs = False self.log_newbloc = False self.segm_to_do = set() - self.job_done = set() self.jitcount = 0 self.addr2obj = {} self.addr2objref = {} @@ -140,7 +139,6 @@ class JitCore(object): addr = addr.offset # Prepare disassembler - self.mdis.job_done.clear() self.mdis.lines_wd = self.options["jit_maxline"] self.mdis.dis_bloc_callback = self.disasm_cb diff --git a/test/core/asmblock.py b/test/core/asmblock.py index c3b220df..eb7b54b2 100644 --- a/test/core/asmblock.py +++ b/test/core/asmblock.py @@ -19,12 +19,16 @@ first_block = mdis.dis_block(0) assert len(first_block.lines) == 5 print first_block +## Test redisassemble blocks +first_block_bis = mdis.dis_block(0) +assert len(first_block.lines) == len(first_block_bis.lines) +print first_block_bis + ## Disassembly of several block, with cache blocks = mdis.dis_multiblock(0) -assert len(blocks) == 0 +assert len(blocks) == 17 -## Test cache -mdis.job_done.clear() +## Test redisassemble blocks blocks = mdis.dis_multiblock(0) assert len(blocks) == 17 ## Equality between assembly lines is not yet implemented |