function! vebugger#gdb#start(binaryFile,args) let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('gdb',get(a:args,'version'),'gdb')) \.' -i mi --silent '.fnameescape(a:binaryFile)) let l:debugger.state.gdb={} let l:debugger.pipes.err.annotation = "err&prg\t\t" call l:debugger.writeLine("set width 0") call l:debugger.writeLine("define hook-stop\nwhere\nend") if get(a:args,'pid') "Attach to process call l:debugger.writeLine('attach '.string(a:args.pid)) elseif has_key(a:args,'con') "Attach to gdbserver call l:debugger.writeLine('target remote '.a:args.con) else call l:debugger.writeLine('set args '.vebugger#util#commandLineArgsForProgram(a:args).' 1>&2') if !has('win32') call vebugger#std#openShellBuffer(l:debugger) endif if has_key(a:args,'entry') call l:debugger.writeLine('tbreak '.a:args.entry) call l:debugger.writeLine('run') else call l:debugger.writeLine('start') endif end call l:debugger.addReadHandler(function('vebugger#gdb#_readProgramOutput')) call l:debugger.addReadHandler(function('vebugger#gdb#_readWhere')) call l:debugger.addReadHandler(function('vebugger#gdb#_readFinish')) call l:debugger.addReadHandler(function('vebugger#gdb#_readEvaluatedExpressions')) call l:debugger.setWriteHandler('std','flow',function('vebugger#gdb#_writeFlow')) call l:debugger.setWriteHandler('std','breakpoints',function('vebugger#gdb#_writeBreakpoints')) call l:debugger.setWriteHandler('std','closeDebugger',function('vebugger#gdb#_closeDebugger')) call l:debugger.setWriteHandler('std','evaluateExpressions',function('vebugger#gdb#_requestEvaluateExpression')) call l:debugger.setWriteHandler('std','executeStatements',function('vebugger#gdb#_executeStatements')) call l:debugger.generateWriteActionsFromTemplate() call l:debugger.std_addAllBreakpointActions(g:vebugger_breakpoints) return l:debugger endfunction function! s:findFolderFromStackTrace(src,nameFromStackTrace) let l:path=a:src for l:dirname in split(a:nameFromStackTrace,'\.') let l:nextPath=l:path.'/'.fnameescape(l:dirname) if empty(glob(l:nextPath)) return l:path endif let l:path=l:nextPath endfor return l:path endfunction function! vebugger#gdb#_readProgramOutput(pipeName,line,readResult,debugger) if 'err'==a:pipeName \&&a:line!~'\v^[=~*&^]' \&&a:line!~'\V(gdb)' let a:readResult.std.programOutput={'line':a:line} endif endfunction function! vebugger#gdb#_readWhere(pipeName,line,readResult,debugger) if 'out'==a:pipeName "let l:matches=matchlist(a:line,'\v^\~"#(\d+)\s+(.+)\s+\(.*\)\s+at\s+([^:]+):(\d+)') let l:matches=matchlist(a:line,'\v^\*stopped.*fullname\=\"([^"]+)\",line\=\"(\d+)"') if 2