Ejemplo n.º 1
0
    def create_process(self, args):
        self.child = Popen(args,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Shrug(self.stdout, delim='\n')
        Stdin(self.stdin)
        event.install(self.stdout)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))

        xmap(self.stdout, 'LINE', self.handle_line)
        xmap(self.stdout, 'DELETED_BREAKPOINT', self.handle_deleted_breakpoint)
        xmap(self.stdout, 'BREAKPOINT', self.handle_breakpoint)

        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Ejemplo n.º 2
0
    def create_process(self, args):
        from os import environ, setsid
        self.child = Popen(args,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Terminator(self.stdout, delim=b'\n')
        Stdin(self.stdin)
        PdbEvents(self.stdout, self.encoding)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))

        xmap(self.stdout, 'LINE', self.handle_line)
        xmap(self.stdout, 'DELETED_BREAKPOINT', self.handle_deleted_breakpoint)
        xmap(self.stdout, 'BREAKPOINT', self.handle_breakpoint)

        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Ejemplo n.º 3
0
    def __init__(self, cmd):
        self.child   = Popen(cmd, 
        shell=True, stdout=PIPE, stdin=PIPE, preexec_fn=setsid, 
        stderr=STDOUT,  env=environ)
        

        self.stdout  = Device(self.child.stdout)
        self.stdin   = Device(self.child.stdin)
Ejemplo n.º 4
0
    def start(self):
        self.child = Popen(self.cmd,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Ejemplo n.º 5
0
    def start(self):
        print('Ibash - Bash process started...')
        self.child = Popen(self.cmd,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD,
             lambda con, data: sys.stdout.write(data.decode('utf8')))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Ejemplo n.º 6
0
    def start(self):
        self.child   = Popen(self.cmd, shell=0, stdout=PIPE, stdin=PIPE, 
                             preexec_fn=setsid, stderr=STDOUT,  env=environ)
        

        self.stdout  = Device(self.child.stdout)
        self.stdin   = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Ejemplo n.º 7
0
    def create_process(self, args):
        self.child  = Popen(args, shell=0, stdout=PIPE, stdin=PIPE, preexec_fn=setsid, 
                            stderr=STDOUT,  env=environ)
    
        self.stdout = Device(self.child.stdout)
        self.stdin  = Device(self.child.stdin)
    
        Stdout(self.stdout)
        Shrug(self.stdout, delim='\n')
        Stdin(self.stdin)
        event.install(self.stdout)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))

        xmap(self.stdout, 'LINE', self.handle_line)
        xmap(self.stdout, 'DELETED_BREAKPOINT', self.handle_deleted_breakpoint)
        xmap(self.stdout, 'BREAKPOINT', self.handle_breakpoint)

        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))
