示例#1
0
    def __init__(self, common, efmmgr, backendStr: str, proxyCmd: str,
                 clientCmd: str):
        """ctor."""
        super().__init__(common)
        self.efmmgr = efmmgr
        self._last_command: Union[str, None] = None

        # Create new tab for the debugging view and split horizontally
        self.vim.command('tabnew'
                         ' | setlocal nowinfixwidth'
                         ' | setlocal nowinfixheight'
                         ' | silent wincmd o')

        # Get the selected backend module
        backend_maps: Dict[str, Type[base.BaseBackend]] = {
            "gdb": Gdb,
            "bashdb": BashDB,
            "lldb": Lldb,
            "pdb": Pdb,
        }
        self.backend_name = backendStr
        self.backend = backend_maps[backendStr]()

        # Initialize current line tracking
        self.cursor = Cursor(common)

        # Go to the other window and spawn gdb client
        self.client = Client(common, proxyCmd, clientCmd)

        # Initialize connection to the side channel
        self.proxy = Proxy(common, self.client)

        # Initialize breakpoint tracking
        breakpoint_impl = self.backend.create_breakpoint_impl(self.proxy)
        self.breakpoint = Breakpoint(common, self.proxy, breakpoint_impl)

        # Initialize the keymaps subsystem
        self.keymaps = Keymaps(common)

        # Initialize the windowing subsystem
        self.win = Win(common, self.cursor, self.client, self.breakpoint,
                       self.keymaps)

        # Initialize the parser
        parser_adapter = ParserAdapter(common, self.cursor, self.win)
        self.parser = self.backend.create_parser_impl(common, parser_adapter)

        # Set initial keymaps in the terminal window.
        self.keymaps.dispatch_set_t()
        self.keymaps.dispatch_set()

        # Setup 'errorformat' for the given backend.
        self.efmmgr.setup(self.backend.get_error_formats())

        # Start insert mode in the GDB window
        self.vim.feedkeys("i")
示例#2
0
文件: app.py 项目: kayspark/nvim-gdb
    def __init__(self, vim, logger, backendStr, proxyCmd, clientCmd):
        self.vim = vim
        self.log = lambda msg: logger.log('app', msg)

        # Prepare configuration: keymaps, hooks, parameters etc.
        self.config = getConfig(vim)
        self.defineSigns(self.config)

        # Create new tab for the debugging view and split horizontally
        vim.command(
            'tabnew | setlocal nowinfixwidth | setlocal nowinfixheight | exe "normal \<c-w>o"'
        )
        vim.command(self.config["split_command"])
        if len(vim.current.tabpage.windows) != 2:
            raise Exception(
                "The split_command should result in exactly two windows")

        # Enumerate the available windows
        wins = vim.current.tabpage.windows
        wcli, wjump = wins[1], wins[0]

        # Import the desired backend module
        self.backend = importlib.import_module("gdb.backend." +
                                               backendStr).init()

        # Create a temporary unique directory for all the sockets.
        self.sockDir = SockDir()

        # Initialize current line tracking
        self.cursor = Cursor(vim)

        # Go to the other window and spawn gdb client
        self.client = Client(vim, wcli, proxyCmd, clientCmd, self.sockDir)

        # Initialize connection to the side channel
        self.proxy = Proxy(vim, self.client.getProxyAddr(), self.sockDir)

        # Initialize breakpoint tracking
        self.breakpoint = Breakpoint(vim, self.config, self.proxy)

        # Initialize the keymaps subsystem
        self.keymaps = Keymaps(vim, self.config)

        # Initialize the windowing subsystem
        self.win = Win(vim, wjump, self.cursor, self.client, self.breakpoint,
                       self.keymaps)

        # Initialize the SCM
        self.scm = self.backend["initScm"](vim, logger, self.cursor, self.win)

        # Set initial keymaps in the terminal window.
        self.keymaps.dispatchSetT()
        self.keymaps.dispatchSet()

        # Start insert mode in the GDB window
        vim.feedkeys("i")
示例#3
0
    def __init__(self, common, backendStr, proxyCmd, clientCmd):
        super().__init__(common)
        self._last_command = None

        # Create new tab for the debugging view and split horizontally
        self.vim.command('tabnew'
                         ' | setlocal nowinfixwidth'
                         ' | setlocal nowinfixheight'
                         ' | silent wincmd o')
        self.vim.command(self.config.get("split_command"))
        if len(self.vim.current.tabpage.windows) != 2:
            raise Exception("The split_command should result in exactly two"
                            " windows")

        # Enumerate the available windows
        wins = self.vim.current.tabpage.windows
        wcli, wjump = wins[1], wins[0]

        # Initialize current line tracking
        self.cursor = Cursor(common)

        # Go to the other window and spawn gdb client
        self.client = Client(common, wcli, proxyCmd, clientCmd)

        # Initialize connection to the side channel
        self.proxy = Proxy(common, self.client)

        # Initialize breakpoint tracking
        self.breakpoint = Breakpoint(common, self.proxy)

        # Initialize the keymaps subsystem
        self.keymaps = Keymaps(common)

        # Initialize the windowing subsystem
        self.win = Win(common, wjump, self.cursor, self.client,
                       self.breakpoint)

        # Get the selected backend module
        backend_maps = {
            "gdb": GdbParser,
            "bashdb": BashDBParser,
            "lldb": LldbParser,
            "pdb": PdbParser
        }
        backend_class = backend_maps[backendStr]

        # Initialize the parser
        self.parser = backend_class(common, self.cursor, self.win)

        # Set initial keymaps in the terminal window.
        self.keymaps.dispatch_set_t()
        self.keymaps.dispatch_set()

        # Start insert mode in the GDB window
        self.vim.feedkeys("i")