Added callstack support

Currently only sets the state with the current callstack
This commit is contained in:
IdanArye 2013-12-27 23:09:58 +02:00
parent a820f6b777
commit 9788f69c3e
3 changed files with 32 additions and 5 deletions

View File

@ -196,3 +196,7 @@ function! vebugger#showLogBuffer()
call s:debugger.showLogBuffer()
endif
endfunction
function! vebugger#getActiveDebugger()
return s:debugger
endfunction

View File

@ -32,13 +32,19 @@ function! s:readWhere(pipeName,line,readResult,debugger)
if 'out'==a:pipeName
let l:matches=matchlist(a:line,'\v\s*\[(\d+)]\s*(\S+)\s*\(([^:]*):(\d*)\)')
if 4<len(l:matches)
if '1'==l:matches[1] " check that this is the innermost stackframe
let l:file=s:findFolderFromStackTrace(a:debugger.state.std.srcpath,l:matches[2]).'/'.l:matches[3]
let l:file=fnamemodify(l:file,':~:.')
let l:file=s:findFolderFromStackTrace(a:debugger.state.std.srcpath,l:matches[2]).'/'.l:matches[3]
let l:file=fnamemodify(l:file,':~:.')
let l:frameNumber=str2nr(l:matches[1])
if 1==l:frameNumber " first stackframe is the current location
let a:readResult.std.location={
\'file':(l:file),
\'line':(l:matches[4])}
endif
let a:readResult.std.callstack={
\'clearOld':('1'==l:frameNumber),
\'add':'after',
\'file':(l:file),
\'line':(l:matches[4])}
endif
end
endfunction

View File

@ -2,12 +2,14 @@
function! vebugger#std#setStandardState(debugger)
let a:debugger.state.std={
\'srcpath':'.',
\'location':{}}
\'location':{},
\'callstack':[]}
endfunction
function! vebugger#std#setStandardReadResultTemplate(debugger)
let a:debugger.readResultTemplate.std={
\'location':{}}
\'location':{},
\'callstack':{}}
endfunction
function! vebugger#std#addStandardFunctions(debugger)
@ -68,6 +70,21 @@ function! s:standardThinkHandlers.moveToCurrentLine(readResult,debugger) dict
endif
endfunction
function! s:standardThinkHandlers.updateCallStack(readResult,debugger) dict
let l:callstack=a:readResult.std.callstack
if !empty(l:callstack)
if get(l:callstack,'clearOld')
let a:debugger.state.std.callstack=[]
endif
let l:frame={'file':(l:callstack.file),'line':(l:callstack.line)}
if 'after'==get(l:callstack,'add')
call add(a:debugger.state.std.callstack,l:frame)
elseif 'before'==get(l:callstack,'add')
call insert(a:debugger.state.std.callstack,l:frame)
endif
endif
endfunction
let s:standardCloseHandlers={}
function! s:standardCloseHandlers.removeCurrentMarker(debugger) dict
sign unplace 1