diff --git a/autoload/vebugger/jdb.vim b/autoload/vebugger/jdb.vim index 319fe3a..29d2dde 100644 --- a/autoload/vebugger/jdb.vim +++ b/autoload/vebugger/jdb.vim @@ -1,6 +1,7 @@ function! vebugger#jdb#start(entryClass,args) 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') && !has_key(a:args,'attach') ? ' -classpath '.fnameescape(a:args.classpath) : '') + \.(has_key(a:args,'attach') ? ' -attach '.shellescape(a:args.attach) : '')) let l:debugger.state.jdb={} if has_key(a:args,'srcpath') let l:debugger.state.jdb.srcpath=a:args.srcpath @@ -9,10 +10,14 @@ 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)) + if !has_key(a:args,'attach') + call l:debugger.writeLine('stop on '.a:entryClass.'.main') + call l:debugger.writeLine('run '.a:entryClass.' '.vebugger#util#commandLineArgsForProgram(a:args)) + else + call l:debugger.writeLine('run') + endif call l:debugger.writeLine('monitor where') - if !has('win32') + if !has('win32') && !has_key(a:args,'attach') call vebugger#std#openShellBuffer(l:debugger) endif @@ -33,6 +38,12 @@ function! vebugger#jdb#start(entryClass,args) return l:debugger endfunction +function! vebugger#jdb#attach(address, ...) + let l:args = a:0 ? a:{1} : {} + let l:args.attach = a:address + call vebugger#jdb#start('', l:args) +endfunction + function! vebugger#jdb#_readProgramOutput(pipeName,line,readResult,debugger) dict if 'out'==a:pipeName if a:line=~'\v^\> \>' diff --git a/doc/vebugger.txt b/doc/vebugger.txt index 697c3c6..d119363 100644 --- a/doc/vebugger.txt +++ b/doc/vebugger.txt @@ -212,6 +212,15 @@ file - it's the name of the class to run. The supported extra arguments are: * "classpath": Where to look for class files * "srcpath": Where to look for source files. You can have multiple srcpaths, passed as a list * "version": The version of the debugger to run + +Alternatively, to attach to a running process you can use *vebugger#jdb#attach* +> + call vebugger#jdb#attach('8000',{ + \'srcpath':'src'}) +< +The first argument here is the the address to attach to, e.g. 127.0.0.1:8000 +or just 8000. It does not support the "args" or "classpath" arguments. + If you don't supply "classpath" and "srcpath", Vebugger will assume you are using the current directory for source files and class files.