Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / examples / python / templates / scripted_platform.py
blobfb1bde8fd4cb7aabccbcfe8b70d8736e032ce700
1 from abc import ABCMeta, abstractmethod
3 import lldb
6 class ScriptedPlatform(metaclass=ABCMeta):
8 """
9 The base class for a scripted platform.
11 Most of the base class methods are `@abstractmethod` that need to be
12 overwritten by the inheriting class.
14 DISCLAIMER: THIS INTERFACE IS STILL UNDER DEVELOPMENT AND NOT STABLE.
15 THE METHODS EXPOSED MIGHT CHANGE IN THE FUTURE.
16 """
18 processes = None
20 @abstractmethod
21 def __init__(self, exe_ctx, args):
22 """Construct a scripted platform.
24 Args:
25 exe_ctx (lldb.SBExecutionContext): The execution context for the scripted platform
26 args (lldb.SBStructuredData): A Dictionary holding arbitrary
27 key/value pairs used by the scripted platform.
28 """
29 processes = []
31 @abstractmethod
32 def list_processes(self):
33 """Get a list of processes that are running or that can be attached to on the platform.
35 processes = {
36 420: {
37 name: a.out,
38 arch: aarch64,
39 pid: 420,
40 parent_pid: 42 (optional),
41 uid: 0 (optional),
42 gid: 0 (optional),
46 Returns:
47 Dict: The processes represented as a dictionary, with at least the
48 process ID, name, architecture. Optionally, the user can also
49 provide the parent process ID and the user and group IDs.
50 The dictionary can be empty.
51 """
52 pass
54 def get_process_info(self, pid):
55 """Get the dictionary describing the process.
57 Returns:
58 Dict: The dictionary of process info that matched process ID.
59 None if the process doesn't exists
60 """
61 pass
63 @abstractmethod
64 def attach_to_process(self, attach_info):
65 """Attach to a process.
67 Args:
68 attach_info (lldb.SBAttachInfo): The information related to attach to a process.
70 Returns:
71 lldb.SBError: A status object notifying if the attach succeeded.
72 """
73 pass
75 @abstractmethod
76 def launch_process(self, launch_info):
77 """Launch a process.
79 Args:
80 launch_info (lldb.SBLaunchInfo): The information related to the process launch.
82 Returns:
83 lldb.SBError: A status object notifying if the launch succeeded.
84 """
85 pass
87 @abstractmethod
88 def kill_process(self, pid):
89 """Kill a process.
91 Args:
92 pid (int): Process ID for the process to be killed.
94 Returns:
95 lldb.SBError: A status object notifying if the shutdown succeeded.
96 """
97 pass