예제 #1
0
    def __init__(self, session, win):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._buf = win.buffer
        self._session = session
        self._connection = None

        self._current_thread = None
        self._current_frame = None
        self._current_syntax = ""

        self._threads = []
        self._sources = {}
        self._scratch_buffers = []

        utils.SetUpHiddenBuffer(self._buf, 'vimspector.StackTrace')
        utils.SetUpUIWindow(win)

        vim.command('nnoremap <buffer> <CR> :call vimspector#GoToFrame()<CR>')

        self._line_to_frame = {}
        self._line_to_thread = {}

        # TODO: We really need a proper state model
        #
        # AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS
        # REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES
        #
        # When we attach using gdbserver, this whole thing breaks because we request
        # the threads over and over and get duff data back on later threads.
        self._requesting_threads = False
예제 #2
0
 def __init__(self, win, lines, draw):
     self.lines = lines
     self.draw = draw
     self.syntax = None
     if win is not None:
         self.buf = win.buffer
         utils.SetUpUIWindow(win)
예제 #3
0
    def __init__(self, session, win):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._buf = win.buffer
        self._session = session
        self._connection = None

        self._current_thread = None
        self._current_frame = None
        self._current_syntax = ""

        self._threads = []
        self._sources = {}
        self._scratch_buffers = []

        # FIXME: This ID is by group, so should be module scope
        self._next_sign_id = 1

        utils.SetUpHiddenBuffer(self._buf, 'vimspector.StackTrace')
        utils.SetUpUIWindow(win)

        mappings = settings.Dict('mappings')['stack_trace']

        with utils.LetCurrentWindow(win):
            for mapping in utils.GetVimList(mappings, 'expand_or_jump'):
                vim.command(f'nnoremap <silent> <buffer> { mapping } '
                            ':<C-U>call vimspector#GoToFrame()<CR>')

            for mapping in utils.GetVimList(mappings, 'focus_thread'):
                vim.command(f'nnoremap <silent> <buffer> { mapping } '
                            ':<C-U>call vimspector#SetCurrentThread()<CR>')

            if utils.UseWinBar():
                vim.command('nnoremenu <silent> 1.1 WinBar.Pause/Continue '
                            ':call vimspector#PauseContinueThread()<CR>')
                vim.command('nnoremenu <silent> 1.2 WinBar.Expand/Collapse '
                            ':call vimspector#GoToFrame()<CR>')
                vim.command('nnoremenu <silent> 1.3 WinBar.Focus '
                            ':call vimspector#SetCurrentThread()<CR>')

        win.options['cursorline'] = False

        if not signs.SignDefined('vimspectorCurrentThread'):
            signs.DefineSign('vimspectorCurrentThread',
                             text='▶ ',
                             double_text='▶',
                             texthl='MatchParen',
                             linehl='CursorLine')

        self._line_to_frame = {}
        self._line_to_thread = {}

        self._requesting_threads = StackTraceView.ThreadRequestState.NO
        self._pending_thread_request = None
예제 #4
0
    def __init__(self, session, connection, buf):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._buf = buf
        self._session = session
        self._connection = connection

        self._current_thread = None
        self._current_frame = None
        self._current_syntax = ""

        self._threads = []
        self._sources = {}

        utils.SetUpScratchBuffer(self._buf, 'vimspector.StackTrace')

        vim.current.buffer = self._buf
        # FIXME: Remove all usage of "Windown" and just use buffers to prevent all
        # the bugs around the window being closed.
        self._win = vim.current.window
        utils.SetUpUIWindow(self._win)

        vim.command('nnoremap <buffer> <CR> :call vimspector#GoToFrame()<CR>')

        self._line_to_frame = {}
        self._line_to_thread = {}

        # TODO: We really need a proper state model
        #
        # AWAIT_CONNECTION -- OnServerReady / RequestThreads --> REQUESTING_THREADS
        # REQUESTING -- OnGotThreads / RequestScopes --> REQUESTING_SCOPES
        #
        # When we attach using gdbserver, this whole thing breaks because we request
        # the threads over and over and get duff data back on later threads.
        self._requesting_threads = False
예제 #5
0
    def __init__(self, win, lines, draw):
        self.lines = lines
        self.draw = draw
        self.buf = win.buffer

        utils.SetUpUIWindow(win)
예제 #6
0
    def __init__(self, connection, variables_win, watches_win):
        self._logger = logging.getLogger(__name__)
        utils.SetUpLogging(self._logger)

        self._vars = View(variables_win, {}, self._DrawScopes)
        self._watch = View(watches_win, {}, self._DrawWatches)
        self._connection = connection
        self._current_syntax = ''

        # Allows us to hit <CR> to expand/collapse variables
        with utils.LetCurrentWindow(self._vars.win):
            vim.command(
                'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>')

        # This is actually the tree (scopes are alwyas the root)
        #  it's just a list of DAP scope dicts, with one magic key (_variables)
        #  _variables is a list of DAP variable with the same magic key
        #
        # If _variables is present, then we have requested and should display the
        # children. Otherwise, we haven't or shouldn't.
        self._scopes = []

        # This is similar to scopes, but the top level is an "expression" (request)
        # containing a special '_result' key which is the response. The response
        # structure con contain _variables and is handled identically to the scopes
        # above. It also has a special _line key which is where we printed it (last)
        self._watches = []

        # Allows us to hit <CR> to expand/collapse variables
        with utils.LetCurrentWindow(self._watch.win):
            vim.command(
                'nnoremap <buffer> <CR> :call vimspector#ExpandVariable()<CR>')
            vim.command(
                'nnoremap <buffer> <DEL> :call vimspector#DeleteWatch()<CR>')

            vim.command('nnoremenu 1.1 WinBar.New '
                        ':call vimspector#AddWatch()<CR>')
            vim.command('nnoremenu 1.2 WinBar.Expand/Collapse '
                        ':call vimspector#ExpandVariable()<CR>')
            vim.command('nnoremenu 1.3 WinBar.Delete '
                        ':call vimspector#DeleteWatch()<CR>')

        utils.SetUpScratchBuffer(self._vars.win.buffer, 'vimspector.Variables')
        utils.SetUpPromptBuffer(self._watch.win.buffer, 'vimspector.Watches',
                                'Expression: ', 'vimspector#AddWatchPrompt')

        utils.SetUpUIWindow(self._vars.win)
        utils.SetUpUIWindow(self._watch.win)

        has_balloon = int(vim.eval("has( 'balloon_eval' )"))
        has_balloon_term = int(vim.eval("has( 'balloon_eval_term' )"))

        self._oldoptions = {}
        if has_balloon or has_balloon_term:
            self._oldoptions = {
                'balloonexpr': vim.options['balloonexpr'],
                'balloondelay': vim.options['balloondelay'],
            }
            vim.options[
                'balloonexpr'] = 'vimspector#internal#balloon#BalloonExpr()'
            vim.options['balloondelay'] = 250

        if has_balloon:
            self._oldoptions['ballooneval'] = vim.options['ballooneval']
            vim.options['ballooneval'] = True

        if has_balloon_term:
            self._oldoptions['balloonevalterm'] = vim.options[
                'balloonevalterm']
            vim.options['balloonevalterm'] = True

        self._is_term = not bool(int(vim.eval("has( 'gui_running' )")))