diff --git a/autoload/lldb/layout.vim b/autoload/lldb/layout.vim index 8fe422b..76e1b31 100644 --- a/autoload/lldb/layout.vim +++ b/autoload/lldb/layout.vim @@ -1,3 +1,13 @@ +function! s:logs_clear() + if input('Clear logs [y=yes]? ') == 'y' + if expand('%') == '[lldb]logs' + set ma + norm! ggdG + set noma + endif + endif +endfun + function! lldb#layout#init_buffers() let s:buffers = [ 'backtrace', 'breakpoints', 'disassembly', \ 'locals', 'logs', 'registers', 'threads' ] @@ -10,6 +20,11 @@ function! lldb#layout#init_buffers() call setbufvar(bnr, '&swf', 0) call setbufvar(bnr, '&ma', 0) exe 'silent b ' . bnr + if bname == 'logs' + nnoremap i :call lldb#remote#stdin_prompt() + nnoremap d :call logs_clear() + nnoremap q :drop # + endif call setbufvar(bnr, '&nu', 0) call setbufvar(bnr, '&rnu', 0) call setbufvar(bnr, '&bl', 0) diff --git a/autoload/lldb/remote.vim b/autoload/lldb/remote.vim index 128ac87..8f8dd92 100644 --- a/autoload/lldb/remote.vim +++ b/autoload/lldb/remote.vim @@ -10,6 +10,7 @@ function! lldb#remote#init(chan_id) let g:lldb#_channel_id = a:chan_id au VimLeavePre * call llnotify('exit') au TextChanged \[lldb\]logs norm! G + au BufEnter \[lldb\]logs norm! G call lldb#remote#define_commands() endfun @@ -24,26 +25,34 @@ let s:ctrlchars = { 'BS': "\b", \ 'LF': "\n", \ 'NUL': "\0", \ 'SPACE': " " } -function! s:stdinctrl(A, L, P) +function! s:stdincompl(A, L, P) return keys(s:ctrlchars) + [ '--raw' ] endfun -function! s:stdin(arg) - if len(a:arg) > 0 - if has_key(s:ctrlchars, a:arg) - return s:ctrlchars[a:arg] - elseif a:arg == '--raw' - return input('raw> ') +function! lldb#remote#stdin_prompt(...) + let strin = '' + if a:0 == 1 && len(a:1) > 0 + if has_key(s:ctrlchars, a:1) + let strin = s:ctrlchars[a:1] + elseif a:1 == '--raw' + let strin = input('raw> ') else - return input("Invalid input!\nraw> ") + let strin = input("Invalid argument!\nline> ", a:1) . "\n" endif + elseif a:0 > 1 + let strin = input("Too many arguments!\nline> ", join(a:000, ' ')) . "\n" else - return input('line> ') . "\n" + let strin = input('line> ') . "\n" endif + call s:llnotify("stdin", strin) endfun function! lldb#remote#get_modes() - return rpcrequest(g:lldb#_channel_id, 'get_modes') + if exists('g:lldb#_channel_id') + return rpcrequest(g:lldb#_channel_id, 'get_modes') + else + return [] + endif endfun function! lldb#remote#define_commands() @@ -52,8 +61,8 @@ function! lldb#remote#define_commands() \ LLmode call llnotify("mode", ) command! -nargs=* -complete=customlist,llcomplete \ LL call llnotify("exec", ) - command! -nargs=? -complete=customlist,stdinctrl - \ LLstdin call llnotify("stdin", stdin()) + command! -nargs=? -complete=customlist,stdincompl + \ LLstdin call lldb#remote#stdin_prompt() nnoremap LLBreakSwitch \ :call llnotify("breakswitch", bufnr("%"), getcurpos()[1]) diff --git a/doc/lldb.txt b/doc/lldb.txt index 36b7f39..4ebd186 100644 --- a/doc/lldb.txt +++ b/doc/lldb.txt @@ -205,7 +205,9 @@ Below are some random points that might make your debugging life easier: * Do not create multiple targets -- currently not supported -* Try out `:LL command history` +* Try these out (in debug mode): `:LL help process` `:LL command history` + +* While in logs buffer, try pressing `i`, `d` or `q` * LLDB completions will be relative to the parent directory of session file. This is because regardless of the pwd of Vim, the plugin process will always @@ -213,13 +215,11 @@ Below are some random points that might make your debugging life easier: * Target should be deleted when exiting debugging mode, so that it can be re-added (after a compilation, may be) when re-entering debug mode. - - For compilation, I would suggest the neomake plugin by benekastah. + - For compiling, try using `:NeomakeSh` from neomake plugin by benekastah. -* If you have an external script, I would suggest moving all breakpoint +* If you have an external script, may I suggest moving all breakpoint management commands to the session file. -* If logs buffer is focused, it will automatically scroll down on output. - * Have a key-binding for `process interrupt` command; it will come in handy. ============================================================================== diff --git a/rplugin/python/lldb_nvim/__init__.py b/rplugin/python/lldb_nvim/__init__.py index 07b50c9..a0650c6 100644 --- a/rplugin/python/lldb_nvim/__init__.py +++ b/rplugin/python/lldb_nvim/__init__.py @@ -31,10 +31,14 @@ def _mode(self, mode): def _exec(self, *args): if args[0] == 'disassemble': self.ctrl.safe_call(self.ctrl.do_disassemble, [' '.join(args)]) - self.ctrl.vimx.command('drop [lldb]disassembly') + if self.ctrl._target is not None: + self.ctrl.vimx.command('drop [lldb]disassembly') else: self.ctrl.safe_execute(args) + if args[0] == 'help': + self.ctrl.vimx.command('drop [lldb]logs') + @neovim.rpc_export('stdin') def _stdin(self, strin): self.ctrl.safe_call(self.ctrl.put_stdin, [strin])