Displaying exceptions in JDB

This commit is contained in:
IdanArye 2014-02-08 22:58:34 +02:00
parent c51b7f0b10
commit 59f55a62be
3 changed files with 22 additions and 2 deletions

View File

@ -5,6 +5,7 @@ function! vebugger#gdb#start(binaryFile,args)
\: 'gdb '.fnameescape(a:binaryFile))) \: 'gdb '.fnameescape(a:binaryFile)))
let l:debugger.state.gdb={} let l:debugger.state.gdb={}
call l:debugger.writeLine("set width 0")
call l:debugger.writeLine("define hook-stop\nwhere\nend") call l:debugger.writeLine("define hook-stop\nwhere\nend")
call l:debugger.writeLine("start") call l:debugger.writeLine("start")

View File

@ -19,6 +19,7 @@ function! vebugger#jdb#start(entryClass,args)
call l:debugger.writeLine('monitor where') call l:debugger.writeLine('monitor where')
call l:debugger.addReadHandler(function('s:readWhere')) call l:debugger.addReadHandler(function('s:readWhere'))
call l:debugger.addReadHandler(function('s:readException'))
call l:debugger.addReadHandler(function('s:readEvaluatedExpressions')) call l:debugger.addReadHandler(function('s:readEvaluatedExpressions'))
call l:debugger.setWriteHandler('std','flow',function('s:writeFlow')) call l:debugger.setWriteHandler('std','flow',function('s:writeFlow'))
@ -65,6 +66,16 @@ function! s:readWhere(pipeName,line,readResult,debugger)
endif endif
endfunction endfunction
function! s:readException(pipeName,line,readResult,debugger)
if 'out'==a:pipeName
let l:matches=matchlist(a:line,'\vException occurred:\s+(\S+)')
if 1<len(l:matches)
let a:readResult.std.exception={
\'message':(l:matches[1])}
endif
endif
endfunction
function! s:writeFlow(writeAction,debugger) function! s:writeFlow(writeAction,debugger)
if 'stepin'==a:writeAction if 'stepin'==a:writeAction
call a:debugger.writeLine('step') call a:debugger.writeLine('step')

View File

@ -12,7 +12,8 @@ function! vebugger#std#setStandardReadResultTemplate(debugger)
\'location':{}, \'location':{},
\'callstack':{}, \'callstack':{},
\'evaluatedExpression':{}, \'evaluatedExpression':{},
\'programFinish':{}} \'programFinish':{},
\'exception':{}}
endfunction endfunction
function! vebugger#std#setStandardWriteactionsTemplate(debugger) function! vebugger#std#setStandardWriteactionsTemplate(debugger)
@ -134,6 +135,14 @@ function! s:standardThinkHandlers.closeDebuggerWhenProgramFinishes(readResult,de
endif endif
endfunction endfunction
function! s:standardThinkHandlers.printException(readResult,debugger) dict
if !empty(a:readResult.std.exception)
echohl WarningMsg
echo a:readResult.std.exception.message."\n"
echohl None
endif
endfunction
let s:standardCloseHandlers={} let s:standardCloseHandlers={}
function! s:standardCloseHandlers.removeCurrentMarker(debugger) dict function! s:standardCloseHandlers.removeCurrentMarker(debugger) dict
let a:debugger.state.std.location={} let a:debugger.state.std.location={}
@ -156,7 +165,6 @@ function! vebugger#std#updateMarksForFile(state,filename)
if !empty(a:state) if !empty(a:state)
if !empty(a:state.std.location) if !empty(a:state.std.location)
if a:state.std.location.file==a:filename if a:state.std.location.file==a:filename
echo l:filename
exe 'sign place 1 name=vebugger_current line='.a:state.std.location.line.' file='.fnameescape(l:filename) exe 'sign place 1 name=vebugger_current line='.a:state.std.location.line.' file='.fnameescape(l:filename)
endif endif
endif endif