コード例 #1
0
ファイル: dbgentry.py プロジェクト: nutsi/voltron
        class VoltronVDBCommand(VoltronCommand, vtrace.Notifier):
            """
            Debugger command class for VDB
            """
            def __init__(self, vdb, vtrace):
                """
                vdb is the debugger instance
                vtrace is the vtrace module?
                """
                super(VoltronCommand, self).__init__()
                self._vdb = vdb
                self._vtrace = vtrace

                self.pm = PluginManager()

                self.adaptor = self.pm.debugger_plugin_for_host(
                    'vdb').adaptor_class(self._vdb, self._vtrace)
                voltron.debugger = self.adaptor

                self.pm.register_plugins()

                self.server = Server()
                self.server.start()

            def invoke(self, arg, from_tty):
                self.handle_command(arg)

            def register_hooks(self):
                self._vdb.registerNotifier(vtrace.NOTIFY_ALL, self)

            def unregister_hooks(self):
                self._vdb.deregisterNotifier(vtrace.NOTIFY_ALL, self)

            def notify(self, event, trace):
                if event == self._vtrace.NOTIFY_DETACH:
                    self.exit_handler(event)
                elif event == self._vtrace.NOTIFY_EXIT:
                    self.exit_handler(event)
                elif event == self._vtrace.NOTIFY_BREAK:
                    self.stop_handler(event)
                elif event == self._vtrace.NOTIFY_STEP:
                    self.stop_handler(event)
                elif event == self._vtrace.NOTIFY_CONTINUE:
                    self.cont_handler(event)

            def stop_handler(self, event):
                self.adaptor.update_state()
                log.debug('Inferior stopped')

            def exit_handler(self, event):
                log.debug('Inferior exited')
                self.server.stop()
                # vdb doesn't signal STOP/BREAK on exit, so we
                #   clear an outstanding Wait requests
                self.adaptor.update_state()

            def cont_handler(self, event):
                log.debug('Inferior continued')
コード例 #2
0
ファイル: dbgentry.py プロジェクト: changbiao/voltron
        class VoltronVDBCommand(VoltronCommand, vtrace.Notifier):
            """
            Debugger command class for VDB
            """
            def __init__(self, vdb, vtrace):
                """
                vdb is the debugger instance
                vtrace is the vtrace module?
                """
                super(VoltronCommand, self).__init__()
                self._vdb = vdb
                self._vtrace = vtrace

                self.pm = PluginManager()

                self.adaptor = self.pm.debugger_plugin_for_host('vdb').adaptor_class(self._vdb, self._vtrace)
                voltron.debugger = self.adaptor

                self.pm.register_plugins()

                self.server = Server()
                self.server.start()

            def invoke(self, arg, from_tty):
                self.handle_command(arg)

            def register_hooks(self):
                self._vdb.registerNotifier(vtrace.NOTIFY_ALL, self)

            def unregister_hooks(self):
                self._vdb.deregisterNotifier(vtrace.NOTIFY_ALL, self)

            def notify(self, event, trace):
                if event == self._vtrace.NOTIFY_DETACH:
                    self.exit_handler(event)
                elif event == self._vtrace.NOTIFY_EXIT:
                    self.exit_handler(event)
                elif event == self._vtrace.NOTIFY_BREAK:
                    self.stop_handler(event)
                elif event == self._vtrace.NOTIFY_STEP:
                    self.stop_handler(event)
                elif event == self._vtrace.NOTIFY_CONTINUE:
                    self.cont_handler(event)

            def stop_handler(self, event):
                self.adaptor.update_state()
                log.debug('Inferior stopped')

            def exit_handler(self, event):
                log.debug('Inferior exited')
                self.server.stop()
                # vdb doesn't signal STOP/BREAK on exit, so we
                #   clear an outstanding Wait requests
                self.adaptor.update_state()

            def cont_handler(self, event):
                log.debug('Inferior continued')
コード例 #3
0
ファイル: dbgentry.py プロジェクト: nutsi/voltron
        class VoltronGDBCommand(VoltronCommand, gdb.Command):
            """
            Debugger command class for GDB
            """
            def __init__(self):
                super(VoltronCommand,
                      self).__init__("voltron", gdb.COMMAND_NONE,
                                     gdb.COMPLETE_NONE)

                # load plugins
                self.pm = PluginManager()

                # set up a gdb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host(
                    'gdb').adaptor_class()
                voltron.debugger = self.adaptor

                # register plugins now that we have a debugger
                self.pm.register_plugins()

                # server is started and stopped with the inferior to avoid GDB hanging on exit
                self.server = None

            def invoke(self, arg, from_tty):
                self.handle_command(arg)

            def register_hooks(self):
                gdb.events.stop.connect(self.stop_handler)
                gdb.events.exited.connect(self.stop_and_exit_handler)
                gdb.events.cont.connect(self.cont_handler)

            def unregister_hooks(self):
                gdb.events.stop.disconnect(self.stop_handler)
                gdb.events.exited.disconnect(self.stop_and_exit_handler)
                gdb.events.cont.disconnect(self.cont_handler)

            def stop_handler(self, event):
                self.adaptor.update_state()
                self.server.dispatch_queue()
                log.debug('Inferior stopped')

            def exit_handler(self, event):
                log.debug('Inferior exited')
                self.server.stop()

            def stop_and_exit_handler(self, event):
                log.debug('Inferior stopped and exited')
                self.stop_handler(event)
                self.exit_handler(event)

            def cont_handler(self, event):
                log.debug('Inferior continued')
                if self.server == None or self.server.is_running == False:
                    self.server = Server()
                    self.server.start()
