diff options
| -rw-r--r-- | miasm2/core/asmblock.py | 32 | ||||
| -rw-r--r-- | miasm2/jitter/codegen.py | 8 | ||||
| -rw-r--r-- | miasm2/jitter/jitcore.py | 2 |
3 files changed, 31 insertions, 11 deletions
diff --git a/miasm2/core/asmblock.py b/miasm2/core/asmblock.py index 1f54a7e4..082dc344 100644 --- a/miasm2/core/asmblock.py +++ b/miasm2/core/asmblock.py @@ -67,8 +67,17 @@ class AsmConstraint(object): label = property(get_label, set_label) + def to_string(self, symbol_pool=None): + if symbol_pool is None: + return "%s:%s" % (self.c_t, self.loc_key) + else: + return "%s:%s" % ( + self.c_t, + symbol_pool.str_loc_key(self.loc_key) + ) + def __str__(self): - return "%s:%s" % (str(self.c_t), str(self.loc_key)) + return self.to_string() class asm_constraint(AsmConstraint): @@ -127,22 +136,29 @@ class AsmBlock(object): label = property(get_label) - def __str__(self): + def to_string(self, symbol_pool=None): out = [] - out.append(str(self.loc_key)) - for l in self.lines: - out.append(str(l)) + if symbol_pool is None: + out.append(str(self.loc_key)) + else: + out.append(symbol_pool.str_loc_key(self.loc_key)) + + for instr in self.lines: + out.append(instr.to_string(symbol_pool)) if self.bto: lbls = ["->"] - for l in self.bto: - if l is None: + for dst in self.bto: + if dst is None: lbls.append("Unknown? ") else: - lbls.append(str(l) + " ") + lbls.append(dst.to_string(symbol_pool) + " ") lbls = '\t'.join(lbls) out.append(lbls) return '\n'.join(out) + def __str__(self): + return self.to_string() + def addline(self, l): self.lines.append(l) diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py index c6232642..92af3259 100644 --- a/miasm2/jitter/codegen.py +++ b/miasm2/jitter/codegen.py @@ -342,8 +342,12 @@ class CGen(object): out = [] if instr_attrib.log_mn: - out.append('printf("%.8X %s\\n");' % (instr_attrib.instr.offset, - instr_attrib.instr)) + out.append( + 'printf("%.8X %s\\n");' % ( + instr_attrib.instr.offset, + instr_attrib.instr.to_string(self.ir_arch.symbol_pool) + ) + ) return out def gen_post_code(self, attrib): diff --git a/miasm2/jitter/jitcore.py b/miasm2/jitter/jitcore.py index 8fd3453e..bf56b9de 100644 --- a/miasm2/jitter/jitcore.py +++ b/miasm2/jitter/jitcore.py @@ -153,7 +153,7 @@ class JitCore(object): return cur_block # Logging if self.log_newbloc: - print cur_block + print cur_block.to_string(self.mdis.symbol_pool) # Update label -> block self.lbl2bloc[cur_block.loc_key] = cur_block |