Ejemplo n.º 1
0
    def sendcmd(self, cmd):
        """Send a cli command."""
        if not self.gdb.accepting_cmd():
            self.gdb.console_print("gdb busy: command discarded, please retry\n")
            return False

        self.gdb.gdb_busy = True
        cmd = misc.norm_unixpath(cmd)
        self.stream_record = ""
        return self.send("-interpreter-exec console %s\n", misc.quote(cmd))
Ejemplo n.º 2
0
Archivo: gdbmi.py Proyecto: 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()
Ejemplo n.º 3
0
    def get_fullpath(self, name):
        """Get the full path name for the file named 'name' and return it.

        If name is an absolute path, just stat it. Otherwise, add name to
        each directory in gdb source directories and stat the result.
        Path names are unix normalized with forward slashes.
        """

        # an absolute path name
        if os.path.isabs(name):
            if os.path.exists(name):
                return misc.norm_unixpath(name, True)
            else:
                # strip off the directory part and continue
                name = os.path.split(name)[1]

        if not name:
            return None

        # proceed with each directory in gdb source directories
        for dirname in self.directories:
            if dirname == "$cdir":
                pathname = fullname(name, self.file)
                if not pathname:
                    for source_dict in self.sources:
                        pathname = fullname(name, source_dict)
                        if pathname:
                            break
                    else:
                        continue  # main loop
            elif dirname == "$cwd":
                pathname = os.path.abspath(name)
            else:
                pathname = os.path.normpath(name)

            if os.path.exists(pathname):
                return misc.norm_unixpath(pathname, True)

        return None