Beispiel #1
0
def on_step(sim: OTBNSim, args: List[str]) -> None:
    '''Step one instruction'''
    if len(args):
        raise ValueError('step expects zero arguments. Got {}.'.format(args))

    pc = int(sim.model.state.pc)

    assert 0 == pc & 3
    print('EXEC {:#08x}'.format(pc))
    done, changes = sim.step()
    for trace in changes:
        print('  {}'.format(trace))
Beispiel #2
0
def on_step(sim: OTBNSim, args: List[str]) -> None:
    '''Step one instruction'''
    if len(args):
        raise ValueError('step expects zero arguments. Got {}.'.format(args))

    pc = int(sim.state.pc)

    assert 0 == pc & 3
    insn, changes = sim.step(verbose=False)
    disasm = '(not running)' if insn is None else insn.disassemble(pc)
    print('EXEC {:#08x}:     {}'.format(pc, disasm))
    for trace in changes:
        print('  {}'.format(trace))
Beispiel #3
0
def on_step(sim: OTBNSim, args: List[str]) -> Optional[OTBNSim]:
    '''Step one instruction'''
    check_arg_count('step', 0, args)

    pc = sim.state.pc
    assert 0 == pc & 3

    insn, changes = sim.step(verbose=False)

    print('STALL' if insn is None else insn.rtl_trace(pc))
    for change in changes:
        entry = change.rtl_trace()
        if entry is not None:
            print(entry)

    return None
Beispiel #4
0
def on_step(sim: OTBNSim, args: List[str]) -> Optional[OTBNSim]:
    '''Step one instruction'''
    if len(args):
        raise ValueError('step expects zero arguments. Got {}.'.format(args))

    pc = sim.state.pc
    assert 0 == pc & 3

    insn, changes = sim.step(verbose=False)

    print('STALL' if insn is None else insn.rtl_trace(pc))
    for change in changes:
        entry = change.rtl_trace()
        if entry is not None:
            print(entry)

    return None
Beispiel #5
0
def on_step(sim: OTBNSim, args: List[str]) -> None:
    '''Step one instruction'''
    if len(args):
        raise ValueError('step expects zero arguments. Got {}.'.format(args))

    pc = sim.state.pc
    assert 0 == pc & 3

    insn, changes = sim.step(verbose=False)

    if insn is None:
        hdr = 'STALL'
    else:
        hdr = 'E PC: {:#010x}, insn: {:#010x}'.format(pc, insn.raw)
    print(hdr)
    for change in changes:
        entry = change.rtl_trace()
        if entry is not None:
            print(entry)
Beispiel #6
0
def on_step(sim: OTBNSim, args: List[str]) -> Optional[OTBNSim]:
    '''Step one instruction'''
    check_arg_count('step', 0, args)

    pc = sim.state.pc
    assert 0 == pc & 3

    was_wiping = sim.state.wiping() and sim.state.secure_wipe_enabled

    insn, changes = sim.step(verbose=False)
    if insn is not None:
        hdr = insn.rtl_trace(pc)  # type: Optional[str]
    elif was_wiping:
        # The trailing space is a bit naff but matches the behaviour in the RTL
        # tracer, where it's rather difficult to change.
        hdr = 'U ' if sim.state.wiping() else 'V '
    elif (sim.state.executing() or
          (changes and not sim.state.secure_wipe_enabled)):
        hdr = 'STALL'
    else:
        hdr = None

    rtl_changes = []
    for c in changes:
        rt = c.rtl_trace()
        if rt is not None:
            rtl_changes.append(rt)

    # This is a bit of a hack. Very occasionally, we'll see traced changes when
    # there's not actually an instruction in flight. For example, this happens
    # if there's a RND request still pending when an operation stops. In this
    # case, we might see a change where we drop the REQ signal after the secure
    # wipe has finished. Rather than define a special "do-nothing" trace entry
    # format for this situation, we cheat and use STALL.
    if hdr is None and rtl_changes:
        hdr = 'STALL'

    if hdr is not None:
        print(hdr)
        for rt in rtl_changes:
            print(rt)

    return None
Beispiel #7
0
def on_step(sim: OTBNSim, args: List[str]) -> None:
    '''Step one instruction'''
    if len(args):
        raise ValueError('step expects zero arguments. Got {}.'
                         .format(args))

    pc = sim.state.pc
    assert 0 == pc & 3

    insn, changes = sim.step(verbose=False, collect_stats=False)

    if insn is None:
        print('STALL')
    else:
        print(f'E PC: {pc:#010x}, insn: {insn.raw:#010x}')
        print(f'# @{pc:#010x}: {insn.insn.mnemonic}')

    for change in changes:
        entry = change.rtl_trace()
        if entry is not None:
            print(entry)
Beispiel #8
0
def on_step(sim: OTBNSim, args: List[str]) -> Optional[OTBNSim]:
    '''Step one instruction'''
    check_arg_count('step', 0, args)

    pc = sim.state.pc
    assert 0 == pc & 3

    was_wiping = sim.state.wiping() and sim.state.secure_wipe_enabled

    insn, changes = sim.step(verbose=False)
    if insn is not None:
        hdr = insn.rtl_trace(pc)  # type: Optional[str]
    elif was_wiping:
        # The trailing space is a bit naff but matches the behaviour in the RTL
        # tracer, where it's rather difficult to change.
        hdr = 'U ' if sim.state.wiping() else 'V '
    elif (sim.state.running()
          or (changes and not sim.state.secure_wipe_enabled)):
        hdr = 'STALL'
    else:
        hdr = None

    rtl_changes = []
    for c in changes:
        rt = c.rtl_trace()
        if rt is not None:
            rtl_changes.append(rt)

    if hdr is None:
        assert not rtl_changes
    else:
        print(hdr)
        for rt in rtl_changes:
            print(rt)

    return None