Example #1
0
File: gdbmi.py Project: Skip/vim
 def handle_result(self, line):
     """Process gdb/mi result."""
     matchobj = re_evaluate.match(line)
     if matchobj:
         self.result = misc.unquote(matchobj.group('value'))
         if self.result:
             self.gdb.show_balloon('%s = "%s"' % (self.text, self.result))
Example #2
0
 def handle_result(self, line):
     """Process gdb/mi result."""
     matchobj = re_evaluate.match(line)
     if matchobj:
         self.result = misc.unquote(matchobj.group("value"))
         if self.result:
             self.gdb.show_balloon('%s = "%s"' % (self.text, self.result))
     elif not "Attempt to use a type name as an expression" in line:
         self.gdb.show_balloon("%s: %s" % (self.text, line))
Example #3
0
def parse_msg(msg):
    """Parse a received netbeans message.

    Return the (None,) tuple or the tuple:
        is_event: boolean
            True: an event - False: a reply
        buf_id: int
            netbeans buffer number
        event: str
            event name
        seqno: int
            netbeans sequence number
        nbstring: str
            the netbeans string
        arg_list: list
            list of remaining args after the netbeans string

    """
    matchobj = re_event.match(msg)
    if matchobj:
        # an event
        bufid_name = matchobj.group('buf_id')
        event = matchobj.group('event')
    else:
        # a reply
        bufid_name = '0'
        event = ''
        matchobj = re_response.match(msg)
    if not matchobj:
        error('discarding invalid netbeans message: "%s"', msg)
        return (None,)

    seqno = matchobj.group('seqno')
    args = matchobj.group('args').strip()
    try:
        buf_id = int(bufid_name)
        seqno = int(seqno)
    except ValueError:
        assert False, 'error in regexp'

    # a netbeans string
    nbstring = ''
    if args and args[0] == misc.DOUBLEQUOTE:
        end = args.rfind(misc.DOUBLEQUOTE)
        if end != -1 and end != 0:
            nbstring = args[1:end]
            # do not unquote nbkey parameter twice since vim already parses
            # function parameters as strings (see :help expr-quote)
            if event != 'keyAtPos':
                nbstring = misc.unquote(nbstring)
        else:
            end = -1
    else:
        end = -1
    arg_list = args[end+1:].split()

    return (matchobj.re is re_event), buf_id, event, seqno, nbstring, arg_list
Example #4
0
File: gdbmi.py Project: Skip/vim
 def handle_result(self, line):
     """Handle gdb/mi result, print an error message."""
     errmsg = 'error,msg='
     if line.startswith(errmsg):
         line = line[len(errmsg):]
         matchobj = misc.re_quoted.match(line)
         if matchobj:
             line = misc.unquote(matchobj.group(1))
             self.gdb.console_print('%s\n' % line)
             return
     info(line)
Example #5
0
 def handle_result(self, line):
     """Handle gdb/mi result, print an error message."""
     errmsg = "error,msg="
     if line.startswith(errmsg):
         line = line[len(errmsg) :]
         matchobj = misc.re_quoted.match(line)
         if matchobj:
             line = misc.unquote(matchobj.group(1))
             # do not repeat the log stream record
             if line + "\n" != self.stream_record:
                 self.gdb.console_print("%s\n" % line)
             return
     info(line)
Example #6
0
 def process_stream_record(self, line):
     """Process a received gdb/mi stream record."""
     matchobj = misc.re_quoted.match(line[1:])
     annotation_lvl1 = re_anno_1.match(line)
     if annotation_lvl1 is not None:
         return
     if matchobj:
         line = misc.unquote(matchobj.group(1))
         if (not self.stream_record and line == '[0] cancel\n[1] all\n') \
                 or (not self.multiple_choice                            \
                         and len(self.stream_record) == 1                \
                         and self.stream_record[0] == '[0] cancel\n'     \
                         and line.startswith('[1] all\n')):
             self.multiple_choice = _timer()
         self.stream_record.append(line)
     else:
         warning('process_stream_record: bad format: "%s"', line)