Ejemplo n.º 8
0
Archivo: debug.py Proyecto: yutzhead/vy
class Pdb(object):
    def __call__(self, area, setup={'background':'blue', 'foreground':'yellow'}):
        area.add_mode('PDB')

        area.install(('BETA', '<Key-p>', lambda event: event.widget.chmode('PDB')),
                    ('PDB', '<Key-p>', lambda event: self.stdin.dump('print %s' % event.widget.tag_get_ranges('sel', sep='\r\n'))), 
                    ('PDB', '<Key-1>', lambda event: self.start_debug(event.widget)), 
                    ('PDB', '<Key-2>', lambda event: self.start_debug_args(event.widget)), 
                    ('PDB', '<Key-q>', lambda event: self.terminate_process()), 
                    ('PDB', '<Key-c>', lambda event: self.stdin.dump('continue\r\n')), 
                    ('PDB', '<Key-e>', lambda event: self.stdin.dump('!%s' % event.widget.tag_get_ranges('sel', sep='\r\n'))), 
                    ('PDB', '<Key-w>', lambda event: self.stdin.dump('where\r\n')), 
                    ('PDB', '<Key-a>', lambda event: self.stdin.dump('args\r\n')), 
                    ('PDB', '<Key-s>', lambda event: self.stdin.dump('step\r\n')), 
                    ('PDB', '<Control-C>', lambda event: self.dump_clear_all()), 
                    ('PDB', '<Control-c>', lambda event: self.stdin.dump('clear %s\r\n' % self.map_line[(event.widget.filename, str(event.widget.indref('insert')[0]))])),
                    ('PDB', '<Key-B>', lambda event: self.stdin.dump('tbreak %s:%s\r\n' % (event.widget.filename, event.widget.indref('insert')[0]))),
                    ('PDB', '<Key-b>', lambda event: self.stdin.dump('break %s:%s\r\n' % (event.widget.filename, event.widget.indref('insert')[0]))))

        self.setup = setup

    def __init__(self):
        self.child = None
        self.map_index  = dict()
        self.map_line   = dict()

    def create_process(self, args):
        self.child  = Popen(args, shell=0, stdout=PIPE, stdin=PIPE, preexec_fn=setsid, 
                            stderr=STDOUT,  env=environ)
    
        self.stdout = Device(self.child.stdout)
        self.stdin  = Device(self.child.stdin)
    
        Stdout(self.stdout)
        Shrug(self.stdout, delim='\n')
        Stdin(self.stdin)
        event.install(self.stdout)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))

        xmap(self.stdout, 'LINE', self.handle_line)
        xmap(self.stdout, 'DELETED_BREAKPOINT', self.handle_deleted_breakpoint)
        xmap(self.stdout, 'BREAKPOINT', self.handle_breakpoint)

        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))

    def kill_debug_process(self):
        try:
            self.child.kill()
        except AttributeError:
            return

        self.delete_all_breakpoints()
        self.clear_breakpoint_map()

    def terminate_process(self):
        self.kill_debug_process()
        set_status_msg('Debug finished !')

    def start_debug(self, area):
        self.kill_debug_process()
        self.create_process(['python', '-u', '-m', 'pdb', area.filename])

        set_status_msg('Debug started !')

    def start_debug_args(self, area):
        ask  = Ask(area)
        ARGS = 'python -u -m pdb %s %s' % (area.filename, ask.data)
        ARGS = shlex.split(ARGS)

        self.kill_debug_process()
        self.create_process(ARGS)
        
        set_status_msg('Debug started ! Args: %s' % ask.data)

    def clear_breakpoint_map(self):
        self.map_index.clear()
        self.map_line.clear()

    def dump_clear_all(self):
        self.stdin.dump('clear\r\nyes\r\n')
        self.delete_all_breakpoints()
        self.clear_breakpoint_map()

    def delete_all_breakpoints(self):
        """
        It deletes all added breakpoint tags.
        It is useful when restarting pdb as a different process.
        """
    
        for index, (filename, line) in self.map_index.iteritems():
            try:
                area = get_opened_files()[filename]
            except KeyError:
                pass
            else:
                NAME = '_breakpoint_%s' % index
                area.tag_delete(NAME)        

    def handle_line(self, device, filename, line, args):
    
        """
    
        """
        try:
            area = get_opened_files()[filename]
        except  KeyError:
            pass
        else:
            set_line(area, line)
    
    def handle_deleted_breakpoint(self, device, index):
        """
        When a break point is removed.
        """

        filename, line = self.map_index[index]
        NAME           = '_breakpoint_%s' % index
        area           = None

        try:
            area = get_opened_files()[filename]
        except KeyError:
            return

        area.tag_delete(NAME)

    def handle_breakpoint(self, device, index, filename, line):
        """
        When a break point is added.
        """

        self.map_index[index]           = (filename, line)
        self.map_line[(filename, line)] = index
        map                             = get_opened_files()

        area = map[filename]
        
        NAME = '_breakpoint_%s' % index
        area.tag_add(NAME, '%s.0 linestart' % line, 
                     '%s.0 lineend' % line)
    
        area.tag_config(NAME, **self.setup)

    def dump_sigint(self, area):
        killpg(child.pid, 2)
