Example #1
0
    def do_break(self, arg, temporary=0, thread_name=None):
        """b(reak) {[file:]lineno | function} [thread Thread-name] [, condition]
With a line number argument, set a break there in the current file.
With a function name, set a break at first executable line of that
function.  Without argument, set a breakpoint at current location.  If
a second argument is present, it is a string specifying an expression
which must evaluate to true before the breakpoint is honored.

The line number may be prefixed with a filename and a colon,
to specify a breakpoint in another file (probably one that
hasn't been loaded yet).  The file is searched for on sys.path;
the .py suffix may be omitted.

If a thread name is given we will stop only if the the thread has that name;
dot (.) can be used to indicate the current thread."""
        
        # Decorate non-thread break to strip out 'thread Thread-name'
        args = arg.split()
        if len(args) > 2 and args[1] == 'thread':
            thread_name = args[2]
            if thread_name == '.':
                thread_name = threading.currentThread().getName()
            del args[1:3]
            arg = ' '.join(args)
        if thread_name and thread_name not in self.traced.keys():
            self.errmsg("I don't know about thread %s" % thread_name)
            if not fns.get_confirmation(self,
                                        'Really set anyway (y or n)? '):
                return
        self.nothread_do_break(self, arg, temporary=temporary,
                               thread_name=thread_name)
Example #2
0
    def do_break(self, arg, temporary=0, thread_name=None):
        """b(reak) {[file:]lineno | function} [thread Thread-name] [, condition]
With a line number argument, set a break there in the current file.
With a function name, set a break at first executable line of that
function.  Without argument, set a breakpoint at current location.  If
a second argument is present, it is a string specifying an expression
which must evaluate to true before the breakpoint is honored.

The line number may be prefixed with a filename and a colon,
to specify a breakpoint in another file (probably one that
hasn't been loaded yet).  The file is searched for on sys.path;
the .py suffix may be omitted.

If a thread name is given we will stop only if the the thread has that name;
dot (.) can be used to indicate the current thread."""

        # Decorate non-thread break to strip out 'thread Thread-name'
        args = arg.split()
        if len(args) > 2 and args[1] == 'thread':
            thread_name = args[2]
            if thread_name == '.':
                thread_name = threading.currentThread().getName()
            del args[1:3]
            arg = ' '.join(args)
        if thread_name and thread_name not in self.traced.keys():
            self.errmsg("I don't know about thread %s" % thread_name)
            if not fns.get_confirmation(self, 'Really set anyway (y or n)? '):
                return
        self.nothread_do_break(self,
                               arg,
                               temporary=temporary,
                               thread_name=thread_name)
Example #3
0
    def do_quit(self, arg):
        """If all threads are blocked in the debugger, tacitly quit. If some are not, then issue a warning and prompt for quit."""
        really_quit = True
        threading_list = threading.enumerate()
        if (len(threading_list) == 1 and
            threading_list[0].getName() == 'MainThread'):
            # We just have a main thread so that's safe to quit
            return self.nothread_quit(self, arg)
            
        if hasattr(sys, "_current_frames"):
            frames = sys._current_frames()
        else:
            frames = None

        for thread_obj in threading_list:
            thread_name = thread_obj.getName() 
            if not thread_name in self.traced.keys():
                self.msg("I don't know about state of %s"
                         % thread_name)
                really_quit = False
                break
            thread_id = self.traced[thread_name]
            if frames:
                if thread_id in frames.keys():
                    frame = frames[thread_id]
                    if not self.is_in_dbg(frame):
                        self.msg("Thread %s is not blocked by the debugger."
                                 % thread_name)
                        really_quit = False
                        break
                else:
                    self.msg("Thread ID for thread %s not found. Weird."
                             % thread_name)
                    really_quit = False
                    break
        if not really_quit:
            really_quit = fns.get_confirmation(self,
                                               'Really quit anyway (y or n)? ',
                                               True)
        self.msg("Quit for threading not fully done yet. Try kill.")
        return
        if really_quit:
            self.nothread_quit(self, arg)
Example #4
0
    def do_quit(self, arg):
        """If all threads are blocked in the debugger, tacitly quit. If some are not, then issue a warning and prompt for quit."""
        really_quit = True
        threading_list = threading.enumerate()
        if (len(threading_list) == 1
                and threading_list[0].getName() == 'MainThread'):
            # We just have a main thread so that's safe to quit
            return self.nothread_quit(self, arg)

        if hasattr(sys, "_current_frames"):
            frames = sys._current_frames()
        else:
            frames = None

        for thread_obj in threading_list:
            thread_name = thread_obj.getName()
            if not thread_name in self.traced.keys():
                self.msg("I don't know about state of %s" % thread_name)
                really_quit = False
                break
            thread_id = self.traced[thread_name]
            if frames:
                if thread_id in frames.keys():
                    frame = frames[thread_id]
                    if not self.is_in_dbg(frame):
                        self.msg("Thread %s is not blocked by the debugger." %
                                 thread_name)
                        really_quit = False
                        break
                else:
                    self.msg("Thread ID for thread %s not found. Weird." %
                             thread_name)
                    really_quit = False
                    break
        if not really_quit:
            really_quit = fns.get_confirmation(
                self, 'Really quit anyway (y or n)? ', True)
        self.msg("Quit for threading not fully done yet. Try kill.")
        return
        if really_quit:
            self.nothread_quit(self, arg)
Example #5
0
    def do_tbreak(self, arg):
        """tbreak {[file:]lineno | function} [thread Thread-name] [, condition]

Set a temporary breakpoint. Arguments are like the "break" command.
Like "break" except the breakoint is only temporary,
so it will be deleted when hit.

If a thread name is given we will stop only if the the thread has that name."""
        # Decorate non-thread break to strip out 'thread Thread-name'
        args = arg.split()
        thread_name = None
        if len(args) > 2 and args[1] == 'thread':
            thread_name = args[2]
            if thread_name == '.':
                thread_name = threading.currentThread().getName()
            if thread_name not in self.traced.keys():
                self.errmsg("I don't know about thread %s" % thread_name)
                if not fns.get_confirmation(self,
                                            'Really set anyway (y or n)? '):
                    return
            del args[1:3]
            arg = ' '.join(args)
        self.nothread_do_tbreak(self, arg, thread_name)
        return
Example #6
0
    def do_tbreak(self, arg):
        """tbreak {[file:]lineno | function} [thread Thread-name] [, condition]

Set a temporary breakpoint. Arguments are like the "break" command.
Like "break" except the breakoint is only temporary,
so it will be deleted when hit.

If a thread name is given we will stop only if the the thread has that name."""
        # Decorate non-thread break to strip out 'thread Thread-name'
        args = arg.split()
        thread_name = None
        if len(args) > 2 and args[1] == 'thread':
            thread_name = args[2]
            if thread_name == '.':
                thread_name = threading.currentThread().getName()
            if thread_name not in self.traced.keys():
                self.errmsg("I don't know about thread %s" % thread_name)
                if not fns.get_confirmation(self,
                                            'Really set anyway (y or n)? '):
                    return
            del args[1:3]
            arg = ' '.join(args)
        self.nothread_do_tbreak(self, arg, thread_name)
        return