Change the code path of user actions
Most user actions now go through vebugger#userAction, which calls the user action on the active debugger object. The exceptions are: - Starting the debugger - because we don't have an active debugger yet - Stopping the debugger - because we'll need to clear the active debugger after that - Altering breakpoints - because we want to be able to do it even without an active debugger(e.g. - setting breakpoints before starting the debugger)
This commit is contained in:
parent
3f13848d67
commit
4567ad166b
@ -222,11 +222,23 @@ function! s:f_debugger.setWriteAction(namespace,name,value) dict
|
||||
let self.writeActions[a:namespace][a:name]=a:value
|
||||
endfunction
|
||||
|
||||
"Set a write action and perform it
|
||||
function! s:f_debugger.setWriteActionAndPerform(namespace, name, value) dict
|
||||
call self.setWriteAction(a:namespace, a:name, a:value)
|
||||
call self.performWriteActions()
|
||||
endfunction
|
||||
|
||||
"Add a write action of a specific namespace and name, for write actions that supports a list
|
||||
function! s:f_debugger.addWriteAction(namespace,name,value) dict
|
||||
call add(self.writeActions[a:namespace][a:name],a:value)
|
||||
endfunction
|
||||
|
||||
"Add a write action and perform it
|
||||
function! s:f_debugger.addWriteActionAndPerform(namespace, name, value) dict
|
||||
call self.addWriteAction(a:namespace, a:name, a:value)
|
||||
call self.performWriteActions()
|
||||
endfunction
|
||||
|
||||
"Create a bare debugger object from a raw shell line
|
||||
function! vebugger#createDebugger(command)
|
||||
|
||||
@ -283,6 +295,16 @@ function! vebugger#killDebugger()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! vebugger#userAction(action, ...)
|
||||
if exists('s:debugger')
|
||||
if has_key(s:debugger, a:action)
|
||||
call call(s:debugger[a:action], a:000, s:debugger)
|
||||
else
|
||||
throw 'Current debugger does not support action '.a:action
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Write a line to the currently active debugger
|
||||
function! vebugger#writeLine(line)
|
||||
if exists('s:debugger')
|
||||
@ -297,13 +319,6 @@ function! vebugger#invokeReading()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Toggle the terminal buffer for the currently active debugger
|
||||
function! vebugger#toggleTerminalBuffer()
|
||||
if exists('s:debugger')
|
||||
call s:debugger.toggleTerminalBuffer()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Fetch the currently active debugger object
|
||||
function! vebugger#getActiveDebugger()
|
||||
if exists('s:debugger')
|
||||
@ -312,36 +327,3 @@ function! vebugger#getActiveDebugger()
|
||||
return {}
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Set a write action for the currently active debugger
|
||||
function! vebugger#setWriteAction(namespace,name,value)
|
||||
if exists('s:debugger')
|
||||
call s:debugger.setWriteAction(a:namespace,a:name,a:value)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Add a write action to the currently active debugger
|
||||
function! vebugger#addWriteAction(namespace,name,value)
|
||||
if exists('s:debugger')
|
||||
call s:debugger.addWriteAction(a:namespace,a:name,a:value)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Force performing all the write of the currently active debugger
|
||||
function! vebugger#performWriteActions()
|
||||
if exists('s:debugger')
|
||||
call s:debugger.performWriteActions()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Set a write action for the currently active debugger and perform it
|
||||
function! vebugger#setWriteActionAndPerform(namespace,name,value)
|
||||
call vebugger#setWriteAction(a:namespace,a:name,a:value)
|
||||
call vebugger#performWriteActions()
|
||||
endfunction
|
||||
|
||||
"Add a write action to the currently active debugger and perform it
|
||||
function! vebugger#addWriteActionAndPerform(namespace,name,value)
|
||||
call vebugger#addWriteAction(a:namespace,a:name,a:value)
|
||||
call vebugger#performWriteActions()
|
||||
endfunction
|
||||
|
@ -271,19 +271,23 @@ function! vebugger#std#toggleBreakpoint(file,line)
|
||||
let l:breakpoint=g:vebugger_breakpoints[l:i]
|
||||
if l:breakpoint.file==a:file && l:breakpoint.line==a:line
|
||||
call remove(g:vebugger_breakpoints,l:i)
|
||||
call vebugger#addWriteActionAndPerform('std','breakpoints',{
|
||||
if !empty(l:debugger)
|
||||
call l:debugger.addWriteActionAndPerform('std','breakpoints',{
|
||||
\'action':'remove',
|
||||
\'file':(a:file),
|
||||
\'line':(a:line)})
|
||||
endif
|
||||
call vebugger#std#updateMarksForFile(l:debuggerState,a:file)
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
call add(g:vebugger_breakpoints,{'file':(a:file),'line':(a:line)})
|
||||
call vebugger#addWriteActionAndPerform('std','breakpoints',{
|
||||
if !empty(l:debugger)
|
||||
call l:debugger.addWriteActionAndPerform('std','breakpoints',{
|
||||
\'action':'add',
|
||||
\'file':(a:file),
|
||||
\'line':(a:line)})
|
||||
endif
|
||||
call vebugger#std#updateMarksForFile(l:debuggerState,a:file)
|
||||
endfunction
|
||||
|
||||
@ -296,27 +300,15 @@ function! vebugger#std#clearBreakpoints()
|
||||
if index(l:files,l:breakpoint.file)<0
|
||||
call add(l:files,l:breakpoint.file)
|
||||
endif
|
||||
call vebugger#addWriteAction('std','breakpoints',extend({'action':'remove'},l:breakpoint))
|
||||
if !empty(l:debugger)
|
||||
call l:debugger.addWriteAction('std','breakpoints',extend({'action':'remove'},l:breakpoint))
|
||||
endif
|
||||
endfor
|
||||
call vebugger#performWriteActions()
|
||||
if !empty(l:debugger)
|
||||
call l:debugger.performWriteActions()
|
||||
endif
|
||||
let g:vebugger_breakpoints=[]
|
||||
for l:file in l:files
|
||||
call vebugger#std#updateMarksForFile(l:debuggerState,l:file)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"Ask the active debugger to evaluate an expression
|
||||
function! vebugger#std#eval(expression)
|
||||
let l:debugger=vebugger#getActiveDebugger()
|
||||
if !empty(l:debugger) && !empty(l:debugger.std_eval)
|
||||
call l:debugger.std_eval(a:expression)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"Ask the active debugger to execute a statement
|
||||
function! vebugger#std#execute(statement)
|
||||
let l:debugger=vebugger#getActiveDebugger()
|
||||
if !empty(l:debugger) && !empty(l:debugger.std_eval)
|
||||
call l:debugger.std_execute(a:statement)
|
||||
endif
|
||||
endfunction
|
||||
|
@ -1,25 +1,25 @@
|
||||
|
||||
|
||||
command! -nargs=1 VBGrawWrite call vebugger#writeLine(<q-args>)
|
||||
command! -nargs=1 VBGrawWrite call vebugger#userAction('writeLine', <q-args>)
|
||||
command! -nargs=0 VBGkill call vebugger#killDebugger()
|
||||
|
||||
command! -nargs=0 VBGstepIn call vebugger#setWriteActionAndPerform('std','flow','stepin')
|
||||
command! -nargs=0 VBGstepOver call vebugger#setWriteActionAndPerform('std','flow','stepover')
|
||||
command! -nargs=0 VBGstepOut call vebugger#setWriteActionAndPerform('std','flow','stepout')
|
||||
command! -nargs=0 VBGcontinue call vebugger#setWriteActionAndPerform('std','flow','continue')
|
||||
command! -nargs=0 VBGstepIn call vebugger#userAction('setWriteActionAndPerform', 'std', 'flow', 'stepin')
|
||||
command! -nargs=0 VBGstepOver call vebugger#userAction('setWriteActionAndPerform', 'std', 'flow', 'stepover')
|
||||
command! -nargs=0 VBGstepOut call vebugger#userAction('setWriteActionAndPerform', 'std', 'flow', 'stepout')
|
||||
command! -nargs=0 VBGcontinue call vebugger#userAction('setWriteActionAndPerform', 'std', 'flow', 'continue')
|
||||
|
||||
command! -nargs=0 VBGtoggleTerminalBuffer call vebugger#toggleTerminalBuffer()
|
||||
command! -nargs=0 VBGtoggleTerminalBuffer call vebugger#userAction('toggleTerminalBuffer')
|
||||
command! -nargs=+ -complete=file VBGtoggleBreakpoint call vebugger#std#toggleBreakpoint(<f-args>)
|
||||
command! -nargs=0 VBGtoggleBreakpointThisLine call vebugger#std#toggleBreakpoint(expand('%:~:.'),line('.'))
|
||||
command! -nargs=0 VBGclearBreakpints call vebugger#std#clearBreakpoints()
|
||||
|
||||
command! -nargs=1 VBGeval call vebugger#std#eval(<q-args>)
|
||||
command! -nargs=0 VBGevalWordUnderCursor call vebugger#std#eval(expand('<cword>'))
|
||||
command! -nargs=1 VBGexecute call vebugger#std#execute(<q-args>)
|
||||
command! -nargs=1 VBGeval call vebugger#userAction('std_eval', <q-args>)
|
||||
command! -nargs=0 VBGevalWordUnderCursor call vebugger#userAction('std_eval', expand('<cword>'))
|
||||
command! -nargs=1 VBGexecute call vebugger#userAction('std_execute', <q-args>)
|
||||
|
||||
command! -range -nargs=0 VBGevalSelectedText call vebugger#std#eval(vebugger#util#get_visual_selection())
|
||||
command! -range -nargs=0 VBGexecuteSelectedText call vebugger#std#execute(vebugger#util#get_visual_selection())
|
||||
command! -range -nargs=0 VBGrawWriteSelectedText call vebugger#writeLine(vebugger#util#get_visual_selection())
|
||||
command! -range -nargs=0 VBGevalSelectedText call vebugger#userAction('std_eval', vebugger#util#get_visual_selection())
|
||||
command! -range -nargs=0 VBGexecuteSelectedText call vebugger#userAction('std_execute', vebugger#util#get_visual_selection())
|
||||
command! -range -nargs=0 VBGrawWriteSelectedText call vebugger#userAction('writeLine', vebugger#util#get_visual_selection())
|
||||
|
||||
command! -nargs=+ -complete=file VBGstartGDB call vebugger#gdb#start([<f-args>][0],{'args':[<f-args>][1:]})
|
||||
function! s:attachGDB(...)
|
||||
|
Loading…
Reference in New Issue
Block a user