Ejemplo n.º 9
0
class Spawn(BaseSpawn):
    def __init__(self, cmd):
        self.child   = Popen(cmd, 
        shell=True, stdout=PIPE, stdin=PIPE, preexec_fn=setsid, 
        stderr=STDOUT,  env=environ)
        

        self.stdout  = Device(self.child.stdout)
        self.stdin   = Device(self.child.stdin)

    def install_events(self):
        super(Spawn, self).install_events()

        Stdout(self.stdout)
        Stdin(self.stdin)

        self.stdout.add_map(LOAD, lambda con, data: \
        self.output.append(data))

        self.stdin.add_map(CLOSE, self.handle_close)
        self.stdout.add_map(CLOSE, self.handle_close)

    def dump_signal(self, num):
        killpg(self.child.pid, num)

    def terminate_process(self):
        self.child.kill()
        root.status.set_msg('Killed process!')

    def dump_line(self):
        data = self.input.curline().encode(self.input.charset)
        self.stdin.dump(data)
        self.input.down()

    def handle_close(self, dev, err):
        root.status.set_msg('Killed process!')
        self.stdout.destroy()
        self.stdin.destroy()
Ejemplo n.º 10
0
class Process(object):
    def __call__(self, area):
        area.install(('NORMAL', '<Control-Return>', lambda event: self.dump_region(event.widget)),
                   ('NORMAL', '<Return>', lambda event: self.dump_line(event.widget)), 
                   ('INSERT', '<F1>', lambda event: self.dump_line_and_insert_line(event.widget)),
                   ('INSERT', '<F2>', lambda event: self.dump_line_and_tab(event.widget)),
                   ('NORMAL', '<F1>', lambda event: self.dump_line_and_down(event.widget)),
                   ('NORMAL', '<Control-F1>', lambda event: self.restart()),
                   ('NORMAL', '<Control-backslash>', lambda event: self.dump_signal(3)),
                   ('NORMAL', '<Control-c>', lambda event: self.dump_signal(2)))



    def __init__(self, cmd=['bash', '-i']):
        self.cmd = cmd
        self.start()

    def start(self):
        self.child   = Popen(self.cmd, shell=0, stdout=PIPE, stdin=PIPE, 
                             preexec_fn=setsid, stderr=STDOUT,  env=environ)
        

        self.stdout  = Device(self.child.stdout)
        self.stdin   = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))

    def restart(self):
        self.child.kill()
        self.start()

        set_status_msg('Process killed and started !')

    def dump_line_and_tab(self, area):
        data = area.get('insert linestart', 'insert -1c lineend')
        data = data.encode('utf-8')
        self.stdin.dump('%s\t\t' % data)

    def dump_region(self, area):
        data = area.tag_get_ranges('sel')
        data = data.encode('utf-8')
        self.stdin.dump(data)

    def dump_line(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')
        self.stdin.dump(data)

    def dump_line_and_down(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')
        self.stdin.dump(data)
        area.down()
    
    def dump_line_and_insert_line(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')

        self.stdin.dump(data)
        area.insert_line_down()
    
    def dump_signal(self, signal):
        killpg(self.child.pid, signal)
Ejemplo n.º 11
0
class Process(object):
    def __call__(self, area):
        area.install(
            ('NORMAL', '<Control-Return>',
             lambda event: self.dump_region(event.widget)),
            ('NORMAL', '<Return>', lambda event: self.dump_line(event.widget)),
            ('INSERT', '<F1>',
             lambda event: self.dump_line_and_insert_line(event.widget)),
            ('INSERT', '<F2>',
             lambda event: self.dump_line_and_tab(event.widget)),
            ('NORMAL', '<F1>',
             lambda event: self.dump_line_and_down(event.widget)),
            ('NORMAL', '<Control-F1>', lambda event: self.restart()),
            ('NORMAL', '<Control-backslash>',
             lambda event: self.dump_signal(3)),
            ('NORMAL', '<Control-c>', lambda event: self.dump_signal(2)))

    def __init__(self, cmd=['bash', '-i']):
        self.cmd = cmd
        self.start()

    def start(self):
        self.child = Popen(self.cmd,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))

    def restart(self):
        self.child.kill()
        self.start()

        set_status_msg('Process killed and started !')

    def dump_line_and_tab(self, area):
        data = area.get('insert linestart', 'insert -1c lineend')
        data = data.encode('utf-8')
        self.stdin.dump('%s\t\t' % data)

    def dump_region(self, area):
        data = area.tag_get_ranges('sel')
        data = data.encode('utf-8')
        self.stdin.dump(data)

    def dump_line(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')
        self.stdin.dump(data)

    def dump_line_and_down(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')
        self.stdin.dump(data)
        area.down()

    def dump_line_and_insert_line(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')

        self.stdin.dump(data)
        area.insert_line_down()

    def dump_signal(self, signal):
        killpg(self.child.pid, signal)
Ejemplo n.º 12
0
from untwisted.iofile import *
from subprocess import Popen, PIPE, STDOUT
from untwisted.core import Kill

def on_close(dev, err):
    print('On CLOSE ...', err)
    lose(dev)
    raise Kill

def on_load(dev, data):
    print('On LOAD ...', data)

child   = Popen(['python2', '-i'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)

stdout  = Device(child.stdout)
stdin   = Device(child.stdin)

Stdin(stdin)
Stdout(stdout)

stdin.dump(b'print "hello world!"\n')
xmap(stdin, DUMPED, lambda dev: stdin.dump(b'quit()\n'))
xmap(stdout, LOAD, on_load)
xmap(stdin, CLOSE, on_close)
xmap(stdout, CLOSE, on_close)

core.gear.mainloop()



Ejemplo n.º 13
0
from untwisted import core
from untwisted.core import Kill


def on_close(dev, err):
    print('On CLOSE ...', err)

    dev.destroy()
    dev.close()
    raise Kill


def on_load(dev, data):
    print('On LOAD ...', data)


child = Popen(['python', '-i'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)

stdout = Device(child.stdout)
stdin = Device(child.stdin)

FileWriter(stdin)
FileReader(stdout)
stdin.dump(b'print("hello world!")\n')

stdin.add_map(DUMPED, lambda dev: stdin.dump(b'quit()\n'))
stdout.add_map(LOAD, on_load)
stdin.add_map(CLOSE, on_close)
stdout.add_map(CLOSE, on_close)

core.gear.mainloop()
Ejemplo n.º 14
0
class Process(object):
    def __call__(self, area):
        area.install('ibash', ('NORMAL', '<Control-F9>',
                               lambda event: self.dump_region(event.widget)),
                     ('NORMAL', '<Shift-Return>',
                      lambda event: self.dump_line(event.widget)),
                     ('NORMAL', '<F9>',
                      lambda event: self.ask_data_and_dump(event.widget)),
                     ('NORMAL', '<Control-C>', self.dump_signal))
        ENV['lsh'] = self.restart

    def __init__(self, cmd=['bash', '-i']):
        self.cmd = cmd
        self.start()

    def start(self):
        print('Ibash - Bash process started...')
        self.child = Popen(self.cmd,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Stdin(self.stdin)

        xmap(self.stdout, LOAD,
             lambda con, data: sys.stdout.write(data.decode('utf8')))
        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))

    def restart(self):
        """
        Restart ibash process.
        """

        self.child.kill()
        self.start()

        root.status.set_msg('Process killed and started !')

    def dump_tab(self, area):
        data = area.get('insert linestart', 'insert -1c lineend')
        data = data.encode('utf-8')
        self.stdin.dump('%s\t\t' % data)

    def dump_region(self, area):
        data = area.join_ranges('sel')
        data = data.encode('utf-8')
        self.stdin.dump(data)

    def dump_line(self, area):
        data = area.get('insert linestart', 'insert +1l linestart')
        data = data.encode('utf-8')
        self.stdin.dump(data)
        area.down()

    def ask_data_and_dump(self, area):
        ask = Ask()

        if ask.data:
            self.stdin.dump(b'%s\n' % ask.data.encode('utf-8'))

    def dump_signal(self, event):
        root.status.set_msg('(ibash) Signal number SIGINT(2)/SIGQUIT(3):')
        ask = Ask()
        signal = None

        try:
            signal = int(ask.data)
        except ValueError as e:
            root.status.set_msg('(ibash) Invalid signal')
        killpg(self.child.pid, signal)
Ejemplo n.º 15
0
from untwisted.iofile import *
from subprocess import Popen, PIPE, STDOUT
from untwisted.core import Kill


def on_close(dev, err):
    print 'On CLOSE ...', err
    lose(dev)
    raise Kill


def on_load(dev, data):
    print 'On LOAD ...', data


child = Popen(['python2', '-i'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)

stdout = Device(child.stdout)
stdin = Device(child.stdin)

Stdin(stdin)
Stdout(stdout)

stdin.dump('print "hello world!"\n')
xmap(stdin, DUMPED, lambda dev: stdin.dump('quit()\n'))
xmap(stdout, LOAD, on_load)
xmap(stdin, CLOSE, on_close)
xmap(stdout, CLOSE, on_close)

core.gear.mainloop()
Ejemplo n.º 16
0
class Pdb(object):
    setup = {'background': 'blue', 'foreground': 'yellow'}
    encoding = 'utf8'

    def __call__(self, area, python='python2'):
        self.area = area
        area.add_mode('PYTHON')

        area.install(
            'pdb', ('PYTHON', '<Key-p>', lambda event: self.send(
                'print %s' % event.widget.join_ranges('sel', sep='\r\n'))),
            ('PYTHON', '<Key-x>', lambda event: self.evaluate_expression()),
            ('PYTHON', '<Key-r>', lambda event: self.execute_statement()),
            ('PYTHON', '<Key-1>',
             lambda event: self.start_debug(event.widget)),
            ('PYTHON', '<Key-2>',
             lambda event: self.start_debug_args(event.widget)),
            ('PYTHON', '<Key-q>', lambda event: self.terminate_process()),
            ('PYTHON', '<Key-c>', lambda event: self.send('continue\r\n')),
            ('PYTHON', '<Key-e>', lambda event: self.send(
                '!%s' % event.widget.join_ranges('sel', sep='\r\n'))),
            ('PYTHON', '<Key-w>', lambda event: self.send('where\r\n')),
            ('PYTHON', '<Key-a>', lambda event: self.send('args\r\n')),
            ('PYTHON', '<Key-s>', lambda event: self.send('step\r\n')),
            ('PYTHON', '<Control-C>', lambda event: self.dump_clear_all()),
            ('PYTHON', '<Control-c>', self.remove_breakpoint),
            ('PYTHON', '<Key-B>', lambda event: self.
             send('tbreak %s:%s\r\n' %
                  (event.widget.filename, event.widget.indref('insert')[0]))),
            ('PYTHON', '<Key-b>', lambda event: self.send('break %s:%s\r\n' % (
                event.widget.filename, event.widget.indref('insert')[0]))))

        self.python = python

    def __init__(self):
        self.child = None
        self.map_index = dict()
        self.map_line = dict()

    def create_process(self, args):
        from os import environ, setsid
        self.child = Popen(args,
                           shell=0,
                           stdout=PIPE,
                           stdin=PIPE,
                           preexec_fn=setsid,
                           stderr=STDOUT,
                           env=environ)

        self.stdout = Device(self.child.stdout)
        self.stdin = Device(self.child.stdin)

        Stdout(self.stdout)
        Terminator(self.stdout, delim=b'\n')
        Stdin(self.stdin)
        PdbEvents(self.stdout, self.encoding)

        xmap(self.stdout, LOAD, lambda con, data: sys.stdout.write(data))

        xmap(self.stdout, 'LINE', self.handle_line)
        xmap(self.stdout, 'DELETED_BREAKPOINT', self.handle_deleted_breakpoint)
        xmap(self.stdout, 'BREAKPOINT', self.handle_breakpoint)

        xmap(self.stdin, CLOSE, lambda dev, err: lose(dev))
        xmap(self.stdout, CLOSE, lambda dev, err: lose(dev))

    def kill_debug_process(self):
        try:
            self.child.kill()
        except AttributeError:
            return

    def terminate_process(self):
        self.kill_debug_process()
        self.delete_all_breakpoints()
        self.clear_breakpoint_map()
        root.status.set_msg('Debug finished !')

    def start_debug(self, area):
        self.kill_debug_process()
        self.delete_all_breakpoints()
        self.clear_breakpoint_map()
        self.create_process([self.python, '-u', '-m', 'pdb', area.filename])

        root.status.set_msg('Debug started !')

    def start_debug_args(self, area):
        ask = Ask()
        ARGS = '%s -u -m pdb %s %s' % (self.python, area.filename, ask.data)

        ARGS = shlex.split(ARGS)
        self.kill_debug_process()
        self.delete_all_breakpoints()
        self.clear_breakpoint_map()

        self.create_process(ARGS)

        root.status.set_msg('Debug started ! Args: %s' % ask.data)

    def evaluate_expression(self):
        ask = Ask()
        self.send('print(%s)\r\n' % ask.data)

    def execute_statement(self):
        ask = Ask()
        self.send('!%s\r\n' % ask.data)

    def clear_breakpoint_map(self):
        self.map_index.clear()
        self.map_line.clear()

    def dump_clear_all(self):
        self.send('clear\r\nyes\r\n')
        self.delete_all_breakpoints()
        self.clear_breakpoint_map()

    def remove_breakpoint(self, event):
        self.send('clear %s\r\n' %
                  self.map_line[(event.widget.filename,
                                 str(event.widget.indref('insert')[0]))])

    def delete_all_breakpoints(self):
        """
        It deletes all added breakpoint tags.
        It is useful when restarting pdb as a different process.
        """

        widgets = AreaVi.get_opened_files(root)
        for index, (filename, line) in self.map_index.items():
            area = widgets.get(filename)
            if area:
                area.tag_delete('_breakpoint_%s' % index)

    def handle_line(self, device, filename, line, args):
        """
    
        """

        wids = AreaVi.get_opened_files(root)
        try:
            area = wids[filename]
        except KeyError:
            pass
        else:
            set_line(area, line)

    def handle_deleted_breakpoint(self, device, index):
        """
        When a break point is removed.
        """

        filename, line = self.map_index[index]
        NAME = '_breakpoint_%s' % index
        area = None

        try:
            area = AreaVi.get_opened_files(root)[filename]
        except KeyError:
            return

        area.tag_delete(NAME)

    def handle_breakpoint(self, device, index, filename, line):
        """
        When a break point is added.
        """

        self.map_index[index] = (filename, line)
        self.map_line[(filename, line)] = index
        map = AreaVi.get_opened_files(root)

        area = map[filename]

        NAME = '_breakpoint_%s' % index
        area.tag_add(NAME, '%s.0 linestart' % line, '%s.0 lineend' % line)

        area.tag_config(NAME, **self.setup)

    def dump_sigint(self, area):
        from os import killpg
        killpg(child.pid, 2)

    def send(self, data):
        self.stdin.dump(data.encode(self.encoding))