Esempio n. 1
0
 private EventRequest createMethodRequest(JDXDebugTarget target, Object classFilter, boolean entry)
     throws CoreException {
   EventRequest request = null;
   EventRequestManager manager = target.getEventRequestManager();
   if (manager == null) {
     target.requestFailed(
         JDXMessages.JDXMethodBreakpoint_Unable_to_create_breakpoint_request___VM_disconnected__1,
         null); //$NON-NLS-1$
   }
   try {
     if (entry) {
       if (classFilter instanceof ClassType
           && getMethodName() != null
           && getMethodSignature() != null) {
         ClassType clazz = (ClassType) classFilter;
         if (clazz.name().equals(getTypeName())) {
           Method method = clazz.concreteMethodByName(getMethodName(), getMethodSignature());
           if (method != null && !method.isNative()) {
             Location location = method.location();
             if (location != null && location.codeIndex() != -1) {
               request = manager.createBreakpointRequest(location);
             }
           }
         }
       }
       if (request == null) {
         request = manager.createMethodEntryRequest();
         if (classFilter instanceof String) {
           ((MethodEntryRequest) request).addClassFilter((String) classFilter);
         } else if (classFilter instanceof ReferenceType) {
           ((MethodEntryRequest) request).addClassFilter((ReferenceType) classFilter);
         }
       }
     } else {
       request = manager.createMethodExitRequest();
       if (classFilter instanceof String) {
         ((MethodExitRequest) request).addClassFilter((String) classFilter);
       } else if (classFilter instanceof ReferenceType) {
         ((MethodExitRequest) request).addClassFilter((ReferenceType) classFilter);
       }
     }
     configureRequest(request, target);
   } catch (VMDisconnectedException e) {
     if (!target.isAvailable()) {
       return null;
     }
     Plugin.log(e);
   } catch (RuntimeException e) {
     target.internalError(e);
   }
   return request;
 }
 @Override
 protected void createRequests(JDXDebugTarget target) throws CoreException {
   if (target.isTerminated() || shouldSkipBreakpoint()) {
     return;
   }
   String referenceTypeName = getTypeName();
   if (referenceTypeName == null) {
     return;
   }
   ClassPrepareRequest request = target.createClassPrepareRequest(referenceTypeName, null, false);
   configureRequestHitCount(request);
   updateEnabledState(request, target);
   registerRequest(request, target);
   incrementInstallCount();
 }
  @Override
  protected void deregisterRequest(EventRequest request, JDXDebugTarget target)
      throws CoreException {
    target.removeEventListener(this, request);

    if (getMarker().exists()) {
      decrementInstallCount();
    }
  }
 @Override
 public boolean handleClassPrepareEvent(ClassPrepareEvent event, JDXDebugTarget target) {
   try {
     if (isEnabled() && event.referenceType().name().equals(getTypeName())) {
       ThreadReference threadRef = event.thread();
       JDXThread thread = target.findThread(threadRef);
       if (thread == null) {
         return true;
       }
       return handleBreakpointEvent(event, target, thread);
     }
   } catch (CoreException e) {
   }
   return true;
 }