Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Commit

Permalink
Usability improvements in logs buffer etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
johncf committed Sep 12, 2015
1 parent 537160c commit 392b560
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 18 deletions.
15 changes: 15 additions & 0 deletions autoload/lldb/layout.vim
Original file line number Diff line number Diff line change
@@ -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' ]
Expand All @@ -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 <buffer> i :call lldb#remote#stdin_prompt()<CR>
nnoremap <silent> <buffer> <nowait> d :call <SID>logs_clear()<CR>
nnoremap <silent> <buffer> <nowait> q :drop #<CR>
endif
call setbufvar(bnr, '&nu', 0)
call setbufvar(bnr, '&rnu', 0)
call setbufvar(bnr, '&bl', 0)
Expand Down
33 changes: 21 additions & 12 deletions autoload/lldb/remote.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function! lldb#remote#init(chan_id)
let g:lldb#_channel_id = a:chan_id
au VimLeavePre * call <SID>llnotify('exit')
au TextChanged \[lldb\]logs norm! G
au BufEnter \[lldb\]logs norm! G
call lldb#remote#define_commands()
endfun

Expand All @@ -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()
Expand All @@ -52,8 +61,8 @@ function! lldb#remote#define_commands()
\ LLmode call <SID>llnotify("mode", <f-args>)
command! -nargs=* -complete=customlist,<SID>llcomplete
\ LL call <SID>llnotify("exec", <f-args>)
command! -nargs=? -complete=customlist,<SID>stdinctrl
\ LLstdin call <SID>llnotify("stdin", <SID>stdin(<q-args>))
command! -nargs=? -complete=customlist,<SID>stdincompl
\ LLstdin call lldb#remote#stdin_prompt(<f-args>)

nnoremap <silent> <Plug>LLBreakSwitch
\ :call <SID>llnotify("breakswitch", bufnr("%"), getcurpos()[1])<CR>
Expand Down
10 changes: 5 additions & 5 deletions doc/lldb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,21 @@ 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
be in the parent directory of the currently loaded session file.

* 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.

==============================================================================
Expand Down
6 changes: 5 additions & 1 deletion rplugin/python/lldb_nvim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 392b560

Please sign in to comment.