def test_v3_redirect_assembler(): # prepare a forest that already got two traces, # the first with call assembler and the target of # call assembler already included. then a read mark # redirect assembler is emulated. forest = TraceForest(3) trace = forest.add_trace('loop', 0, 0) trace.start_mark(const.MARK_TRACE_ASM) op = FlatOp(0, 'call_assembler_i', '', 'i0', 0, 15) trace.add_instr(op) # trace2 = forest.add_trace('loop', 16, 0) trace2.start_mark(const.MARK_TRACE_ASM) trace2.set_addr_bounds(42,44) # fobj = FileObj([const.MARK_REDIRECT_ASSEMBLER, encode_le_u64(15), encode_le_u64(17), encode_le_u64(16), ]) fw = FileObjWrapper(fobj) forest = construct_forest(fw, forest=forest) asm = forest.get_trace(16) parent = forest.get_trace(0) assert asm.get_parent() == parent assert len(parent.links) == 1
def test_v3_redirect_assembler(): # prepare a forest that already got two traces, # the first with call assembler and the target of # call assembler already included. then a read mark # redirect assembler is emulated. forest = TraceForest(3) trace = forest.add_trace('loop', 0, 0) trace.start_mark(const.MARK_TRACE_ASM) op = FlatOp(0, 'call_assembler_i', '', 'i0', 0, 15) trace.add_instr(op) # trace2 = forest.add_trace('loop', 16, 0) trace2.start_mark(const.MARK_TRACE_ASM) trace2.set_addr_bounds(42, 44) # fobj = FileObj([ const.MARK_REDIRECT_ASSEMBLER, encode_le_u64(15), encode_le_u64(17), encode_le_u64(16), ]) fw = FileObjWrapper(fobj) forest = construct_forest(fw, forest=forest) asm = forest.get_trace(16) parent = forest.get_trace(0) assert asm.get_parent() == parent assert len(parent.links) == 1