From 5036961da92982519408e4d546d1091cf9f7e483 Mon Sep 17 00:00:00 2001 From: IdanArye Date: Tue, 24 Jun 2014 01:46:03 +0300 Subject: [PATCH] Add support for multiple versions of debuggers --- autoload/vebugger/gdb.vim | 2 +- autoload/vebugger/jdb.vim | 2 +- autoload/vebugger/mdbg.vim | 2 +- autoload/vebugger/pdb.vim | 6 +++++- autoload/vebugger/rdebug.vim | 2 +- autoload/vebugger/util.vim | 15 +++++++++++++-- doc/vebugger.txt | 22 +++++++++++++++++++++- plugin/vebugger.vim | 2 ++ 8 files changed, 45 insertions(+), 8 deletions(-) diff --git a/autoload/vebugger/gdb.vim b/autoload/vebugger/gdb.vim index 939c838..2cea119 100644 --- a/autoload/vebugger/gdb.vim +++ b/autoload/vebugger/gdb.vim @@ -6,7 +6,7 @@ function! vebugger#gdb#searchAndAttach(binaryFile) endfunction function! vebugger#gdb#start(binaryFile,args) - let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('gdb','gdb')) + 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={} diff --git a/autoload/vebugger/jdb.vim b/autoload/vebugger/jdb.vim index 5fa38e9..1040921 100644 --- a/autoload/vebugger/jdb.vim +++ b/autoload/vebugger/jdb.vim @@ -1,5 +1,5 @@ function! vebugger#jdb#start(entryClass,args) - let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('jdb','jdb')) + let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('jdb',get(a:args,'version'),'jdb')) \.(has_key(a:args,'classpath') ? ' -classpath '.fnameescape(a:args.classpath) : '')) let l:debugger.state.jdb={} if has_key(a:args,'srcpath') diff --git a/autoload/vebugger/mdbg.vim b/autoload/vebugger/mdbg.vim index fff7888..a2b013f 100644 --- a/autoload/vebugger/mdbg.vim +++ b/autoload/vebugger/mdbg.vim @@ -6,7 +6,7 @@ function! vebugger#mdbg#searchAndAttach(binaryFile,srcpath) endfunction function! vebugger#mdbg#start(binaryFile,args) - let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('mdbg','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.readResultTemplate.mdbg={'breakpointBound':{}} diff --git a/autoload/vebugger/pdb.vim b/autoload/vebugger/pdb.vim index 43f8d5f..f03e55c 100644 --- a/autoload/vebugger/pdb.vim +++ b/autoload/vebugger/pdb.vim @@ -1,5 +1,9 @@ function! vebugger#pdb#start(entryFile,args) - let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('python','python')) + let l:debuggerExe=vebugger#util#getToolFullPath('python',get(a:args,'version'),{ + \' ':'python', + \'2':'python2', + \'3':'python3'}) + let l:debugger=vebugger#std#startDebugger(shellescape(l:debuggerExe) \.' -m pdb '.a:entryFile.' '.vebugger#util#commandLineArgsForProgram(a:args)) let l:debugger.state.pdb={} diff --git a/autoload/vebugger/rdebug.vim b/autoload/vebugger/rdebug.vim index e42e91c..ef248b3 100644 --- a/autoload/vebugger/rdebug.vim +++ b/autoload/vebugger/rdebug.vim @@ -1,5 +1,5 @@ function! vebugger#rdebug#start(entryFile,args) - let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('ruby','ruby')) + let l:debugger=vebugger#std#startDebugger(shellescape(vebugger#util#getToolFullPath('ruby',get(a:args,'version'),'ruby')) \.' -rdebug '.a:entryFile.' '.vebugger#util#commandLineArgsForProgram(a:args)) let l:debugger.state.rdebug={} let l:debugger.state.std.config.externalFileStop_flowCommand='stepover' "skip external modules diff --git a/autoload/vebugger/util.vim b/autoload/vebugger/util.vim index 3146932..3c1a5f9 100644 --- a/autoload/vebugger/util.vim +++ b/autoload/vebugger/util.vim @@ -86,12 +86,23 @@ endfunction "Return a tool's(usually debugger) full path, or revert to default if that "path is not defined -function! vebugger#util#getToolFullPath(toolName,default) +function! vebugger#util#getToolFullPath(toolName,version,default) let l:optionName='vebugger_path_'.a:toolName + if !empty(a:version) + let l:optionName=l:optionName.'_'.a:version + endif if exists('g:'.l:optionName) return g:[l:optionName] else - return a:default + if type({})==type(a:default) + if !empty(a:version) && has_key(a:default,a:version) + return a:default[a:version] + else + return a:default[' '] + endif + else + return a:default + endif endif endfunction diff --git a/doc/vebugger.txt b/doc/vebugger.txt index f8ee558..b06a2d4 100644 --- a/doc/vebugger.txt +++ b/doc/vebugger.txt @@ -85,6 +85,15 @@ g:vebugger_path_XXX, where XXX is the executable used for the debugger: Notice that for PDB and RDebug you use "python" and "ruby", since the debugger is actually a module bundled in the interpreter. +You can set multiple versions for each debugger, by appending the version name +to the debugger name with "_". These versions will be used when the "version" +argument is supplied when running the debugger: + +*g:vebugger_path_python_2* defaults to "python2" +*g:vebugger_path_python_3* defaults to "python3" +*g:vebugger_path_mdbg_32* No default - use it for the 32bit version of Mdbg +*g:vebugger_path_mdbg_64* No default - use it for the 64bit version of Mdbg + LAUNCHING DEBUGGERS *vebugger-launching* A debugger's implementation is responsible for starting it. The standard is to @@ -108,7 +117,8 @@ GDB can be launched with *vebuger#gdb#start* The supported extra arguments are: * "args": Command line arguments for the debugged program * "pid": Process id to attach to -* "entry": The entry +* "entry": The entry point for starting the debugging(default "main") +* "version": The version of the debugger to run You can't specify both ("args" and/or "entry") and "pid". GDB can also be launched with the *VBGstartGDB* command: @@ -137,6 +147,7 @@ file - it's the name of the class to run. The supported extra arguments are: * "args": Command line arguments for the debugged program * "classpath": Where to look for class files * "srcpath": Where to look for source files +* "version": The version of the debugger to run If you don't supply "classpath" and "srcpath", Vebugger will assume you are using the current directory for source files and class files. @@ -152,6 +163,7 @@ RDebug is launched with *vebugger#rdebug#start* < The supported extra arguments are: * "args": Command line arguments for the debugged script +* "version": The version of the debugger to run RDebug can also be launched with the *VBGstartRDebug* command: > @@ -166,12 +178,19 @@ PDB is launched with *vebugger#pdb#start* < The supported extra arguments are: * "args": Command line arguments for the debugged script +* "version": The version of the debugger to run PDB can also be launched with the *VBGstartPDB* command: > VBGstartPDB script.py hello world < +There are also commands to specify if you want to use python2 or python3: +> + VBGstartPDB2 script.py hello world + VBGstartPDB3 script.py hello world +< + LAUNCHING MDBG *vebugger-mdbg* Mdbg is launched with *vebugger#mdbg#start* @@ -186,6 +205,7 @@ The supported extra arguments are: * "noConsole": If non-zero, do not open a console for the debugged program * "args": Command line arguments for the debugged program * "pid": Process id to attach to +* "version": The version of the debugger to run If you specify "pid", you can't specify "args" and/or "noConsole". If you don't supply "srcpath", Vebugger will assume you are diff --git a/plugin/vebugger.vim b/plugin/vebugger.vim index 8d1fdc9..6ea2076 100644 --- a/plugin/vebugger.vim +++ b/plugin/vebugger.vim @@ -25,6 +25,8 @@ command! -nargs=+ -complete=file VBGstartGDB call vebugger#gdb#start([][ command! -nargs=1 -complete=file VBGattachGDB call vebugger#gdb#searchAndAttach() command! -nargs=+ -complete=file VBGstartRDebug call vebugger#rdebug#start([][0],{'args':[][1:]}) command! -nargs=+ -complete=file VBGstartPDB call vebugger#pdb#start([][0],{'args':[][1:]}) +command! -nargs=+ -complete=file VBGstartPDB2 call vebugger#pdb#start([][0],{'args':[][1:],'version':'2'}) +command! -nargs=+ -complete=file VBGstartPDB3 call vebugger#pdb#start([][0],{'args':[][1:],'version':'3'}) command! -nargs=+ -complete=file VBGstartGDBForD call vebugger#gdb#start([][0],{'args':[][1:],'entry':'_Dmain'}) if exists('g:vebugger_leader')