Exemplo n.º 1
0
    def start(self, opts=None):
        """ We've already created a debugger object, but here we start
        debugging in earnest. We can also turn off debugging (but have
        the hooks suspended or not) using 'stop'.

        'opts' is a hash of every known value you might want to set when
        starting the debugger. See START_OPTS of module default.
        """

        # The below is our fancy equivalent of:
        #    sys.settrace(self._trace_dispatch)
        try:
            self.trace_hook_suspend = True
            get_option = lambda key: Mmisc.option_set(opts, key,
                                                      default.START_OPTS)

            add_hook_opts = get_option('add_hook_opts')

            # Has tracer been started?
            if not tracer.is_started() or get_option('force'):
                # FIXME: should filter out opts not for tracer

                tracer_start_opts = default.START_OPTS.copy()
                if opts:
                    tracer_start_opts.update(opts.get('tracer_start', {}))
                tracer_start_opts['trace_fn'] = self.trace_dispatch
                tracer_start_opts['add_hook_opts'] = add_hook_opts
                tracer.start(tracer_start_opts)
            elif not tracer.find_hook(self.trace_dispatch):
                tracer.add_hook(self.trace_dispatch, add_hook_opts)
                pass
            self.execution_status = 'Running'
        finally:
            self.trace_hook_suspend = False
        return
Exemplo n.º 2
0
    def start(self, opts=None):
        """ We've already created a debugger object, but here we start
        debugging in earnest. We can also turn off debugging (but have
        the hooks suspended or not) using 'stop'.

        'opts' is a hash of every known value you might want to set when
        starting the debugger. See START_OPTS of module default.
        """

        # The below is our fancy equivalent of:
        #    sys.settrace(self._trace_dispatch)
        try:
            self.trace_hook_suspend = True
            get_option = lambda key: Mmisc.option_set(opts, key,
                                                      default.START_OPTS)

            add_hook_opts = get_option('add_hook_opts')

            # Has tracer been started?
            if not tracer.is_started() or get_option('force'):
                # FIXME: should filter out opts not for tracer
                # Also, if we use opts.copy we need to check for 'None'.
                tracer_start_opts = default.START_OPTS.copy()
                tracer_start_opts['trace_fn'] = self.trace_dispatch
                tracer_start_opts['add_hook_opts'] = add_hook_opts
                tracer.start(tracer_start_opts)
            elif not tracer.find_hook(self.trace_dispatch):
                tracer.add_hook(self.trace_dispatch, add_hook_opts)
                pass
            self.execution_status = 'Running'
        finally:
            self.trace_hook_suspend = False
        return
Exemplo n.º 3
0
    def test_basic(self):
        """Basic sanity and status testing."""
        tracer.HOOKS = []
        self.assertEqual(0, tracer.size())
        self.assertEqual(False, tracer.is_started())
        tracer.start()
        self.assertEqual(True, tracer.is_started())

        tracer.stop()
        self.assertEqual(False, tracer.is_started())
        self.assertEqual(1, tracer.add_hook(my_trace_dispatch,
                                            {'backlevel': 1}))
        self.assertEqual(0, len(trace_lines))

        tracer.start()
        self.assertEqual(0, len(trace_lines))
        self.assertEqual(True, tracer.is_started())
        self.assertEqual(
            0, tracer.remove_hook(my_trace_dispatch, stop_if_empty=True))
        self.assertEqual(False, tracer.is_started())
        self.assertEqual(
            1,
            tracer.add_hook(my_trace_dispatch, {
                'start': True,
                'backlevel': 1
            }))
        self.assertEqual(True, tracer.is_started())
        tracer.clear_hooks_and_stop()
        return
Exemplo n.º 4
0
 def stop(self, options=None):
     # Our version of:
     #    sys.settrace(None)
     try:
         self.trace_hook_suspend = True
         get_option = lambda key: Mmisc.option_set(options, key,
                                                   default.STOP_OPTS)
         args = [self.trace_dispatch]
         remove = get_option('remove')
         if remove:
             args.append(remove)
             pass
         if tracer.is_started():
             try:
                 tracer.remove_hook(*args)
             except LookupError:
                 pass
             pass
     finally:
         self.trace_hook_suspend = False
     return
Exemplo n.º 5
0
 def stop(self, options=None):
     # Our version of:
     #    pdb.set_trace(None)
     try:
         self.trace_hook_suspend = True
         get_option = lambda key: Mmisc.option_set(options, key,
                                                   default.STOP_OPTS)
         args = [self.trace_dispatch]
         remove = get_option('remove')
         if remove:
             args.append(remove)
             pass
         if tracer.is_started():
             try:
                 tracer.remove_hook(*args)
             except LookupError:
                 pass
             pass
     finally:
         self.trace_hook_suspend = False
     return
Exemplo n.º 6
0
 def is_started(self):
     '''Return True if debugging is in progress.'''
     return (tracer.is_started() and
             not self.trace_hook_suspend
             and tracer.find_hook(self.trace_dispatch))
Exemplo n.º 7
0
 def is_started(self):
     '''Return True if debugging is in progress.'''
     return (tracer.is_started() and
             not self.trace_hook_suspend
             and tracer.find_hook(self.trace_dispatch))