当前位置: 首页>>代码示例>>Java>>正文


Java EventRequestManager类代码示例

本文整理汇总了Java中com.sun.jdi.request.EventRequestManager的典型用法代码示例。如果您正苦于以下问题:Java EventRequestManager类的具体用法?Java EventRequestManager怎么用?Java EventRequestManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EventRequestManager类属于com.sun.jdi.request包,在下文中一共展示了EventRequestManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setEventRequests

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
private void setEventRequests(VirtualMachine vm) {
    EventRequestManager erm = vm.eventRequestManager();

    // Normally, we want all uncaught exceptions.  We request them
    // via the same mechanism as Commands.commandCatchException()
    // so the user can ignore them later if they are not
    // interested.
    // FIXME: this works but generates spurious messages on stdout
    //        during startup:
    //          Set uncaught java.lang.Throwable
    //          Set deferred uncaught java.lang.Throwable
    Commands evaluator = new Commands();
    evaluator.commandCatchException
        (new StringTokenizer("uncaught java.lang.Throwable"));

    ThreadStartRequest tsr = erm.createThreadStartRequest();
    tsr.enable();
    ThreadDeathRequest tdr = erm.createThreadDeathRequest();
    tdr.enable();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:VMConnection.java

示例2: addBreakpoint

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
private static void addBreakpoint(VirtualMachine vm, ReferenceType refType) {
    Location breakpointLocation = null;
    List<Location> locs;
    try {
        locs = refType.allLineLocations();
        for (Location loc: locs) {
            if (loc.method().name().equals(METHOD_NAME)) {
                breakpointLocation = loc;
                break;
            }
        }
    } catch (AbsentInformationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (breakpointLocation != null) {
        EventRequestManager evtReqMgr = vm.eventRequestManager();
        BreakpointRequest bReq = evtReqMgr.createBreakpointRequest(breakpointLocation);
        bReq.setSuspendPolicy(BreakpointRequest.SUSPEND_ALL);
        bReq.enable();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:GetObjectLockCount.java

示例3: stopOnEntry

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
/**
 * Suspend the main thread when the program enters the main method of the specified main class.
 * @param debugSession
 *                  the debug session.
 * @param mainClass
 *                  the fully qualified name of the main class.
 * @return
 *        a {@link CompletableFuture} that contains the suspended main thread id.
 */
public static CompletableFuture<Long> stopOnEntry(IDebugSession debugSession, String mainClass) {
    CompletableFuture<Long> future = new CompletableFuture<>();

    EventRequestManager manager = debugSession.getVM().eventRequestManager();
    MethodEntryRequest request = manager.createMethodEntryRequest();
    request.addClassFilter(mainClass);
    request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);

    debugSession.getEventHub().events().filter(debugEvent -> {
        return debugEvent.event instanceof MethodEntryEvent && request.equals(debugEvent.event.request());
    }).subscribe(debugEvent -> {
        Method method = ((MethodEntryEvent) debugEvent.event).method();
        if (method.isPublic() && method.isStatic() && method.name().equals("main")
                && method.signature().equals("([Ljava/lang/String;)V")) {
            deleteEventRequestSafely(debugSession.getVM().eventRequestManager(), request);
            debugEvent.shouldResume = false;
            ThreadReference bpThread = ((MethodEntryEvent) debugEvent.event).thread();
            future.complete(bpThread.uniqueID());
        }
    });
    request.enable();

    return future;
}
 
开发者ID:Microsoft,项目名称:java-debug,代码行数:34,代码来源:DebugUtility.java

示例4: perform

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
@Override
    public void perform(String[] argv, Context ctx) {

        EventRequestManager manager = ctx.getVm().eventRequestManager();
        MethodEntryRequest mer = manager.createMethodEntryRequest();
        mer.setSuspendPolicy(EventRequest.SUSPEND_NONE);
        mer.enable();

        ctx.register(mer, new EventCallback() {
            @Override
            public void handleEvent(Event event) {
                MethodEntryEvent mee = (MethodEntryEvent) event;
                Method method = mee.method();
                System.out.println("--" + method.name());
//                mee.thread().resume();
            }
        });
    }
 
开发者ID:CvvT,项目名称:andbg,代码行数:19,代码来源:track.java

示例5: deleteStepRequests

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
void deleteStepRequests(@Nullable final ThreadReference stepThread) {
  EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager();
  List<StepRequest> stepRequests = requestManager.stepRequests();
  if (!stepRequests.isEmpty()) {
    final List<StepRequest> toDelete = new ArrayList<StepRequest>(stepRequests.size());
    for (final StepRequest request : stepRequests) {
      ThreadReference threadReference = request.thread();
      // [jeka] on attempt to delete a request assigned to a thread with unknown status, a JDWP error occurs
      try {
        if (threadReference.status() != ThreadReference.THREAD_STATUS_UNKNOWN && (stepThread == null || stepThread.equals(threadReference))) {
          toDelete.add(request);
        }
      }
      catch (IllegalThreadStateException e) {
        LOG.info(e); // undocumented by JDI: may be thrown when querying thread status
      }
      catch (ObjectCollectedException ignored) {
      }
    }
    requestManager.deleteEventRequests(toDelete);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DebugProcessImpl.java

示例6: deleteBreakpoint

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
@Override
public void deleteBreakpoint(Location location) throws DebuggerException {
  final String className = debuggerUtil.findFqnByPosition(location);
  final int lineNumber = location.getLineNumber();
  EventRequestManager requestManager = getEventManager();
  List<BreakpointRequest> snapshot = new ArrayList<>(requestManager.breakpointRequests());
  for (BreakpointRequest breakpointRequest : snapshot) {
    com.sun.jdi.Location jdiLocation = breakpointRequest.location();
    if (jdiLocation.declaringType().name().equals(className)
        && jdiLocation.lineNumber() == lineNumber) {
      requestManager.deleteEventRequest(breakpointRequest);
      LOG.debug("Delete breakpoint: {}", location);
    }
  }

  List<Breakpoint> defferedByClass = deferredBreakpoints.get(className);
  if (defferedByClass != null) {
    defferedByClass.removeIf(
        breakpoint -> {
          Location l = breakpoint.getLocation();
          return l.getLineNumber() == location.getLineNumber()
              && l.getTarget().equals(location.getTarget());
        });
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:JavaDebugger.java

示例7: setEventRequests

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
private void setEventRequests(VirtualMachine vm) {
    EventRequestManager erm = vm.eventRequestManager();

    // Normally, we want all uncaught exceptions.  We request them
    // via the same mechanism as Commands.commandCatchException()
    // so the user can ignore them later if they are not
    // interested.
    // FIXME: this works but generates spurious messages on stdout
    //        during startup:
    //          Set uncaught java.lang.Throwable
    //          Set deferred uncaught java.lang.Throwable
    Commands evaluator = new Commands(env);
    evaluator.commandCatchException
        (new StringTokenizer("uncaught java.lang.Throwable"));

    ThreadStartRequest tsr = erm.createThreadStartRequest();
    tsr.enable();
    ThreadDeathRequest tdr = erm.createThreadDeathRequest();
    tdr.enable();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:21,代码来源:VMConnection.java

示例8: createRequest

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void createRequest()
{
  final EventRequestManager manager = owner.getEventRequestManager();
  if (manager != null)
  {
    try
    {
      final ClassPrepareRequest request = manager.createClassPrepareRequest();
      owner.jdiManager().modelFilter().filter(request);
      request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
      request.enable();
      owner.addJDIEventListener(this, request);
    }
    catch (final RuntimeException e)
    {
      JiveDebugPlugin.log(e);
    }
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:20,代码来源:EventHandlerFactory.java

示例9: removeFieldRequests

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void removeFieldRequests(final JDIDebugTarget target)
{
  final EventRequestManager manager = target.getEventRequestManager();
  if (manager != null && !fieldRequests.isEmpty())
  {
    try
    {
      manager.deleteEventRequests(fieldRequests);
      for (final EventRequest request : fieldRequests)
      {
        target.removeJDIEventListener(
            request instanceof AccessWatchpointRequest ? fieldReadHandler : fieldWriteHandler,
            request);
      }
    }
    catch (final RuntimeException e)
    {
      JiveDebugPlugin.log(e);
    }
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:22,代码来源:EventHandlerFactory.java

示例10: removeRequest

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void removeRequest()
{
  final EventRequestManager manager = owner.getEventRequestManager();
  if (manager != null && request != null)
  {
    try
    {
      owner.removeJDIEventListener(this, request);
      manager.deleteEventRequest(request);
      request = null;
    }
    catch (final RuntimeException e)
    {
      JiveDebugPlugin.log(e);
    }
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:18,代码来源:EventHandlerFactory.java

示例11: createRequest

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void createRequest()
{
  final EventRequestManager manager = getEventRequestManager();
  if (manager != null)
  {
    try
    {
      if (stepRequest != null)
      {
        removeRequest();
      }
      stepRequest = manager.createStepRequest(getUnderlyingThread(), StepRequest.STEP_LINE,
          StepRequest.STEP_INTO);
      final JiveDebugTarget target = (JiveDebugTarget) getDebugTarget();
      final IModelFilter requestFilter = target.jdiManager().modelFilter();
      requestFilter.filter(stepRequest);
      stepRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
      stepRequest.enable();
      addJDIEventListener(this, stepRequest);
    }
    catch (final RuntimeException e)
    {
      logError(e);
    }
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:27,代码来源:JiveThread.java

示例12: removeRequest

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected void removeRequest()
{
  final EventRequestManager manager = getEventRequestManager();
  if (manager != null && stepRequest != null)
  {
    try
    {
      removeJDIEventListener(this, stepRequest);
      manager.deleteEventRequest(stepRequest);
      stepRequest = null;
    }
    catch (final RuntimeException e)
    {
      logError(e);
    }
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:18,代码来源:JiveThread.java

示例13: createRequest

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
@Override
protected void createRequest()
{
  final EventRequestManager manager = getEventRequestManager();
  if (manager != null)
  {
    try
    {
      final EventRequest request = manager.createThreadDeathRequest();
      request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
      request.enable();
      addJDIEventListener(this, request);
    }
    catch (final RuntimeException e)
    {
      logError(e);
    }
  }
}
 
开发者ID:UBPL,项目名称:jive,代码行数:20,代码来源:JiveDebugTarget.java

示例14: HotSwapperJpda

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
/**
 * Connects to the JVM.
 *
 * @param port the port number used for the connection to the JVM.
 */
public HotSwapperJpda(String port)
        throws IOException, IllegalConnectorArgumentsException {
    jvm = null;
    request = null;
    newClassFiles = null;
    trigger = new Trigger();
    AttachingConnector connector
            = (AttachingConnector) findConnector("com.sun.jdi.SocketAttach");

    Map arguments = connector.defaultArguments();
    ((Connector.Argument) arguments.get("hostname")).setValue(HOST_NAME);
    ((Connector.Argument) arguments.get("port")).setValue(port);
    jvm = connector.attach(arguments);
    EventRequestManager manager = jvm.eventRequestManager();
    request = methodEntryRequests(manager, TRIGGER_NAME);
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:22,代码来源:HotSwapperJpda.java

示例15: getEventRequestManager

import com.sun.jdi.request.EventRequestManager; //导入依赖的package包/类
protected EventRequestManager getEventRequestManager () throws VMDisconnectedExceptionWrapper, InternalExceptionWrapper {
    VirtualMachine vm = getVirtualMachine();
    if (vm == null) {
        // Already disconnected
        throw new VMDisconnectedExceptionWrapper(new VMDisconnectedException());
    }
    return VirtualMachineWrapper.eventRequestManager (vm);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:BreakpointImpl.java


注:本文中的com.sun.jdi.request.EventRequestManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。