コード例 #4
0
ファイル: entry.py プロジェクト: richo/voltron
        class VoltronGDBCommand (VoltronCommand, gdb.Command):
            """
            Debugger command class for GDB
            """
            def __init__(self):
                super(VoltronCommand, self).__init__("voltron", gdb.COMMAND_NONE, gdb.COMPLETE_NONE)

                # load plugins
                self.pm = PluginManager()

                # set up a gdb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host('gdb').adaptor_class()
                voltron.debugger = self.adaptor

                # register plugins now that we have a debugger
                self.pm.register_plugins()

                # server is started and stopped with the inferior to avoid GDB hanging on exit
                self.server = None
                self.registered = False

            def invoke(self, arg, from_tty):
                self.handle_command(arg)

            def register_hooks(self):
                if not self.registered:
                    gdb.events.stop.connect(self.stop_handler)
                    gdb.events.exited.connect(self.stop_and_exit_handler)
                    gdb.events.cont.connect(self.cont_handler)

            def unregister_hooks(self):
                if self.registered:
                    gdb.events.stop.disconnect(self.stop_handler)
                    gdb.events.exited.disconnect(self.stop_and_exit_handler)
                    gdb.events.cont.disconnect(self.cont_handler)

            def stop_handler(self, event):
                self.adaptor.update_state()
                self.server.dispatch_queue()
                log.debug('Inferior stopped')

            def exit_handler(self, event):
                log.debug('Inferior exited')
                self.server.stop()

            def stop_and_exit_handler(self, event):
                log.debug('Inferior stopped and exited')
                self.stop_handler(event)
                self.exit_handler(event)

            def cont_handler(self, event):
                log.debug('Inferior continued')
                if not self.server:
                    self.server = Server()
                    self.server.start()
コード例 #5
0
            def __init__(self):
                super(VoltronCommand, self).__init__("voltron", gdb.COMMAND_NONE, gdb.COMPLETE_NONE)

                # load plugins
                self.pm = PluginManager()

                # set up a gdb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host('gdb').adaptor_class()
                voltron.debugger = self.adaptor

                # server is started and stopped with the inferior to avoid GDB hanging on exit
                self.server = None
コード例 #6
0
ファイル: lldb_api_tests.py プロジェクト: Debug-Orz/voltron
def setup():
    global adaptor, dbg, target

    log.info("setting up LLDB API tests")

    # create an LLDBAdaptor
    pm = PluginManager()
    plugin = pm.debugger_plugin_for_host('lldb')
    adaptor = plugin.adaptor_class()

    # compile and load the test inferior
    subprocess.call("cc -o tests/inferior tests/inferior.c", shell=True)
    target = adaptor.host.CreateTargetWithFileAndArch("tests/inferior", lldb.LLDB_ARCH_DEFAULT)
コード例 #7
0
def setup():
    global adaptor, dbg, target

    log.info("setting up LLDB API tests")

    # create an LLDBAdaptor
    pm = PluginManager()
    plugin = pm.debugger_plugin_for_host('lldb')
    adaptor = plugin.adaptor_class()

    # compile and load the test inferior
    subprocess.call("cc -o tests/inferior tests/inferior.c", shell=True)
    target = adaptor.host.CreateTargetWithFileAndArch("tests/inferior",
                                                      lldb.LLDB_ARCH_DEFAULT)
コード例 #8
0
ファイル: dbgentry.py プロジェクト: jhavstad/voltron
            def __init__(self, vdb, vtrace):
                """
                vdb is the debugger instance
                vtrace is the vtrace module?
                """
                super(VoltronCommand, self).__init__()
                self._vdb = vdb
                self._vtrace = vtrace

                self.pm = PluginManager()

                self.adaptor = self.pm.debugger_plugin_for_host(
                    'vdb').adaptor_class(self._vdb, self._vtrace)
                voltron.debugger = self.adaptor

                self.server = Server()
                self.server.start()
コード例 #9
0
ファイル: dbgentry.py プロジェクト: sigma-random/voltron
            def __init__(self):
                super(VoltronCommand, self).__init__("voltron", gdb.COMMAND_NONE, gdb.COMPLETE_NONE)

                # load plugins
                self.pm = PluginManager()

                # set up a gdb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host('gdb').adaptor_class()
                voltron.debugger = self.adaptor

                # server is started and stopped with the inferior to avoid GDB hanging on exit
                self.server = None
