Debian Codegraph @

cross-project-tests/debuginfo-tests/dexter/dex/command/CommandBase.py

raw
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 """Base class for all DExTer commands, where a command is a specific Python
8 function that can be embedded into a comment in the source code under test
9 which will then be executed by DExTer during debugging.
10 """
11
12 import abc
13 from collections import namedtuple
14 from typing import List
15
16 StepExpectInfo = namedtuple("StepExpectInfo", "expression, path, frame_idx, line_range")
17
18
19 class CommandBase(object, metaclass=abc.ABCMeta):
20 def __init__(self):
21 self.path = None
22 self.lineno = None
23 self.raw_text = ""
24
25 def get_label_args(self):
26 return list()
27
28 def has_labels(self):
29 return False
30
31 @abc.abstractstaticmethod
32 def get_name():
33 """This abstract method is usually implemented in subclasses as:
34 return __class__.__name__
35 """
36
37 def get_watches(self) -> List[str]:
38 return []
39
40 @abc.abstractmethod
41 def eval(self):
42 """Evaluate the command.
43
44 This will be called when constructing a Heuristic object to determine
45 the debug score.
46
47 Returns:
48 The logic for handling the result of CommandBase.eval() must be
49 defined in Heuristic.__init__() so a consitent return type between
50 commands is not enforced.
51 """
52
53 @staticmethod
54 def get_subcommands() -> dict:
55 """Returns a dictionary of subcommands in the form {name: command} or
56 None if no subcommands are required.
57 """
58 return None