2014-05-14 06:14:34 -04:00
|
|
|
function! vebugger#rdebug#start(entryFile,args)
|
2014-06-23 18:46:03 -04:00
|
|
|
let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('ruby',get(a:args,'version'),'ruby'))
|
2014-05-23 10:43:01 -04:00
|
|
|
\.' -rdebug '.a:entryFile.' '.vebugger#util#commandLineArgsForProgram(a:args))
|
2014-05-14 06:14:34 -04:00
|
|
|
let l:debugger.state.rdebug={}
|
2014-05-16 11:25:45 -04:00
|
|
|
let l:debugger.state.std.config.externalFileStop_flowCommand='stepover' "skip external modules
|
2014-05-14 06:14:34 -04:00
|
|
|
|
2014-05-16 11:25:45 -04:00
|
|
|
|
|
|
|
call l:debugger.writeLine("$stdout=$stderr")
|
|
|
|
let l:debugger.pipes.err.annotation = "err&prg\t\t"
|
2014-05-22 10:21:31 -04:00
|
|
|
if !has('win32')
|
|
|
|
call vebugger#std#openShellBuffer(l:debugger)
|
|
|
|
endif
|
2014-05-16 11:25:45 -04:00
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
call l:debugger.addReadHandler(function('vebugger#rdebug#_readProgramOutput'))
|
|
|
|
call l:debugger.addReadHandler(function('vebugger#rdebug#_readWhere'))
|
|
|
|
call l:debugger.addReadHandler(function('vebugger#rdebug#_readEvaluatedExpressions'))
|
2014-05-14 06:14:34 -04:00
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
call l:debugger.setWriteHandler('std','flow',function('vebugger#rdebug#_writeFlow'))
|
|
|
|
call l:debugger.setWriteHandler('std','breakpoints',function('vebugger#rdebug#_writeBreakpoints'))
|
|
|
|
call l:debugger.setWriteHandler('std','evaluateExpressions',function('vebugger#rdebug#_requestEvaluateExpression'))
|
|
|
|
call l:debugger.setWriteHandler('std','executeStatements',function('vebugger#rdebug#_executeStatements'))
|
|
|
|
call l:debugger.setWriteHandler('std','removeAfterDisplayed',function('vebugger#rdebug#_removeAfterDisplayed'))
|
2014-05-14 06:14:34 -04:00
|
|
|
|
|
|
|
call l:debugger.generateWriteActionsFromTemplate()
|
|
|
|
|
|
|
|
call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints)
|
|
|
|
|
|
|
|
return l:debugger
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_readProgramOutput(pipeName,line,readResult,debugger)
|
2014-05-16 11:25:45 -04:00
|
|
|
if 'err'==a:pipeName
|
|
|
|
let a:readResult.std.programOutput={'line':a:line}
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_readWhere(pipeName,line,readResult,debugger)
|
2014-05-14 06:14:34 -04:00
|
|
|
if 'out'==a:pipeName
|
|
|
|
let l:matches=matchlist(a:line,'\v^([^:]+)\:(\d+)\:(.*)$')
|
|
|
|
|
|
|
|
if 3<len(l:matches)
|
|
|
|
let l:file=l:matches[1]
|
|
|
|
if !empty(glob(l:file))
|
|
|
|
let l:line=str2nr(l:matches[2])
|
|
|
|
let a:readResult.std.location={
|
|
|
|
\'file':(l:file),
|
|
|
|
\'line':(l:line)}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_writeFlow(writeAction,debugger)
|
2014-05-14 06:14:34 -04:00
|
|
|
if 'stepin'==a:writeAction
|
|
|
|
call a:debugger.writeLine('step')
|
|
|
|
elseif 'stepover'==a:writeAction
|
|
|
|
call a:debugger.writeLine('next')
|
|
|
|
elseif 'stepout'==a:writeAction
|
|
|
|
"call a:debugger.writeLine('step up')
|
|
|
|
elseif 'continue'==a:writeAction
|
|
|
|
call a:debugger.writeLine('cont')
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_writeBreakpoints(writeAction,debugger)
|
2014-05-14 06:14:34 -04:00
|
|
|
for l:breakpoint in a:writeAction
|
|
|
|
if 'add'==(l:breakpoint.action)
|
|
|
|
call a:debugger.writeLine('break '.fnameescape(l:breakpoint.file).':'.l:breakpoint.line)
|
|
|
|
elseif 'remove'==l:breakpoint.action
|
|
|
|
call a:debugger.writeLine('delete '.fnameescape(l:breakpoint.file).':'.l:breakpoint.line)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_requestEvaluateExpression(writeAction,debugger)
|
2014-05-14 06:14:34 -04:00
|
|
|
for l:evalAction in a:writeAction
|
|
|
|
call a:debugger.writeLine('display '.l:evalAction.expression)
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_executeStatements(writeAction,debugger)
|
2014-05-17 12:50:07 -04:00
|
|
|
for l:evalAction in a:writeAction
|
|
|
|
if has_key(l:evalAction,'statement')
|
|
|
|
"rdebug uses Ruby functions for commands
|
|
|
|
call a:debugger.writeLine(l:evalAction.statement)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_readEvaluatedExpressions(pipeName,line,readResult,debugger)
|
2014-05-14 06:14:34 -04:00
|
|
|
if 'out'==a:pipeName
|
|
|
|
let l:matches=matchlist(a:line,'\v^(\d+)\: (.*) \= (.*)$')
|
|
|
|
if 4<len(l:matches)
|
|
|
|
let l:id=str2nr(l:matches[1])
|
|
|
|
let l:expression=l:matches[2]
|
|
|
|
let l:value=l:matches[3]
|
|
|
|
let a:readResult.std.evaluatedExpression={
|
|
|
|
\'id':(l:id),
|
|
|
|
\'expression':(l:expression),
|
|
|
|
\'value':(l:value)}
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2015-01-23 19:12:49 -05:00
|
|
|
function! vebugger#rdebug#_removeAfterDisplayed(writeAction,debugger)
|
2014-05-14 06:14:34 -04:00
|
|
|
for l:removeAction in a:writeAction
|
|
|
|
if has_key(l:removeAction,'id')
|
|
|
|
call a:debugger.writeLine('undisplay '.l:removeAction.id)
|
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
endfunction
|