44 lines · python
1# DExTer : Debugging Experience Tester2# ~~~~~~ ~ ~~ ~ ~~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-exception7"""Abstract Base class for controlling debuggers."""8 9import abc10 11 12class DebuggerControllerBase(object, metaclass=abc.ABCMeta):13 def __init__(self, context, step_collection):14 self.context = context15 self.step_collection = step_collection16 17 @abc.abstractclassmethod18 def _run_debugger_custom(self):19 """Specify your own implementation of run_debugger_custom in your own20 controller.21 """22 pass23 24 def run_debugger(self, debugger):25 """Responsible for correctly launching and tearing down the debugger."""26 self.debugger = debugger27 28 # Fetch command line options, if any.29 the_cmdline = []30 commands = self.step_collection.commands31 if "DexCommandLine" in commands:32 cmd_line_objs = commands["DexCommandLine"]33 assert len(cmd_line_objs) == 134 cmd_line_obj = cmd_line_objs[0]35 the_cmdline = cmd_line_obj.the_cmdline36 37 with self.debugger:38 if not self.debugger.loading_error:39 self._run_debugger_custom(the_cmdline)40 41 # We may need to pickle this debugger controller after running the42 # debugger. Debuggers are not picklable objects, so set to None.43 self.debugger = None44