Package com.sun.jdi.request

Examples of com.sun.jdi.request.BreakpointRequest


                                   JDIDebugTarget target) {
            ClassType classType = ( ClassType ) ((ClassPrepareEvent) event).referenceType();
            String name = classType.name();

            // change this to create a breakpoint, as the method enter was too slow
            BreakpointRequest req = null;
            List<Method> list = classType.methodsByName( "onBreak" );
            if list.size() == 0 ) {
                throw new IllegalStateException( "MVELDebugHandler.onBreak cannot be found by JDI" );
            }
           
            Method method = list.get( 0 );
            if (method != null && !method.isNative()) {
                Location location = method.location();
                if (location != null && location.codeIndex() != -1) {
                    req = getEventRequestManager().createBreakpointRequest(location);
                    req.addThreadFilter( ((ClassPrepareEvent) event).thread() );
                    req.setSuspendPolicy( EventRequest.SUSPEND_ALL  );
                } else {
                    throw new IllegalStateException( "MVELDebugHandler.onBreak location cannot be found by JDI" );
                }
            }    else {
                throw new IllegalStateException( "MVELDebugHandler.onBreak cannot be found by JDI" );
            }
           

            //breakpointCatched

            /*field= type.fieldByName(getFieldName());
             Field field;
             EventRequest req= manager.createModificationWatchpointRequest(field);
             */
            //req.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD );
            addJDIEventListener(new IJDIEventListener() {

                public boolean handleEvent(Event event, JDIDebugTarget target) {
                    BreakpointEvent entryEvent = (BreakpointEvent) event;

                    //System.out.println( entryEvent + ":" + entryEvent.location() );

                    try {
                        IThread[] tharr = getThreads();
                        ThreadReference t = null;
                        DroolsThread t2 = null;
                        for (int i = 0; i < tharr.length; i++) {
                            DroolsThread th2 = (DroolsThread) tharr[i];
                            ThreadReference th2real = ((DroolsThread) tharr[i]).getUnderlyingThread();
                            if (th2real.suspendCount() == 1    && th2.getName().equals("main")) {
                                t = th2real;
                                t2 = (DroolsThread) th2;
                                th2real.suspend();
                                th2.setRunning(false);
                                th2.fireSuspendEvent(DebugEvent.CLIENT_REQUEST);
                                return true;
                            }
                        }
                    } catch (Exception t) {
                        logError(t);
                    }
                    return true;
                }

                public void wonSuspendVote(Event event, JDIDebugTarget target) {
                    // do nothing
                }

                public void eventSetComplete(Event event, JDIDebugTarget target, boolean suspend, EventSet eventSet) {
                    wonSuspendVote(event, target);
                }

                public boolean handleEvent(Event event, JDIDebugTarget target, boolean suspendVote, EventSet eventSet) {
                    return handleEvent(event, target);
                }

            }, req);

            req.enable();
           
            // now remove the ClassPrepareEvent
            removeJDIEventListener(MVELTraceHandler.this, ((ClassPrepareEvent) event).request() );

            return true;
View Full Code Here


  private void installHaltPoint(VirtualMachine vm) {
    List<ReferenceType> targetClasses = vm
        .classesByName(VMLocalTarget.class.getName());
    ReferenceType classRef = targetClasses.get(0);
    Method meth = classRef.methodsByName("haltPoint").get(0);
    BreakpointRequest req = vm.eventRequestManager()
        .createBreakpointRequest(meth.location());
    req.setSuspendPolicy(BreakpointRequest.SUSPEND_EVENT_THREAD);
    req.enable();
  }
View Full Code Here

              for (Breakpoint bp : EditorFacade.getInstance().getBreakpoints()) {
                if (bp.getClassName().equals(cpe.referenceType().name())) {
                  List<Method> mlist = cpe.referenceType().methodsByName(bp.getMethodName(), bp.getMethodDesc().getRawDesc());
                  if (mlist.size() > 0) {
                    Location loc = mlist.get(0).locationOfCodeIndex(bp.getPc());
                    BreakpointRequest bpr = vm.eventRequestManager().createBreakpointRequest(loc);
                    bpr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
                    bpr.setEnabled(true);
                  } else {
                    logger.warning("Error, breakpoint " + bp + " method not found in EventHandler.");
                  }
                }
              }
