Adding JDI MethodEntry events


I'm trying to write a plugin which traces all method calls on a thread after a breakpoint has been hit.  i.e. add a kind of “Resume with tracing” button to the debugger.

In plain Java, I can do this to add MethodEntry events using the java debug interface (JDI):

VirtualMachine vm = // attach to JVM
EventRequestManager mgr = vm.eventRequestManager();
MethodEntryRequest request = mgr.createMethodEntryRequest();

In my Intellij Plugin I've got this (simplified) code to get the thread:

public class DebugProcessListener implements XDebuggerManagerListener {
  public void processStarted(@NotNull final XDebugProcess debugProcess) {
    XDebugSession debugSession = debugProcess.getSession();
    debugSession.addSessionListener(new DebugSessionListener(debugProcess));

public class DebugSessionListener implements XDebugSessionListener {
  public void sessionPaused() {
    SuspendContext sc = (SuspendContext) debugSession.getSuspendContext();
    ThreadReferenceProxy scThread = sc.getThread();

From here, how can I get access to the JDI VirtualMachine in order to add the MethodEntry request?

1 comment

Hi, you can try something like this:



Please sign in to leave a comment.