Fix #86 - JDB eval show both eval
and dump
of object
This commit is contained in:
parent
9bf2984d13
commit
15ab930a6c
@ -1,70 +1,70 @@
|
|||||||
function! vebugger#jdb#start(entryClass,args)
|
function! vebugger#jdb#start(entryClass,args)
|
||||||
let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('jdb',get(a:args,'version'),'jdb'))
|
let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('jdb',get(a:args,'version'),'jdb'))
|
||||||
\.(has_key(a:args,'classpath') && !has_key(a:args,'attach') ? ' -classpath '.fnameescape(a:args.classpath) : '')
|
\.(has_key(a:args,'classpath') && !has_key(a:args,'attach') ? ' -classpath '.fnameescape(a:args.classpath) : '')
|
||||||
\.(has_key(a:args,'attach') ? ' -attach '.shellescape(a:args.attach) : ''))
|
\.(has_key(a:args,'attach') ? ' -attach '.shellescape(a:args.attach) : ''))
|
||||||
let l:debugger.state.jdb={}
|
let l:debugger.state.jdb={}
|
||||||
if has_key(a:args,'srcpath')
|
if has_key(a:args,'srcpath')
|
||||||
let l:debugger.state.jdb.srcpath=a:args.srcpath
|
let l:debugger.state.jdb.srcpath=a:args.srcpath
|
||||||
else
|
else
|
||||||
let l:debugger.state.jdb.srcpath='.'
|
let l:debugger.state.jdb.srcpath='.'
|
||||||
endif
|
endif
|
||||||
let l:debugger.state.jdb.filesToClassesMap={}
|
let l:debugger.state.jdb.filesToClassesMap={}
|
||||||
|
|
||||||
if !has_key(a:args,'attach')
|
if !has_key(a:args,'attach')
|
||||||
call l:debugger.writeLine('stop on '.a:entryClass.'.main')
|
call l:debugger.writeLine('stop on '.a:entryClass.'.main')
|
||||||
call l:debugger.writeLine('run '.a:entryClass.' '.vebugger#util#commandLineArgsForProgram(a:args))
|
call l:debugger.writeLine('run '.a:entryClass.' '.vebugger#util#commandLineArgsForProgram(a:args))
|
||||||
else
|
else
|
||||||
call l:debugger.writeLine('run')
|
call l:debugger.writeLine('run')
|
||||||
endif
|
endif
|
||||||
call l:debugger.writeLine('monitor where')
|
call l:debugger.writeLine('monitor where')
|
||||||
if !has('win32') && !has_key(a:args,'attach')
|
if !has('win32') && !has_key(a:args,'attach')
|
||||||
call vebugger#std#openShellBuffer(l:debugger)
|
call vebugger#std#openShellBuffer(l:debugger)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call l:debugger.addReadHandler(function('vebugger#jdb#_readProgramOutput'))
|
call l:debugger.addReadHandler(function('vebugger#jdb#_readProgramOutput'))
|
||||||
call l:debugger.addReadHandler(function('vebugger#jdb#_readWhere'))
|
call l:debugger.addReadHandler(function('vebugger#jdb#_readWhere'))
|
||||||
call l:debugger.addReadHandler(function('vebugger#jdb#_readException'))
|
call l:debugger.addReadHandler(function('vebugger#jdb#_readException'))
|
||||||
call l:debugger.addReadHandler(function('vebugger#jdb#_readEvaluatedExpressions'))
|
call l:debugger.addReadHandler(function('vebugger#jdb#_readEvaluatedExpressions'))
|
||||||
|
|
||||||
call l:debugger.setWriteHandler('std','flow',function('vebugger#jdb#_writeFlow'))
|
call l:debugger.setWriteHandler('std','flow',function('vebugger#jdb#_writeFlow'))
|
||||||
call l:debugger.setWriteHandler('std','breakpoints',function('vebugger#jdb#_writeBreakpoints'))
|
call l:debugger.setWriteHandler('std','breakpoints',function('vebugger#jdb#_writeBreakpoints'))
|
||||||
call l:debugger.setWriteHandler('std','evaluateExpressions',function('vebugger#jdb#_requestEvaluateExpression'))
|
call l:debugger.setWriteHandler('std','evaluateExpressions',function('vebugger#jdb#_requestEvaluateExpression'))
|
||||||
call l:debugger.setWriteHandler('std','executeStatements',function('vebugger#jdb#_executeStatements'))
|
call l:debugger.setWriteHandler('std','executeStatements',function('vebugger#jdb#_executeStatements'))
|
||||||
|
|
||||||
call l:debugger.generateWriteActionsFromTemplate()
|
call l:debugger.generateWriteActionsFromTemplate()
|
||||||
|
|
||||||
call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints)
|
call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints)
|
||||||
|
|
||||||
return l:debugger
|
return l:debugger
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#attach(address, ...)
|
function! vebugger#jdb#attach(address, ...)
|
||||||
let l:args = a:0 ? a:{1} : {}
|
let l:args = a:0 ? a:{1} : {}
|
||||||
let l:args.attach = a:address
|
let l:args.attach = a:address
|
||||||
call vebugger#jdb#start('', l:args)
|
call vebugger#jdb#start('', l:args)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_readProgramOutput(pipeName,line,readResult,debugger) dict
|
function! vebugger#jdb#_readProgramOutput(pipeName,line,readResult,debugger) dict
|
||||||
if 'out'==a:pipeName
|
if 'out'==a:pipeName
|
||||||
if a:line=~'\v^\> \>'
|
if a:line=~'\v^\> \>'
|
||||||
\||a:line=='> '
|
\||a:line=='> '
|
||||||
\||a:line=~'\v^Step completed'
|
\||a:line=~'\v^Step completed'
|
||||||
\||a:line=~'\v^Breakpoint hit'
|
\||a:line=~'\v^Breakpoint hit'
|
||||||
\||a:line=~'\v^\> Deferring breakpoint'
|
\||a:line=~'\v^\> Deferring breakpoint'
|
||||||
\||a:line=='Nothing suspended.'
|
\||a:line=='Nothing suspended.'
|
||||||
\||a:line=~'\v^\> run ' "Signs that the output finished
|
\||a:line=~'\v^\> run ' "Signs that the output finished
|
||||||
let self.programOutputMode=0
|
let self.programOutputMode=0
|
||||||
elseif a:line=~'\v(step|step up|next|cont)$' "Next line should be output
|
elseif a:line=~'\v(step|step up|next|cont)$' "Next line should be output
|
||||||
let self.programOutputMode=1
|
let self.programOutputMode=1
|
||||||
elseif a:line=~'\v^\> [^>]' "Start of output
|
elseif a:line=~'\v^\> [^>]' "Start of output
|
||||||
let a:readResult.std.programOutput={'line':substitute(a:line,'\v^\> ','','')}
|
let a:readResult.std.programOutput={'line':substitute(a:line,'\v^\> ','','')}
|
||||||
let self.programOutputMode=1
|
let self.programOutputMode=1
|
||||||
elseif get(self,'programOutputMode')
|
elseif get(self,'programOutputMode')
|
||||||
let a:readResult.std.programOutput={'line':a:line}
|
let a:readResult.std.programOutput={'line':a:line}
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let a:readResult.std.programOutput={'line':a:line}
|
let a:readResult.std.programOutput={'line':a:line}
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:getTagContainingString(tag, str)
|
function! s:getTagContainingString(tag, str)
|
||||||
@ -107,106 +107,139 @@ function! s:findFolderFromStackTrace(src,nameFromStackTrace,frameNumber)
|
|||||||
let l:path=l:nextPath
|
let l:path=l:nextPath
|
||||||
endfor
|
endfor
|
||||||
endfor
|
endfor
|
||||||
return l:path
|
return l:path
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_readWhere(pipeName,line,readResult,debugger)
|
function! vebugger#jdb#_readWhere(pipeName,line,readResult,debugger)
|
||||||
if 'out'==a:pipeName
|
if 'out'==a:pipeName
|
||||||
let l:matches=matchlist(a:line,'\v\s*\[(\d+)]\s*(\S+)\s*\(([^:]*):(\d*)\)')
|
let l:matches=matchlist(a:line,'\v\s*\[(\d+)]\s*(\S+)\s*\(([^:]*):(\d*)\)')
|
||||||
if 4<len(l:matches)
|
if 4<len(l:matches)
|
||||||
let l:frameNumber=str2nr(l:matches[1])
|
let l:frameNumber=str2nr(l:matches[1])
|
||||||
let l:file=s:findFolderFromStackTrace(a:debugger.state.jdb.srcpath,l:matches[2],l:frameNumber).'/'.l:matches[3]
|
let l:file=s:findFolderFromStackTrace(a:debugger.state.jdb.srcpath,l:matches[2],l:frameNumber).'/'.l:matches[3]
|
||||||
let l:file=fnamemodify(l:file,':p')
|
let l:file=fnamemodify(l:file,':p')
|
||||||
if 1==l:frameNumber " first stackframe is the current location
|
if 1==l:frameNumber " first stackframe is the current location
|
||||||
let a:readResult.std.location={
|
let a:readResult.std.location={
|
||||||
\'file':(l:file),
|
\'file':(l:file),
|
||||||
\'line':str2nr(l:matches[4])}
|
\'line':str2nr(l:matches[4])}
|
||||||
endif
|
endif
|
||||||
let a:readResult.std.callstack={
|
let a:readResult.std.callstack={
|
||||||
\'clearOld':('1'==l:frameNumber),
|
\'clearOld':('1'==l:frameNumber),
|
||||||
\'add':'after',
|
\'add':'after',
|
||||||
\'file':(l:file),
|
\'file':(l:file),
|
||||||
\'line':str2nr(l:matches[4])}
|
\'line':str2nr(l:matches[4])}
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_readException(pipeName,line,readResult,debugger)
|
function! vebugger#jdb#_readException(pipeName,line,readResult,debugger)
|
||||||
if 'out'==a:pipeName
|
if 'out'==a:pipeName
|
||||||
let l:matches=matchlist(a:line,'\vException occurred:\s+(\S+)')
|
let l:matches=matchlist(a:line,'\vException occurred:\s+(\S+)')
|
||||||
if 1<len(l:matches)
|
if 1<len(l:matches)
|
||||||
let a:readResult.std.exception={
|
let a:readResult.std.exception={
|
||||||
\'message':(l:matches[1])}
|
\'message':(l:matches[1])}
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_writeFlow(writeAction,debugger)
|
function! vebugger#jdb#_writeFlow(writeAction,debugger)
|
||||||
if 'stepin'==a:writeAction
|
if 'stepin'==a:writeAction
|
||||||
call a:debugger.writeLine('step')
|
call a:debugger.writeLine('step')
|
||||||
elseif 'stepover'==a:writeAction
|
elseif 'stepover'==a:writeAction
|
||||||
call a:debugger.writeLine('next')
|
call a:debugger.writeLine('next')
|
||||||
elseif 'stepout'==a:writeAction
|
elseif 'stepout'==a:writeAction
|
||||||
call a:debugger.writeLine('step up')
|
call a:debugger.writeLine('step up')
|
||||||
elseif 'continue'==a:writeAction
|
elseif 'continue'==a:writeAction
|
||||||
call a:debugger.writeLine('cont')
|
call a:debugger.writeLine('cont')
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:getClassNameFromFile(filename)
|
function! s:getClassNameFromFile(filename)
|
||||||
let l:className=fnamemodify(a:filename,':t:r') " Get only the name of the file, without path or extension
|
let l:className=fnamemodify(a:filename,':t:r') " Get only the name of the file, without path or extension
|
||||||
for l:line in readfile(a:filename)
|
for l:line in readfile(a:filename)
|
||||||
" trailing ; is optional to make it work for groovy as well
|
" trailing ; is optional to make it work for groovy as well
|
||||||
let l:matches=matchlist(l:line,'\vpackage\s+(%(\w|\.)+)\s*;?')
|
let l:matches=matchlist(l:line,'\vpackage\s+(%(\w|\.)+)\s*;?')
|
||||||
if 1<len(l:matches)
|
if 1<len(l:matches)
|
||||||
return l:matches[1].'.'.l:className
|
return l:matches[1].'.'.l:className
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
return l:className
|
return l:className
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_writeBreakpoints(writeAction,debugger)
|
function! vebugger#jdb#_writeBreakpoints(writeAction,debugger)
|
||||||
for l:breakpoint in a:writeAction
|
for l:breakpoint in a:writeAction
|
||||||
let l:class=''
|
let l:class=''
|
||||||
if has_key(a:debugger.state.jdb.filesToClassesMap,l:breakpoint.file)
|
if has_key(a:debugger.state.jdb.filesToClassesMap,l:breakpoint.file)
|
||||||
let l:class=a:debugger.state.jdb.filesToClassesMap[l:breakpoint.file]
|
let l:class=a:debugger.state.jdb.filesToClassesMap[l:breakpoint.file]
|
||||||
else
|
else
|
||||||
let l:class=s:getClassNameFromFile(l:breakpoint.file)
|
let l:class=s:getClassNameFromFile(l:breakpoint.file)
|
||||||
let a:debugger.state.jdb.filesToClassesMap[l:breakpoint.file]=l:class
|
let a:debugger.state.jdb.filesToClassesMap[l:breakpoint.file]=l:class
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if 'add'==(l:breakpoint.action)
|
if 'add'==(l:breakpoint.action)
|
||||||
call a:debugger.writeLine('stop at '.l:class.':'.l:breakpoint.line)
|
call a:debugger.writeLine('stop at '.l:class.':'.l:breakpoint.line)
|
||||||
elseif 'remove'==l:breakpoint.action
|
elseif 'remove'==l:breakpoint.action
|
||||||
call a:debugger.writeLine('clear '.l:class.':'.l:breakpoint.line)
|
call a:debugger.writeLine('clear '.l:class.':'.l:breakpoint.line)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_requestEvaluateExpression(writeAction,debugger)
|
function! vebugger#jdb#_requestEvaluateExpression(writeAction,debugger)
|
||||||
for l:evalAction in a:writeAction
|
for l:evalAction in a:writeAction
|
||||||
call a:debugger.writeLine('eval '.l:evalAction.expression)
|
call a:debugger.writeLine('eval '.l:evalAction.expression)
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_executeStatements(writeAction,debugger)
|
function! vebugger#jdb#_executeStatements(writeAction,debugger)
|
||||||
for l:evalAction in a:writeAction
|
for l:evalAction in a:writeAction
|
||||||
if has_key(l:evalAction,'statement')
|
if has_key(l:evalAction,'statement')
|
||||||
"Use eval to run the statement - it works!
|
"Use eval to run the statement - it works!
|
||||||
call a:debugger.writeLine('eval '.l:evalAction.statement)
|
call a:debugger.writeLine('eval '.l:evalAction.statement)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! vebugger#jdb#_readEvaluatedExpressions(pipeName,line,readResult,debugger)
|
function! vebugger#jdb#_readEvaluatedExpressions(pipeName, line, readResult, debugger) dict
|
||||||
if 'out'==a:pipeName
|
if 'out' == a:pipeName
|
||||||
let l:matches=matchlist(a:line,'\v^%(\s*%(%(%(\w|\.)+)\[\d+\] )+)? ([^=]+) \= (.*)$')
|
let l:matches = matchlist(a:line, '\v^%(\s*%(%(%(\w|\.)+)\[\d+\] )+)? ([^=]+) \= (.*)$')
|
||||||
if 3<len(l:matches)
|
if !has_key(self, 'evalContext')
|
||||||
let l:expression=l:matches[1]
|
if 3 < len(l:matches)
|
||||||
let l:value=l:matches[2]
|
let l:expression = l:matches[1]
|
||||||
let a:readResult.std.evaluatedExpression={
|
let l:value = l:matches[2]
|
||||||
\'expression':(l:expression),
|
if l:value == 'null'
|
||||||
\'value':(l:value)}
|
let a:readResult.std.evaluatedExpression = {
|
||||||
endif
|
\ 'expression': l:expression,
|
||||||
endif
|
\ 'value': l:value}
|
||||||
|
else
|
||||||
|
let self.evalContext = {
|
||||||
|
\ 'expression': l:expression,
|
||||||
|
\ 'dumpCommand': 'dump ' . l:expression,
|
||||||
|
\ 'dumpStart': ' ' . l:expression . ' = {',
|
||||||
|
\ 'lines': [l:value],
|
||||||
|
\ 'dumpStarted': 0,
|
||||||
|
\ }
|
||||||
|
call a:debugger.writeLine(self.evalContext.dumpCommand)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if vebugger#util#endsWith(a:line, self.evalContext.dumpCommand)
|
||||||
|
elseif a:line == self.evalContext.dumpStart
|
||||||
|
call add(self.evalContext.lines, '{')
|
||||||
|
let self.evalContext.dumpStart = 1
|
||||||
|
elseif !self.evalContext.dumpStarted && 3 < len(l:matches)
|
||||||
|
let a:readResult.std.evaluatedExpression = {
|
||||||
|
\ 'expression': self.evalContext.expression,
|
||||||
|
\ 'value': join(self.evalContext.lines, "\n")}
|
||||||
|
unlet self.evalContext
|
||||||
|
else
|
||||||
|
call add(self.evalContext.lines, a:line)
|
||||||
|
endif
|
||||||
|
if a:line == '}'
|
||||||
|
let a:readResult.std.evaluatedExpression = {
|
||||||
|
\ 'expression': self.evalContext.expression,
|
||||||
|
\ 'value': join(self.evalContext.lines, "\n")}
|
||||||
|
|
||||||
|
unlet self.evalContext
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -168,3 +168,7 @@ endfunction
|
|||||||
function! vebugger#util#listSignsInFile(filename) abort
|
function! vebugger#util#listSignsInFile(filename) abort
|
||||||
return s:listSigns('file='.a:filename)
|
return s:listSigns('file='.a:filename)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! vebugger#util#endsWith(string, endsWith) abort
|
||||||
|
return a:string[-len(a:endsWith):] == a:endsWith
|
||||||
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user