コード例 #10
0
ファイル: dbgentry.py プロジェクト: jhavstad/voltron
        class VoltronLLDBCommand(VoltronCommand):
            """
            Debugger command class for LLDB
            """
            def __init__(self, debugger, dict):
                super(VoltronCommand, self).__init__()

                # grab the debugger and command interpreter
                self.debugger = debugger
                self.ci = self.debugger.GetCommandInterpreter()

                # install the voltron command handler
                self.debugger.HandleCommand(
                    'command script add -f dbgentry.lldb_invoke voltron')

                # load plugins
                self.pm = PluginManager()

                # set up an lldb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host(
                    'lldb').adaptor_class()
                voltron.debugger = self.adaptor

                # start the server
                self.server = Server()
                self.server.start()

                self.hook_idx = None

            def invoke(self, debugger, command, result, dict):
                self.handle_command(command)

            def register_hooks(self):
                try:
                    output = self.adaptor.command("target stop-hook list")
                    if not 'voltron' in output:
                        output = self.adaptor.command(
                            'target stop-hook add -o \'voltron stopped\'')
                        try:
                            # hahaha this sucks
                            self.hook_idx = int(
                                res.GetOutput().strip().split()[2][1:])
                        except:
                            pass
                    print("Registered stop-hook")
                except:
                    print("No targets")

            def unregister_hooks(self):
                cmd = 'target stop-hook delete {}'.format(
                    self.hook_idx if self.hook_idx else '')
                self.debugger.HandleCommand(cmd)
コード例 #11
0
            def __init__(self, debugger, dict):
                super(VoltronCommand, self).__init__()

                # grab the debugger and command interpreter
                self.debugger = debugger
                self.ci = self.debugger.GetCommandInterpreter()

                # install the voltron command handler
                self.debugger.HandleCommand('command script add -f dbgentry.lldb_invoke voltron')

                # load plugins
                self.pm = PluginManager()

                # set up an lldb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host('lldb').adaptor_class()
                voltron.debugger = self.adaptor

                # start the server
                self.server = Server()
                self.server.start()

                self.hook_idx = None
コード例 #12
0
ファイル: dbgentry.py プロジェクト: creantan/voltron
            def __init__(self, vdb, vtrace):
                """
                vdb is the debugger instance
                vtrace is the vtrace module?
                """
                super(VoltronCommand, self).__init__()
                self._vdb = vdb
                self._vtrace = vtrace

                self.pm = PluginManager()

                self.adaptor = self.pm.debugger_plugin_for_host('vdb').adaptor_class(self._vdb, self._vtrace)
                voltron.debugger = self.adaptor

                self.server = Server()
                self.server.start()
コード例 #13
0
ファイル: dbgentry.py プロジェクト: sigma-random/voltron
        class VoltronLLDBCommand (VoltronCommand):
            """
            Debugger command class for LLDB
            """
            def __init__(self, debugger, dict):
                super(VoltronCommand, self).__init__()

                # grab the debugger and command interpreter
                self.debugger = debugger
                self.ci = self.debugger.GetCommandInterpreter()

                # install the voltron command handler
                self.debugger.HandleCommand('command script add -f dbgentry.lldb_invoke voltron')

                # load plugins
                self.pm = PluginManager()

                # set up an lldb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host('lldb').adaptor_class()
                voltron.debugger = self.adaptor

                # start the server
                self.server = Server()
                self.server.start()

                self.hook_idx = None

            def invoke(self, debugger, command, result, dict):
                self.handle_command(command)

            def register_hooks(self):
                try:
                    output = self.adaptor.command("target stop-hook list")
                    if not 'voltron' in output:
                        output = self.adaptor.command('target stop-hook add -o \'voltron stopped\'')
                        try:
                            # hahaha this sucks
                            self.hook_idx = int(res.GetOutput().strip().split()[2][1:])
                        except:
                            pass
                    print("Registered stop-hook")
                except:
                    print("No targets")

            def unregister_hooks(self):
                cmd = 'target stop-hook delete {}'.format(self.hook_idx if self.hook_idx else '')
                self.debugger.HandleCommand(cmd)
コード例 #14
0
ファイル: dbgentry.py プロジェクト: sigma-random/voltron
            def __init__(self, debugger, dict):
                super(VoltronCommand, self).__init__()

                # grab the debugger and command interpreter
                self.debugger = debugger
                self.ci = self.debugger.GetCommandInterpreter()

                # install the voltron command handler
                self.debugger.HandleCommand('command script add -f dbgentry.lldb_invoke voltron')

                # load plugins
                self.pm = PluginManager()

                # set up an lldb adaptor and set it as the package-wide adaptor
                self.adaptor = self.pm.debugger_plugin_for_host('lldb').adaptor_class()
                voltron.debugger = self.adaptor

                # start the server
                self.server = Server()
                self.server.start()

                self.hook_idx = None