Add support for multiple versions of debuggers

This commit is contained in:
IdanArye 2014-06-24 01:46:03 +03:00
parent b0be0c92b7
commit 5036961da9
8 changed files with 45 additions and 8 deletions

View File

@ -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={}

View File

@ -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')

View File

@ -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':{}}

View File

@ -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={}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -25,6 +25,8 @@ command! -nargs=+ -complete=file VBGstartGDB call vebugger#gdb#start([<f-args>][
command! -nargs=1 -complete=file VBGattachGDB call vebugger#gdb#searchAndAttach(<q-args>)
command! -nargs=+ -complete=file VBGstartRDebug call vebugger#rdebug#start([<f-args>][0],{'args':[<f-args>][1:]})
command! -nargs=+ -complete=file VBGstartPDB call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:]})
command! -nargs=+ -complete=file VBGstartPDB2 call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:],'version':'2'})
command! -nargs=+ -complete=file VBGstartPDB3 call vebugger#pdb#start([<f-args>][0],{'args':[<f-args>][1:],'version':'3'})
command! -nargs=+ -complete=file VBGstartGDBForD call vebugger#gdb#start([<f-args>][0],{'args':[<f-args>][1:],'entry':'_Dmain'})
if exists('g:vebugger_leader')