add support for attaching JDB to a running process

This commit is contained in:
Anders Mårtensson 2018-04-11 15:56:47 +02:00
parent 8842555cac
commit 7d1703ca32
No known key found for this signature in database
GPG Key ID: DD7F916E8F8A36CF
2 changed files with 23 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={}
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,11 @@ function! vebugger#jdb#start(entryClass,args)
return l:debugger
endfunction
function! vebugger#jdb#attach(address,args)
let a:args.attach = a:address
call vebugger#jdb#start('', a: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.