From 3012df9a85817fcf7d7135bdbc267a91b3983e25 Mon Sep 17 00:00:00 2001 From: IdanArye Date: Thu, 22 May 2014 17:11:54 +0300 Subject: [PATCH] Fixed process attaching for GDB --- autoload/vebugger/util.vim | 44 ++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/autoload/vebugger/util.vim b/autoload/vebugger/util.vim index f59fd83..17ff944 100644 --- a/autoload/vebugger/util.vim +++ b/autoload/vebugger/util.vim @@ -15,24 +15,50 @@ endfunction "the user selects function! vebugger#util#selectProcessOfFile(ofFile) let l:fileName=fnamemodify(a:ofFile,':t') - let l:resultLines=split(vimproc#system('ps -o pid,user,comm,start,state,tt -C '.fnameescape(l:fileName)),'\r\n\|\n\|\r') - if len(l:resultLines)<=1 + if has('win32') + "Get the process data in CSV format + let l:resultLines=split(vimproc#system('tasklist /FO csv /FI "IMAGENAME eq '.l:fileName.'"'),'\r\n\|\n\|\r') + + if l:resultLines[0]=~'\V\^INFO:' + throw 'No matching process found' + endif + "Parse(sort of) the CSV: + let l:resultLinesParsed=map(l:resultLines,'eval("[".v:val."]")') + let l:resultLinesParsed[0][2]='Session' + "Format for output + let l:linesForPrinting=map(copy(l:resultLinesParsed),'v:val[1]."\t".v:val[2]."\t\t".v:val[0]') + else + let l:resultLines=split(vimproc#system('ps -o pid,user,comm,start,state,tt -C '.fnameescape(l:fileName)),'\r\n\|\n\|\r') + let l:linesForPrinting=copy(l:resultLines) + endif + + if len(l:linesForPrinting)<=1 throw 'No matching process found' endif - if &lines