Example #7
0
 def process_stream_record(self, line):
     """Process a received gdb/mi stream record."""
     matchobj = misc.re_quoted.match(line[1:])
     annotation_lvl1 = re_anno_1.match(line)
     if annotation_lvl1 is not None:
         return
     if matchobj:
         line = misc.unquote(matchobj.group(1))
         if (not self.stream_record and line == '[0] cancel\n[1] all\n') \
                 or (not self.multiple_choice                            \
                         and len(self.stream_record) == 1                \
                         and self.stream_record[0] == '[0] cancel\n'     \
                         and line.startswith('[1] all\n')):
             self.multiple_choice = _timer()
         self.stream_record.append(line)
     else:
         warning('process_stream_record: bad format: "%s"', line)
Example #8
0
File: gdbmi.py Project: Skip/vim
    def __call__(self):
        """Write the project file."""
        if self.project_name:
            # write the project file
            errmsg = ''
            gdb_info = self.gdb.info
            quitting = (self.gdb.state == self.gdb.STATE_QUITTING)
            if gdb_info.debuggee:
                try:
                    project = open(self.project_name, 'w+b')

                    if gdb_info.cwd:
                        cwd = gdb_info.cwd[0]
                        if not cwd.endswith(os.sep):
                            cwd += os.sep
                        project.write('cd %s\n'
                            % misc.norm_unixpath(misc.unquote(cwd), True))

                    project.write('file %s\n'
                            % misc.norm_unixpath(gdb_info.debuggee[0], True))

                    if gdb_info.args:
                        project.write('set args %s\n' % gdb_info.args[0])

                    self.save_breakpoints(project)

                    project.close()

                    msg = 'Project \'%s\' has been saved.' % self.project_name
                    info(msg)
                    self.gdb.console_print('%s\n', msg)
                    if not quitting:
                        self.gdb.prompt()
                except IOError, errmsg:
                    pass
            else:
                errmsg = 'Project \'%s\' not saved:'    \
                         ' no executable file specified.' % self.project_name
            if errmsg:
                error(errmsg)
                self.gdb.console_print('%s\n', errmsg)
                if not quitting:
                    self.gdb.prompt()
Example #9
0
    def handle_line(self, line):
        """Process the line received from gdb."""
        if self.fileasync is None:
            return

        debug(line)
        if not line:
            error('handle_line: processing an empty line')
            return

        # gdb/mi stream record
        if line.startswith('> ~"'):
            # remove the '> ' prompt after a multiple choice
            line = line[2:]
        if line[0] in '~@':
            self.process_stream_record(line)
        elif line[0] in '&':
            # write the 'log' stream record to the console
            matchobj = misc.re_quoted.match(line[1:])
            if matchobj:
                line = misc.unquote(matchobj.group(1))
                self.stream_record.append(line)
            else:
                warning('bad format in gdb/mi log: "%s"', line)
        elif line[0] in '*+=':
            # ignore ''async' records
            info(line[1:])
        else:
            matchobj = re_mirecord.match(line)
            # a gdb/mi result or out of band record
            if matchobj:
                self.process_mi_record(matchobj)
            # gdb/mi prompt
            elif line == '(gdb) ':
                self.process_prompt()
            else:
                # on Windows, the inferior output is redirected by gdb
                # to the pipe when 'new-console' is not set
                warning('handle_line: bad format: "%s"', line)
Example #10
0
    def handle_line(self, line):
        """Process the line received from gdb."""
        if self.fileasync is None:
            return

        debug(line)
        if not line:
            error('handle_line: processing an empty line')
            return

        # gdb/mi stream record
        if line.startswith('> ~"'):
            # remove the '> ' prompt after a multiple choice
            line = line[2:]
        if line[0] in '~@':
            self.process_stream_record(line)
        elif line[0] in '&':
            # ignore a 'log' stream record
            matchobj = misc.re_quoted.match(line[1:])
            if matchobj:
                line = misc.unquote(matchobj.group(1))
                info(line)
            else:
                warning('bad format in gdb/mi log: "%s"', line)
        elif line[0] in '*+=':
            # ignore ''async' records
            info(line[1:])
        else:
            matchobj = re_mirecord.match(line)
            # a gdb/mi result or out of band record
            if matchobj:
                self.process_mi_record(matchobj)
            # gdb/mi prompt
            elif line == '(gdb) ':
                self.process_prompt()
            else:
                # on Windows, the inferior output is redirected by gdb
                # to the pipe when 'new-console' is not set
                warning('handle_line: bad format: "%s"', line)