diff --git a/autoload/vebugger/jdb.vim b/autoload/vebugger/jdb.vim index 612336c..cb4a672 100644 --- a/autoload/vebugger/jdb.vim +++ b/autoload/vebugger/jdb.vim @@ -1,6 +1,12 @@ -function! vebugger#jdb#start(entryClass,args) +function! vebugger#jdb#start(args) + if !has_key(a:args, 'con') + let a:args.con = 9009 + endif + 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) : '')) + \.(has_key(a:args,'classpath') ? ' -classpath '.fnameescape(a:args.classpath) : '') + \.(!has_key(a:args,'entryClass') ? ' -attach '.fnameescape(a:args.con) : '')) + let l:debugger.state.jdb={} if has_key(a:args,'srcpath') let l:debugger.state.jdb.srcpath=a:args.srcpath @@ -9,11 +15,13 @@ function! vebugger#jdb#start(entryClass,args) endif let l:debugger.state.jdb.filesToClassesMap={} - call l:debugger.writeLine('stop on '.a:entryClass.'.main') - call l:debugger.writeLine('run '.a:entryClass.' '.vebugger#util#commandLineArgsForProgram(a:args)) - call l:debugger.writeLine('monitor where') - if !has('win32') - call vebugger#std#openShellBuffer(l:debugger) + if has_key(a:args, 'entryClass') + if !has('win32') + call vebugger#std#openShellBuffer(l:debugger) + endif + call l:debugger.writeLine('stop on '.a:args.entryClass.'.main') + call l:debugger.writeLine('run '.a:args.entryClass.' '.vebugger#util#commandLineArgsForProgram(a:args)) + call l:debugger.writeLine('monitor where') endif call l:debugger.addReadHandler(function('vebugger#jdb#_readProgramOutput')) diff --git a/doc/vebugger.txt b/doc/vebugger.txt index db8088d..2fdd77b 100644 --- a/doc/vebugger.txt +++ b/doc/vebugger.txt @@ -137,22 +137,26 @@ LAUNCHING JDB *vebugger-jdb* JDB is launched with *vebugger#jdb#start* > - call vebugger#jdb#start('Main',{ + call vebugger#jdb#start({ + \'entryClass':'Main', \'classpath':'classes', \'srcpath':'src', \'args':['hello','world']}) < -Unlike in the other debuggers, the first argument here is not the name of a -file - it's the name of the class to run. The supported extra arguments are: +Unlike in the other debuggers, there is no first argument. 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 +* "con": A connection string for attaching to an existing jvm. Ex. localhost:8000 or 8000 + defaults to 9009, the standard debug port for jvms. +* "entryClass": A class that contains main for starting the jdb up with. +If entryClass is defined it takes precedence over con. If you don't supply "classpath" and "srcpath", Vebugger will assume you are using the current directory for source files and class files. -JDB does not have a command for starting it, since you usually want to supply -"classpath" and "srcpath". +JDB can be started with VBGstartJDB. If the desired the user can call the command with the extra +arguments that are defined above. LAUNCHING RDEBUG *vebugger-rdebug* diff --git a/plugin/vebugger.vim b/plugin/vebugger.vim index 6ea2076..1ae62ca 100644 --- a/plugin/vebugger.vim +++ b/plugin/vebugger.vim @@ -28,6 +28,7 @@ command! -nargs=+ -complete=file VBGstartPDB call vebugger#pdb#start([][ 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'}) +command! -nargs=* -complete=command VBGstartJDB call vebugger#jdb#start(string() ? eval([][0]) : {}) if exists('g:vebugger_leader') if !empty(g:vebugger_leader)