Fix indentation and bump bugfix version

This commit is contained in:
IdanArye 2015-01-14 22:08:41 +02:00
parent 31a8bd64c8
commit f93bac384b
2 changed files with 132 additions and 132 deletions

View File

@ -1,53 +1,53 @@
function! vebugger#mdbg#searchAndAttach(binaryFile,srcpath) function! vebugger#mdbg#searchAndAttach(binaryFile,srcpath)
let l:processId=vebugger#util#selectProcessOfFile(a:binaryFile) let l:processId=vebugger#util#selectProcessOfFile(a:binaryFile)
if 0<l:processId if 0<l:processId
call vebugger#mdbg#start(a:binaryFile,{'srcpath':a:srcpath,'pid':l:processId}) call vebugger#mdbg#start(a:binaryFile,{'srcpath':a:srcpath,'pid':l:processId})
endif endif
endfunction endfunction
function! vebugger#mdbg#start(binaryFile,args) function! vebugger#mdbg#start(binaryFile,args)
let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('mdbg',get(a:args,'version'),'Mdbg'))) let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('mdbg',get(a:args,'version'),'Mdbg')))
let l:debugger.state.mdbg={'breakpointNumbers':{}} let l:debugger.state.mdbg={'breakpointNumbers':{}}
let l:debugger.readResultTemplate.mdbg={'breakpointBound':{}} let l:debugger.readResultTemplate.mdbg={'breakpointBound':{}}
if has_key(a:args,'srcpath') if has_key(a:args,'srcpath')
let l:debugger.state.mdbg.srcpath=a:args.srcpath let l:debugger.state.mdbg.srcpath=a:args.srcpath
else else
let l:debugger.state.mdbg.srcpath='.' let l:debugger.state.mdbg.srcpath='.'
endif
call l:debugger.writeLine('when StepComplete do where')
call l:debugger.writeLine('when BreakpointHit do where')
if get(a:args,'pid') "Attach to process
call l:debugger.writeLine('attach '.string(a:args.pid))
else
if !get(a:args,'noConsole')
call l:debugger.writeLine('mode nc on')
endif endif
call l:debugger.writeLine('run "'.s:pathToMdbgStyle(fnamemodify(a:binaryFile, ':p')).'" '.vebugger#util#commandLineArgsForProgram(a:args))
call l:debugger.writeLine('where')
end
call l:debugger.addReadHandler(function('s:readProgramOutput'))
call l:debugger.addReadHandler(function('s:readWhere'))
call l:debugger.addReadHandler(function('s:readFinish'))
call l:debugger.addReadHandler(function('s:readEvaluatedExpressions'))
call l:debugger.addReadHandler(function('s:readBreakpointBound'))
call l:debugger.writeLine('when StepComplete do where') call l:debugger.addThinkHandler(function('s:breakpointAdded'))
call l:debugger.writeLine('when BreakpointHit do where')
call l:debugger.setWriteHandler('std','flow',function('s:writeFlow'))
call l:debugger.setWriteHandler('std','breakpoints',function('s:writeBreakpoints'))
call l:debugger.setWriteHandler('std','closeDebugger',function('s:closeDebugger'))
call l:debugger.setWriteHandler('std','evaluateExpressions',function('s:requestEvaluateExpression'))
call l:debugger.setWriteHandler('std','executeStatements',function('s:executeStatements'))
if get(a:args,'pid') "Attach to process call l:debugger.generateWriteActionsFromTemplate()
call l:debugger.writeLine('attach '.string(a:args.pid))
else
if !get(a:args,'noConsole')
call l:debugger.writeLine('mode nc on')
endif
call l:debugger.writeLine('run "'.s:pathToMdbgStyle(fnamemodify(a:binaryFile, ':p')).'" '.vebugger#util#commandLineArgsForProgram(a:args))
call l:debugger.writeLine('where')
end
call l:debugger.addReadHandler(function('s:readProgramOutput'))
call l:debugger.addReadHandler(function('s:readWhere'))
call l:debugger.addReadHandler(function('s:readFinish'))
call l:debugger.addReadHandler(function('s:readEvaluatedExpressions'))
call l:debugger.addReadHandler(function('s:readBreakpointBound'))
call l:debugger.addThinkHandler(function('s:breakpointAdded')) call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints)
call l:debugger.setWriteHandler('std','flow',function('s:writeFlow')) return l:debugger
call l:debugger.setWriteHandler('std','breakpoints',function('s:writeBreakpoints'))
call l:debugger.setWriteHandler('std','closeDebugger',function('s:closeDebugger'))
call l:debugger.setWriteHandler('std','evaluateExpressions',function('s:requestEvaluateExpression'))
call l:debugger.setWriteHandler('std','executeStatements',function('s:executeStatements'))
call l:debugger.generateWriteActionsFromTemplate()
call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints)
return l:debugger
endfunction endfunction
function! s:pathToMdbgStyle(path) function! s:pathToMdbgStyle(path)
@ -67,133 +67,133 @@ function! s:pathToVimStyle(path)
endfunction endfunction
function! s:findFilePath(src,fileName,methodName) function! s:findFilePath(src,fileName,methodName)
let l:fileName = s:pathToVimStyle(a:fileName) let l:fileName = s:pathToVimStyle(a:fileName)
if vebugger#util#isPathAbsolute(l:fileName) if vebugger#util#isPathAbsolute(l:fileName)
return fnamemodify(l:fileName,':p') "Return the normalized full path return fnamemodify(l:fileName,':p') "Return the normalized full path
endif
let l:path=fnamemodify(a:src,':p')
let l:files=glob(l:path.'**/'.l:fileName,0,1)
for l:dirname in split(a:methodName,'\.')
if empty(l:files)
return ''
endif endif
let l:path=fnamemodify(a:src,':p') if 1==len(l:files)
let l:files=glob(l:path.'**/'.l:fileName,0,1) return l:files[0]
for l:dirname in split(a:methodName,'\.') endif
if empty(l:files) let l:path=fnamemodify(l:path.l:dirname,':p')
return '' let l:files=filter(l:files,'-1<stridx(v:val,l:path)')
endif endfor
if 1==len(l:files) return ''
return l:files[0]
endif
let l:path=fnamemodify(l:path.l:dirname,':p')
let l:files=filter(l:files,'-1<stridx(v:val,l:path)')
endfor
return ''
endfunction endfunction
function! s:readProgramOutput(pipeName,line,readResult,debugger) function! s:readProgramOutput(pipeName,line,readResult,debugger)
endfunction endfunction
function! s:readWhere(pipeName,line,readResult,debugger) function! s:readWhere(pipeName,line,readResult,debugger)
if 'out'==a:pipeName if 'out'==a:pipeName
let l:matches=matchlist(a:line,'\v^\*(\d+)\.\s*([A-Za-z0-9_.+<>]+)\s*\((.+):(\d+)\)') let l:matches=matchlist(a:line,'\v^\*(\d+)\.\s*([A-Za-z0-9_.+<>]+)\s*\((.+):(\d+)\)')
if 3<len(l:matches) if 3<len(l:matches)
let l:frameNumber=str2nr(l:matches[1]) let l:frameNumber=str2nr(l:matches[1])
let l:file=s:findFilePath(a:debugger.state.mdbg.srcpath,l:matches[3],l:matches[2]) let l:file=s:findFilePath(a:debugger.state.mdbg.srcpath,l:matches[3],l:matches[2])
let l:file=fnamemodify(l:file,':~:.') let l:file=fnamemodify(l:file,':~:.')
if 0==l:frameNumber " first stackframe is the current location if 0==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':('0'==l:frameNumber), \'clearOld':('0'==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! s:readFinish(pipeName,line,readResult,debugger) function! s:readFinish(pipeName,line,readResult,debugger)
if a:line=~'\VSTOP: Process Exited\$' if a:line=~'\VSTOP: Process Exited\$'
let a:readResult.std.programFinish={'finish':1} let a:readResult.std.programFinish={'finish':1}
endif endif
endfunction 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')
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('out') call a:debugger.writeLine('out')
elseif 'continue'==a:writeAction elseif 'continue'==a:writeAction
call a:debugger.writeLine('go') call a:debugger.writeLine('go')
endif endif
endfunction endfunction
function! s:closeDebugger(writeAction,debugger) function! s:closeDebugger(writeAction,debugger)
call a:debugger.writeLine('quit') call a:debugger.writeLine('quit')
endfunction endfunction
function! s:writeBreakpoints(writeAction,debugger) function! s:writeBreakpoints(writeAction,debugger)
for l:breakpoint in a:writeAction for l:breakpoint in a:writeAction
let l:fullFileName=fnamemodify(l:breakpoint.file,':p') let l:fullFileName=fnamemodify(l:breakpoint.file,':p')
if 'add'==(l:breakpoint.action) if 'add'==(l:breakpoint.action)
call a:debugger.writeLine('break '.s:pathToMdbgStyle(l:fullFileName).':'.l:breakpoint.line) call a:debugger.writeLine('break '.s:pathToMdbgStyle(l:fullFileName).':'.l:breakpoint.line)
let a:debugger.state.mdbg.breakpointNumbers[s:pathToVimStyle(l:fullFileName).':'.l:breakpoint.line]={} let a:debugger.state.mdbg.breakpointNumbers[s:pathToVimStyle(l:fullFileName).':'.l:breakpoint.line]={}
elseif 'remove'==l:breakpoint.action elseif 'remove'==l:breakpoint.action
call a:debugger.writeLine('delete '.a:debugger.state.mdbg.breakpointNumbers[l:fullFileName.':'.l:breakpoint.line].number) call a:debugger.writeLine('delete '.a:debugger.state.mdbg.breakpointNumbers[l:fullFileName.':'.l:breakpoint.line].number)
call remove(a:debugger.state.mdbg.breakpointNumbers,l:fullFileName.':'.l:breakpoint.line) call remove(a:debugger.state.mdbg.breakpointNumbers,l:fullFileName.':'.l:breakpoint.line)
endif endif
endfor endfor
endfunction endfunction
function! s:readBreakpointBound(pipeName,line,readResult,debugger) function! s:readBreakpointBound(pipeName,line,readResult,debugger)
if 'out'==a:pipeName if 'out'==a:pipeName
let l:matches=matchlist(a:line,'\vBreakpoint \#(\d+) bound\s*\(line (\d+) in ([^)]+)\)') let l:matches=matchlist(a:line,'\vBreakpoint \#(\d+) bound\s*\(line (\d+) in ([^)]+)\)')
if 3<len(l:matches) if 3<len(l:matches)
let a:readResult.mdbg.breakpointBound={ let a:readResult.mdbg.breakpointBound={
\'fileNameTail':s:pathToVimStyle(l:matches[3]), \'fileNameTail':s:pathToVimStyle(l:matches[3]),
\'line':l:matches[2], \'line':l:matches[2],
\'breakpointNumber':l:matches[1]} \'breakpointNumber':l:matches[1]}
endif
endif endif
endif
endfunction endfunction
function! s:breakpointAdded(readResult,debugger) function! s:breakpointAdded(readResult,debugger)
if !empty(a:readResult.mdbg.breakpointBound) if !empty(a:readResult.mdbg.breakpointBound)
let l:breakpointBound=a:readResult.mdbg.breakpointBound let l:breakpointBound=a:readResult.mdbg.breakpointBound
let l:lookFor=l:breakpointBound.fileNameTail.':'.l:breakpointBound.line let l:lookFor=l:breakpointBound.fileNameTail.':'.l:breakpointBound.line
let l:lookForRegex='\V'.escape(l:lookFor,'\').'\$' let l:lookForRegex='\V'.escape(l:lookFor,'\').'\$'
let l:matchingKeys=filter(keys(a:debugger.state.mdbg.breakpointNumbers),'v:val=~l:lookForRegex') let l:matchingKeys=filter(keys(a:debugger.state.mdbg.breakpointNumbers),'v:val=~l:lookForRegex')
for l:key in l:matchingKeys for l:key in l:matchingKeys
if empty(a:debugger.state.mdbg.breakpointNumbers[l:key]) if empty(a:debugger.state.mdbg.breakpointNumbers[l:key])
let a:debugger.state.mdbg.breakpointNumbers[l:key]={'number':l:breakpointBound.breakpointNumber} let a:debugger.state.mdbg.breakpointNumbers[l:key]={'number':l:breakpointBound.breakpointNumber}
endif endif
endfor endfor
endif endif
endfunction endfunction
function! s:requestEvaluateExpression(writeAction,debugger) function! s:requestEvaluateExpression(writeAction,debugger)
for l:evalAction in a:writeAction for l:evalAction in a:writeAction
call a:debugger.writeLine('print '.l:evalAction.expression) call a:debugger.writeLine('print '.l:evalAction.expression)
endfor endfor
endfunction endfunction
function! s:executeStatements(writeAction,debugger) function! s: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')
call a:debugger.writeLine('set '.substitute(l:evalAction.statement,'\v;\s*$','','')) call a:debugger.writeLine('set '.substitute(l:evalAction.statement,'\v;\s*$','',''))
endif endif
endfor endfor
endfunction endfunction
function! s:readEvaluatedExpressions(pipeName,line,readResult,debugger) dict function! s:readEvaluatedExpressions(pipeName,line,readResult,debugger) dict
if 'out'==a:pipeName if 'out'==a:pipeName
let l:matches=matchlist(a:line,'\v\[[^\]]*\]\s*mdbg\>\s*([^=]+)\=(.*)$') let l:matches=matchlist(a:line,'\v\[[^\]]*\]\s*mdbg\>\s*([^=]+)\=(.*)$')
if 2<len(l:matches) if 2<len(l:matches)
let l:expression=l:matches[1] let l:expression=l:matches[1]
let l:value=l:matches[2] let l:value=l:matches[2]
let a:readResult.std.evaluatedExpression={ let a:readResult.std.evaluatedExpression={
\'expression':l:expression, \'expression':l:expression,
\'value':l:value} \'value':l:value}
endif
endif endif
endif
endfunction endfunction

View File

@ -4,7 +4,7 @@
Author: Idan Arye <https://github.com/idanarye/> Author: Idan Arye <https://github.com/idanarye/>
License: Same terms as Vim itself (see |license|) License: Same terms as Vim itself (see |license|)
Version: 1.2.0 Version: 1.2.1
INTRODUCTION *vebugger* INTRODUCTION *vebugger*