Merge pull request #55 from nemrod/jdbattach

Add support for attaching JDB to a running process
This commit is contained in:
Idan Arye 2018-04-11 17:49:36 +03:00 committed by GitHub
commit aea7ad4639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View File

@ -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^\> \>'

View File

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