コード例 #1
0
 private Breakpoint createBreakpoint(String category, Element breakpointNode)
     throws InvalidDataException {
   XBreakpoint xBreakpoint = null;
   if (category.equals(LineBreakpoint.CATEGORY.toString())) {
     xBreakpoint = createXLineBreakpoint(JavaLineBreakpointType.class, breakpointNode);
   } else if (category.equals(MethodBreakpoint.CATEGORY.toString())) {
     if (breakpointNode.getAttribute("url") != null) {
       xBreakpoint = createXLineBreakpoint(JavaMethodBreakpointType.class, breakpointNode);
     } else {
       xBreakpoint = createXBreakpoint(JavaWildcardMethodBreakpointType.class, breakpointNode);
     }
   } else if (category.equals(FieldBreakpoint.CATEGORY.toString())) {
     xBreakpoint = createXLineBreakpoint(JavaFieldBreakpointType.class, breakpointNode);
   } else if (category.equals(ExceptionBreakpoint.CATEGORY.toString())) {
     xBreakpoint = createXBreakpoint(JavaExceptionBreakpointType.class, breakpointNode);
   }
   if (xBreakpoint == null) {
     throw new IllegalStateException("Unknown breakpoint category " + category);
   }
   return myBreakpoints.get(xBreakpoint);
 }
コード例 #2
0
 public void setBreakpointDefaults(
     Key<? extends Breakpoint> category, BreakpointDefaults defaults) {
   Class typeCls = null;
   if (LineBreakpoint.CATEGORY.toString().equals(category.toString())) {
     typeCls = JavaLineBreakpointType.class;
   } else if (MethodBreakpoint.CATEGORY.toString().equals(category.toString())) {
     typeCls = JavaMethodBreakpointType.class;
   } else if (FieldBreakpoint.CATEGORY.toString().equals(category.toString())) {
     typeCls = JavaFieldBreakpointType.class;
   } else if (ExceptionBreakpoint.CATEGORY.toString().equals(category.toString())) {
     typeCls = JavaExceptionBreakpointType.class;
   }
   if (typeCls != null) {
     XBreakpointType<XBreakpoint<?>, ?> type =
         XDebuggerUtil.getInstance().findBreakpointType(typeCls);
     ((XBreakpointManagerImpl) getXBreakpointManager())
         .getBreakpointDefaults(type)
         .setSuspendPolicy(Breakpoint.transformSuspendPolicy(defaults.getSuspendPolicy()));
   }
   // myBreakpointDefaults.put(category, defaults);
 }
コード例 #3
0
  public void applyThreadFilter(
      @NotNull final DebugProcessImpl debugProcess, @Nullable ThreadReference newFilterThread) {
    final RequestManagerImpl requestManager = debugProcess.getRequestsManager();
    final ThreadReference oldFilterThread = requestManager.getFilterThread();
    if (Comparing.equal(newFilterThread, oldFilterThread)) {
      // the filter already added
      return;
    }
    requestManager.setFilterThread(newFilterThread);
    if (newFilterThread == null || oldFilterThread != null) {
      final List<Breakpoint> breakpoints = getBreakpoints();
      for (Breakpoint breakpoint : breakpoints) {
        if (LineBreakpoint.CATEGORY.equals(breakpoint.getCategory())
            || MethodBreakpoint.CATEGORY.equals(breakpoint.getCategory())) {
          requestManager.deleteRequest(breakpoint);
          breakpoint.createRequest(debugProcess);
        }
      }
    } else {
      // important! need to add filter to _existing_ requests, otherwise Requestor->Request mapping
      // will be lost
      // and debugger trees will not be restored to original state
      abstract class FilterSetter<T extends EventRequest> {
        void applyFilter(@NotNull final List<T> requests, final ThreadReference thread) {
          for (T request : requests) {
            try {
              final boolean wasEnabled = request.isEnabled();
              if (wasEnabled) {
                request.disable();
              }
              addFilter(request, thread);
              if (wasEnabled) {
                request.enable();
              }
            } catch (InternalException e) {
              LOG.info(e);
            }
          }
        }

        protected abstract void addFilter(final T request, final ThreadReference thread);
      }

      final EventRequestManager eventRequestManager = requestManager.getVMRequestManager();

      new FilterSetter<BreakpointRequest>() {
        @Override
        protected void addFilter(
            @NotNull final BreakpointRequest request, final ThreadReference thread) {
          request.addThreadFilter(thread);
        }
      }.applyFilter(eventRequestManager.breakpointRequests(), newFilterThread);

      new FilterSetter<MethodEntryRequest>() {
        @Override
        protected void addFilter(
            @NotNull final MethodEntryRequest request, final ThreadReference thread) {
          request.addThreadFilter(thread);
        }
      }.applyFilter(eventRequestManager.methodEntryRequests(), newFilterThread);

      new FilterSetter<MethodExitRequest>() {
        @Override
        protected void addFilter(
            @NotNull final MethodExitRequest request, final ThreadReference thread) {
          request.addThreadFilter(thread);
        }
      }.applyFilter(eventRequestManager.methodExitRequests(), newFilterThread);
    }
  }