1# DExTer : Debugging Experience Tester 2# ~~~~~~ ~ ~~ ~ ~~ 3# 4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5# See https://llvm.org/LICENSE.txt for license information. 6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7"""Command for specifying an expected number of steps of a particular kind.""" 8 9from dex.command.CommandBase import CommandBase 10from dex.dextIR.StepIR import StepKind 11 12 13class DexExpectStepKind(CommandBase): 14 """Expect to see a particular step `kind` a number of `times` while stepping 15 through the program. 16 17 DexExpectStepKind(kind, times) 18 19 See Commands.md for more info. 20 """ 21 22 def __init__(self, *args): 23 if len(args) != 2: 24 raise TypeError('expected two args') 25 26 try: 27 step_kind = StepKind[args[0]] 28 except KeyError: 29 raise TypeError('expected arg 0 to be one of {}'.format( 30 [kind for kind, _ in StepKind.__members__.items()])) 31 32 self.name = step_kind 33 self.count = args[1] 34 35 super(DexExpectStepKind, self).__init__() 36 37 @staticmethod 38 def get_name(): 39 return __class__.__name__ 40 41 def eval(self): 42 # DexExpectStepKind eval() implementation is mixed into 43 # Heuristic.__init__() 44 # [TODO] Fix this ^. 45 pass 46