View Full Code Here

              List<ReferenceType> list = vm.classesByName(bp.getClassName());
              if (list.size() > 0) {
                List<Method> mlist = list.get(0).methodsByName(bp.getMethodName(), bp.getMethodDesc().getRawDesc());
                if (mlist.size() > 0) {
                  Location loc = mlist.get(0).locationOfCodeIndex(bp.getPc());
                  BreakpointRequest bpr = vm.eventRequestManager().createBreakpointRequest(loc);
                  bpr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
                  bpr.setEnabled(true);
                } else {
                  logger.warning("Error, breakpoint " + bp + " method not found.");
                }
              } else {
                // add a class load breakpoint
View Full Code Here

      List<ReferenceType> list = vm.classesByName(breakpoint.getClassName());
      if (list.size() > 0) {
        List<Method> mlist = list.get(0).methodsByName(breakpoint.getMethodName(), breakpoint.getMethodDesc().getRawDesc());
        if (mlist.size() > 0) {
          Location loc = mlist.get(0).locationOfCodeIndex(breakpoint.getPc());
          BreakpointRequest bpr = vm.eventRequestManager().createBreakpointRequest(loc);
          bpr.setSuspendPolicy(EventRequest.SUSPEND_ALL);
          bpr.setEnabled(true);
        } else {
          logger.warning("Error, live breakpoint " + breakpoint + " method not found.");
        }
      } else {
        // add a class load breakpoint
View Full Code Here

                    {
                    for(Method method : rt.methods())
                       {
                      if(method.location()!=null)
                        {
                        BreakpointRequest br = vm.eventRequestManager().createBreakpointRequest(method.location());
                        br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                        br.setEnabled(true);
                        }
                       }
                    }
               
                  //inspeccion de acceso y modificacionde atributos
                  if(traceFilter.isTraceFields())
                    {
                    for(Field field : rt.fields())
                      {
                      AccessWatchpointRequest awr = vm.eventRequestManager().createAccessWatchpointRequest(field);
                      awr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                      awr.setEnabled(true);
                     
                      ModificationWatchpointRequest mwr = vm.eventRequestManager().createModificationWatchpointRequest(field);
                      mwr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                      mwr.setEnabled(true);
                      }
                    }
                 
                  //inspeccionar excepciones
                  if(traceFilter.isTraceExceptions())
                    {
                    ExceptionRequest er = vm.eventRequestManager().createExceptionRequest(null, true, true);
                    er.addClassFilter(rt);
                    er.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    er.setEnabled(true);
                    }
                 
                  EClassLoadEvent eEvent;
            //generar evento
                  generatedEvents.add(eEvent=dataManager.createClassLoadEvent(cpe));
                 
                  //resumir hilo
                  resumir.add(((ClassPrepareEvent) event).thread());
                 
                  //if(rt.name().equals("one.PruebaStack"))
                    {
                    MethodEntryRequest mer = vm.eventRequestManager().createMethodEntryRequest();
                    mer.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mer.addThreadFilter(cpe.thread());
                    mer.putProperty("threadName", cpe.thread().name());
                    mer.putProperty("eEvent", eEvent);
                    mer.putProperty("where", "class load");
                    //mer.addClassFilter("one.PruebaStack");
                    mer.addClassFilter(rt);
                    mer.setEnabled(true);
                   
                    MethodExitRequest mxr = vm.eventRequestManager().createMethodExitRequest();
                    mxr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mxr.addThreadFilter(cpe.thread());
                    mxr.putProperty("threadName", cpe.thread().name());
                    mxr.putProperty("eEvent", eEvent);
                    mxr.putProperty("where", "breakpoint");
                    mxr.addClassFilter(rt);
                    mxr.setEnabled(true);
                    }
                  }
            //se entro a un metodo
            else if(event instanceof BreakpointEvent)
              {             
              BreakpointEvent be=(BreakpointEvent) event;
             
              //if(be.location().lineNumber()!=9)
              //{
             
              if(be.request().getProperty(((BreakpointEvent) event).thread().name())!=null)
                {
                be.request().putProperty(((BreakpointEvent) event).thread().name(), null);
                }
              else
                {
                //generar evento
                EEvent eEvent=null;
                if(!be.location().method().isConstructor())
                    generatedEvents.add(eEvent=dataManager.createMethodEntryEvent(be));
                else
                  generatedEvents.add(eEvent=dataManager.createNewObjectEvent(be));
 
                //crea method entry para desactivar method exit cuando empiece a bajar en el stack trace
                MethodEntryRequest mer = vm.eventRequestManager().createMethodEntryRequest();
                    mer.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mer.addThreadFilter(be.thread());
                    mer.putProperty("threadName", be.thread().name());
                    mer.putProperty("eEvent", eEvent);
                    mer.putProperty("where", "breakpoint");
                    mer.setEnabled(true);
               
                    //crea method exit para cuando salga de este stacktrace
                MethodExitRequest mxr = vm.eventRequestManager().createMethodExitRequest();
                    mxr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mxr.addThreadFilter(be.thread());
                    mxr.putProperty("threadName", be.thread().name());
                    mxr.putProperty("eEvent", eEvent);
                    mxr.putProperty("where", "breakpoint");
                    mxr.setEnabled(true);
                }
             
              /*}
              else if(!already)
              {
               
                //generar evento
                EEvent eEvent=null;
                if(!be.location().method().isConstructor())
                    generatedEvents.add(eEvent=dataManager.createMethodEntryEvent(be));
                else
                  generatedEvents.add(eEvent=dataManager.createNewObjectEvent(be));
 
                //crea method entry para desactivar method exit cuando empiece a bajar en el stack trace
                MethodEntryRequest mer = vm.eventRequestManager().createMethodEntryRequest();
                    mer.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mer.addThreadFilter(be.thread());
                    mer.putProperty("threadName", be.thread().name());
                    mer.putProperty("eEvent", eEvent);
                    mer.putProperty("where", "breakpoint");
                    mer.setEnabled(true);
               
                    //crea method exit para cuando salga de este stacktrace
                MethodExitRequest mxr = vm.eventRequestManager().createMethodExitRequest();
                    mxr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mxr.addThreadFilter(be.thread());
                    mxr.putProperty("threadName", be.thread().name());
                    mxr.putProperty("eEvent", eEvent);
                    mxr.putProperty("where", "breakpoint");
                    mxr.setEnabled(true);
                   
                    already=true;
               
              }*/
              }
            //se esta bajando en el stacktrace
            else if(event instanceof MethodEntryEvent)
              {
              //TODO si se esta filtrando por hilos?
              //System.out.println("*->" + event + "(" + event.hashCode() + ")" + " -> " + event.request().getProperty("where") + " filter thread: " + event.request().getProperty("threadName"));
              //deshabilita method entry
              event.request().disable();
             
              //deshabilita method exit
              MethodExitRequest mxr = null;
              for(MethodExitRequest mx : vm.eventRequestManager().methodExitRequests())
                {
                Long id=((EEvent)mx.getProperty("eEvent")).getId();
                if(id!=null && id.equals(((EEvent)event.request().getProperty("eEvent")).getId()))
                  {
                  mxr=mx;
                  break;
                  }
                }
             
              mxr.disable();
             
              //desabilitar otros steps requests
              if(vm.eventRequestManager().stepRequests().size()>0)
                vm.eventRequestManager().stepRequests().get(vm.eventRequestManager().stepRequests().size()-1).disable();
             
              //crea step out para cuando regrese a este stack frame
              StepRequest sr = vm.eventRequestManager().createStepRequest(((MethodEntryEvent) event).thread(), StepRequest.STEP_LINE, StepRequest.STEP_OUT);
              sr.putProperty("eEvent", event.request().getProperty("eEvent"));
              sr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
              sr.setEnabled(true);
              }
            else if(event instanceof MethodExitEvent)
              {
              //System.out.println("*->" + event + "(" + event.hashCode() + ")" + " -> " + event.request().getProperty("where") + " filter thread: " + event.request().getProperty("threadName"));
              //generar evento
              generatedEvents.add(dataManager.createMethodExitEvent((MethodExitEvent) event));
             
              //destruye method entry
              MethodEntryRequest mer = null;
              for(MethodEntryRequest me : vm.eventRequestManager().methodEntryRequests())
                {
                Long id=((EEvent)me.getProperty("eEvent")).getId();
                if(id!=null && id.equals(((EEvent)event.request().getProperty("eEvent")).getId()))
                  {
                  mer=me;
                  break;
                  }
                }
             
              mer.disable();
              vm.eventRequestManager().deleteEventRequest(mer);
             
              //destruye method exit
              event.request().disable();
              vm.eventRequestManager().deleteEventRequest(event.request());
              }
            //se esta subiendo en el stack trace
            else if(event instanceof StepEvent)
              {
              ///////////////
              for(BreakpointRequest br : vm.eventRequestManager().breakpointRequests())
                  {
                  if(br.location().equals(((StepEvent) event).location()))
                    {
                    br.putProperty(((StepEvent) event).thread().name(), "after step event");
                    }
                  }
              //////////////////////
             
              //generar otro step out
View Full Code Here

                    {
                    for(Method method : rt.methods())
                       {
                      if(method.location()!=null)
                        {
                        BreakpointRequest br = vm.eventRequestManager().createBreakpointRequest(method.location());
                        br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                        br.putProperty("START", true);
                        br.setEnabled(true);
                        }
                      /*
                      for(int i=1; i<method.allLineLocations().size(); i++)
                        {
                        br = vm.eventRequestManager().createBreakpointRequest(method.allLineLocations().get(i));
View Full Code Here

        lines = rt.locationsOfLine(lineNum);
        if (lines.size() == 0) {
          continue;
        }
        Location loc = lines.get(0);
        BreakpointRequest request = vm.eventRequestManager().createBreakpointRequest(loc);
        request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
        request.setEnabled(true);
        breakpoint.addRequest(request);
      } catch (AbsentInformationException e) {
        e.printStackTrace();
      }
    }
View Full Code Here

                                   JDIDebugTarget target) {
            ClassType classType = ( ClassType ) ((ClassPrepareEvent) event).referenceType();
            String name = classType.name();

            // change this to create a breakpoint, as the method enter was too slow
            BreakpointRequest req = null;
            List list = classType.methodsByName( "onBreak" );
            if list.size() == 0 ) {
                throw new IllegalStateException( "MVELDebugHandler.onBreak cannot be found by JDI" );
            }
           
            Method method = ( Method ) list.get( 0 );
            if (method != null && !method.isNative()) {
                Location location = method.location();
                if (location != null && location.codeIndex() != -1) {
                    req = getEventRequestManager().createBreakpointRequest(location);
                    req.addThreadFilter( ((ClassPrepareEvent) event).thread() );
                    req.setSuspendPolicy( EventRequest.SUSPEND_ALL  );
                } else {
                    throw new IllegalStateException( "MVELDebugHandler.onBreak location cannot be found by JDI" );
                }
            }    else {
                throw new IllegalStateException( "MVELDebugHandler.onBreak cannot be found by JDI" );
            }
           

            //breakpointCatched

            /*field= type.fieldByName(getFieldName());
             Field field;
             EventRequest req= manager.createModificationWatchpointRequest(field);
             */
            //req.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD );
            addJDIEventListener(new IJDIEventListener() {

                public boolean handleEvent(Event event, JDIDebugTarget target) {
                    BreakpointEvent entryEvent = (BreakpointEvent) event;

                    //System.out.println( entryEvent + ":" + entryEvent.location() );

                    try {
                        IThread[] tharr = getThreads();
                        ThreadReference t = null;
                        DroolsThread t2 = null;
                        for (int i = 0; i < tharr.length; i++) {
                            DroolsThread th2 = (DroolsThread) tharr[i];
                            ThreadReference th2real = ((DroolsThread) tharr[i]).getUnderlyingThread();
                            if (th2real.suspendCount() == 1    && th2.getName().equals("main")) {
                                t = th2real;
                                t2 = (DroolsThread) th2;
                                th2real.suspend();
                                th2.setRunning(false);
                                th2.fireSuspendEvent(DebugEvent.CLIENT_REQUEST);
                                return true;
                            }
                        }
                    } catch (Exception t) {
                        logError(t);
                    }
                    return true;
                }

                public void wonSuspendVote(Event event, JDIDebugTarget target) {
                    // do nothing
                }

                public void eventSetComplete(Event event, JDIDebugTarget target, boolean suspend, EventSet eventSet) {
                    wonSuspendVote(event, target);
                }

                public boolean handleEvent(Event event, JDIDebugTarget target, boolean suspendVote, EventSet eventSet) {
                    return handleEvent(event, target);
                }

            }, req);

            req.enable();
           
            // now remove the ClassPrepareEvent
            removeJDIEventListener(MVELTraceHandler.this, ((ClassPrepareEvent) event).request() );

            return true;
View Full Code Here

        // Delete any record of the breakpoints
        List<BreakpointRequest> toDelete = new ArrayList<BreakpointRequest>();
        EventRequestManager erm = eventRequestManager();
        it = erm.breakpointRequests().iterator();
        while (it.hasNext()) {
            BreakpointRequest req = (BreakpointRequest)it.next();
            if (classToBytes.containsKey(req.location().declaringType())) {
                toDelete.add(req);
            }
        }
        erm.deleteEventRequests(toDelete);
View Full Code Here

TOP

Related Classes of com.sun.jdi.request.BreakpointRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.