Package com.sun.jdi.event

Examples of com.sun.jdi.event.Event


        //iniciar transacion
        JPAManager.getJPAManager().startTransaction();
       
        while(it.hasNext())
            {
            Event event=(Event) it.next();
            chrono.setLastNow();
           
            if(!(event instanceof AccessWatchpointEvent || event instanceof ModificationWatchpointEvent))
              System.out.println("*->" + event);
           
            if(event instanceof ThreadStartEvent)
              {
              //generar evento
              generatedEvents.add(dataManager.createThreadStartEvent((ThreadStartEvent) event));
             
              //resumir hilo
              resumir.add(((ThreadStartEvent) event).thread());
              }
           
            else if(event instanceof ThreadDeathEvent)
            {
              //generar evento
              generatedEvents.add(dataManager.createThreadDeathEvent((ThreadDeathEvent) event));
             
              //resumir hilo
              resumir.add(((ThreadDeathEvent) event).thread());
            }
           
            else if(event instanceof ClassPrepareEvent)
              {
              ClassPrepareEvent cpe=(ClassPrepareEvent) event;
                  ReferenceType rt = cpe.referenceType();
                 
                  //inspeccionar metodos
                  if(traceFilter.isTraceMethods())
                    {
                    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
              if(((EStackFrameLocatableEvent) event.request().getProperty("eEvent")).getStackFrameLocation().getStackFrame().getDepth()==((StepEvent) event).thread().frameCount())
                {
                //habilita 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.enable();
               
                //habilita 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.enable();
               
                //destruye step out
                event.request().disable();
                vm.eventRequestManager().deleteEventRequest(event.request());
               
                //habilita el siguiente step out
                if(vm.eventRequestManager().stepRequests().size()>0)
                  vm.eventRequestManager().stepRequests().get(vm.eventRequestManager().stepRequests().size()-1).enable();
                }
View Full Code Here


        int evento=0;
       
        while(it.hasNext())
            {
         
            Event event=it.next();
            chrono.setLastNow();
            //System.out.println("\t" + ++evento + ", " + event + " request:" +  event.request() + (event.request()!=null ? "suspendPolicy:" + event.request().suspendPolicy() : ""));
           
            if(event instanceof ThreadStartEvent)
              {
              generatedEvents.add(dataManager.createThreadStartEvent((ThreadStartEvent) event));
              resumir.add(((ThreadStartEvent) event).thread());
              }
           
            else if(event instanceof ThreadDeathEvent)
            {
              generatedEvents.add(dataManager.createThreadDeathEvent((ThreadDeathEvent) event));
              resumir.add(((ThreadDeathEvent) event).thread());
            }
           
            else if(event instanceof ClassPrepareEvent)
              {
              ClassPrepareEvent cpe=(ClassPrepareEvent) event;
                           
              //deshabilitar evento
              /*event.request().disable();
                  vm.eventRequestManager().deleteEventRequest(event.request());
                  */
                  ReferenceType rt = cpe.referenceType();
                 
                  //inspeccion method entry y method exit
                  //primero se ejecuta el breakpoint
                  if(traceFilter.isTraceMethods())
                    {
                    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));
                        br.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                        br.putProperty("START", false);
                        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);
                    }
                 
                  //evento
                  generatedEvents.add(dataManager.createClassLoadEvent(cpe));
                 
                  resumir.add(((ClassPrepareEvent) event).thread());
              }
            //se entro a un evento
            else if(event instanceof BreakpointEvent)
              {
              //System.out.println("\t\t" + event);//////////////////////
              //printStackTrace(((BreakpointEvent) event).thread());
             
              BreakpointEvent be=(BreakpointEvent) event;
              /*
              if((Boolean) be.request().getProperty("START"))
                {
                if(!be.location().method().isConstructor())
                    {
                  generatedEvents.add(dataManager.createMethodEntryEvent(be));
                    }
                else
                    {
                  generatedEvents.add(dataManager.createNewObjectEvent(be));
                    }
                }
              */
              /*if(vm.eventRequestManager().methodEntryRequests().size()==0)
                {
                MethodEntryRequest mer = vm.eventRequestManager().createMethodEntryRequest();
                    mer.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mer.addThreadFilter(be.thread());
                   
                    MethodExitRequest mxr = vm.eventRequestManager().createMethodExitRequest();
                    mxr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
                    mxr.addThreadFilter(be.thread());
                }
             
              habilitarMethodEvents=true;
              System.out.println("\t\t\t" + "solicitar eventos metodos: " + habilitarMethodEvents);//////////////////////
              */
             
//              //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("eEvent", eEvent);
                    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("eEvent", eEvent);
                    mxr.setEnabled(true);
                    //System.out.println("\t\t\teventID: " + eEvent.getId());
                }
//                  
//                    entries.add(eEvent);
//                   
//                  //crea step into
//                if(vm.eventRequestManager().stepRequests().size()>0)
//                  {
//                  vm.eventRequestManager().stepRequests().get(0).disable();
//                  vm.eventRequestManager().deleteEventRequest(vm.eventRequestManager().stepRequests().get(0));
//                  }
//               
//                StepRequest sr = vm.eventRequestManager().createStepRequest(be.thread(), StepRequest.STEP_MIN, StepRequest.STEP_INTO);
//                sr.addCountFilter(1);
//                sr.putProperty("eEvent", eEvent);
//                sr.setEnabled(true);
//                }
//              /*
//              MethodEntryRequest mer = vm.eventRequestManager().createMethodEntryRequest();
//                  mer.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
//                  mer.putProperty("eEvent", eEvent);
//                  mer.setEnabled(true);
//             
//              MethodExitRequest mxr = vm.eventRequestManager().createMethodExitRequest();
//                  mxr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
//                  mer.putProperty("eEvent", eEvent);
//                  mxr.setEnabled(true);*/
              }
            //se esta bajando en el stacktrace
            else if(event instanceof MethodEntryEvent)
              {/*
              System.out.println("\t\t" + event);//////////////////////
              if(vm.eventRequestManager().methodEntryRequests().size()>0)
                {
                habilitarMethodEvents=false;
                System.out.println("\t\t\t" + "solicitar eventos metodos: " + habilitarMethodEvents);//////////////////////
                //vm.eventRequestManager().deleteEventRequests(vm.eventRequestManager().methodEntryRequests());
                //vm.eventRequestManager().deleteEventRequests(vm.eventRequestManager().methodExitRequests());
                }
              /*
              System.out.println("no tuvo que haber entrado aqui!!!");
              if(event.request().getProperty("eEvent")==null)
                {
                System.out.println("extra " + event + ", " + ((MethodEntryEvent) event).thread().frames().size());
                printStackTrace(((MethodEntryEvent) event).thread());
                }
              else{
              */
              //System.out.println("\t\t" + event + "," + ((EEvent)event.request().getProperty("eEvent")).getId());//////////////////////
              //printStackTrace(((MethodEntryEvent) event).thread());
             
              //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();
             
              //desabiliat otros steps requests
              if(vm.eventRequestManager().stepRequests().size()>0)
                vm.eventRequestManager().stepRequests().get(vm.eventRequestManager().stepRequests().size()-1).disable();
             
              StepRequest sr = vm.eventRequestManager().createStepRequest(((MethodEntryEvent) event).thread(), StepRequest.STEP_LINE, StepRequest.STEP_OUT);
              //sr.addCountFilter(1);
              sr.putProperty("eEvent", event.request().getProperty("eEvent"));
              sr.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD);
              sr.setEnabled(true);
              //}
              }
            else if(event instanceof MethodExitEvent)
              {
              /*System.out.println("\t\t" + event);//////////////////////
              //generar evento
              generatedEvents.add(dataManager.createMethodExitEvent((MethodExitEvent) event));
             
              habilitarMethodEvents=false;
              System.out.println("\t\t\t" + "solicitar eventos metodos: " + habilitarMethodEvents);//////////////////////
              //vm.eventRequestManager().deleteEventRequests(vm.eventRequestManager().methodEntryRequests());
              //vm.eventRequestManager().deleteEventRequests(vm.eventRequestManager().methodExitRequests());
             
//              if(event.request().getProperty("eEvent")==null)
//                {System.out.println("extra " + event + ", " + ((MethodExitEvent) event).thread().frames().size());
//                printStackTrace(((MethodExitEvent) event).thread());
//                }
//              else{*/
              //System.out.println("\t\t" + event + ", " + ((EEvent)event.request().getProperty("eEvent")).getId());//////////////////////
              //printStackTrace(((MethodExitEvent) event).thread());
             
              //System.out.println("method exit event depth: " + ((MethodExitEvent) event).thread().frames().size());
              //System.out.println("method exit request depth: " + ((EStackFrameLocatableEvent)event.request().getProperty("eEvent")).getStackFrame().getDepth());
              //if(((MethodExitEvent) event).thread().frames().size()==((EStackFrameLocatableEvent)event.request().getProperty("eEvent")).getStackFrame().getDepth())
                {
                //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 step into
                /*StepRequest s = null;
                for(StepRequest se : vm.eventRequestManager().stepRequests())
                  {
                  Long id=((EEvent)se.getProperty("eEvent")).getId();
                  if(id!=null && id.equals(((EEvent)event.request().getProperty("eEvent")).getId()))
                    {
                    mer=se;
                    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)
              {
              //System.out.println(event + "... " + (((StepRequest)event.request()).depth()==StepRequest.STEP_INTO ? "IN" : "OUT"));//////////////////////
              //printStackTrace(((StepEvent) event).thread());
              /*
              if(((StepRequest)event.request()).depth()==StepRequest.STEP_INTO)
                {
                event.request().disable();
                vm.eventRequestManager().deleteEventRequest(event.request());
                StepRequest sr = vm.eventRequestManager().createStepRequest(((StepEvent) event).thread(), StepRequest.STEP_MIN, StepRequest.STEP_OUT);
                sr.addCountFilter(1);
                sr.putProperty("eEvent", event.request().getProperty("eEvent"));
                sr.setEnabled(true);
               
                //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)mx.getProperty("eEvent")).getId()))
                    {
                    mxr=mx;
                    break;
                    }
                  }
               
                mxr.disable();
                }
              else
                {
                event.request().disable();
                vm.eventRequestManager().deleteEventRequest(event.request());
                StepRequest sr = vm.eventRequestManager().createStepRequest(((StepEvent) event).thread(), StepRequest.STEP_MIN, StepRequest.STEP_INTO);
                sr.addCountFilter(1);
                sr.putProperty("eEvent", event.request().getProperty("eEvent"));
                sr.setEnabled(true);
               
                //habilita method exit
                MethodExitRequest mxr = null;
                for(MethodExitRequest mx : vm.eventRequestManager().methodExitRequests())
                  {
                  Long id=((EEvent)mx.getProperty("eEvent")).getId();
                  if(id!=null && id.equals(((EEvent)mx.getProperty("eEvent")).getId()))
                    {
                    mxr=mx;
                    break;
                    }
                  }
               
                mxr.enable();
                }
              /*
              if(((StepRequest)event.request()).depth()==StepRequest.STEP_INTO)
                {
                System.out.println("IN: " + event + "... " + ((StepEvent) event).thread().frameCount());
                event.request().disable();
                vm.eventRequestManager().deleteEventRequest(event.request());
                StepRequest sr = vm.eventRequestManager().createStepRequest(((StepEvent) event).thread(), StepRequest.STEP_MIN, StepRequest.STEP_OUT);
                sr.addCountFilter(1);
                sr.setEnabled(true);
                }
              else
                {
                System.out.println("OUT: " + event + "... " + ((StepEvent) event).thread().frameCount());
                event.request().disable();
                vm.eventRequestManager().deleteEventRequest(event.request());
                StepRequest sr = vm.eventRequestManager().createStepRequest(((StepEvent) event).thread(), StepRequest.STEP_MIN, StepRequest.STEP_INTO);
                sr.addCountFilter(1);
                sr.setEnabled(true);
                }
              */
               
              //System.out.println("\t\t" + event + "... " + ((StepEvent) event).location() + ", " + ((EEvent)event.request().getProperty("eEvent")).getId());//////////////////////
              //printStackTrace(((StepEvent) event).thread());
             
              //System.out.println("offical depth: " + ((EStackFrameLocatableEvent) event.request().getProperty("eEvent")).getStackFrame().getDepth());
              //System.out.println("real: " + ((StepEvent) event).thread().frameCount());
              //generar otro step out
              if(((EStackFrameLocatableEvent) event.request().getProperty("eEvent")).getStackFrame().getDepth()<((StepEvent) event).thread().frameCount())
                {
                }
              else
                {
                //habilita 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.enable();
               
                //habilita 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.enable();
               
                //destruye step out
                event.request().disable();
                vm.eventRequestManager().deleteEventRequest(event.request());
               
                //habilita el siguiente step out
                if(vm.eventRequestManager().stepRequests().size()>0)
                  vm.eventRequestManager().stepRequests().get(vm.eventRequestManager().stepRequests().size()-1).enable();
               
View Full Code Here

      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      EventIterator eventIterator = eventSet.eventIterator();
      while (eventIterator.hasNext()) {
        Event event = (Event) eventIterator.next();
        if (event instanceof VMStartEvent) {
          handleVMStartEvent((VMStartEvent)event);
        } else if (event instanceof ClassPrepareEvent) {
          handleClassPrepareEvent((ClassPrepareEvent)event);
        } else if (event instanceof BreakpointEvent) {
View Full Code Here

            do {
                EventSet eventSet = eventQueue.remove();
                long eventIniTime = System.currentTimeMillis();
                //int resumeVMtimes = 0;
                for(EventIterator i = eventSet.eventIterator(); i.hasNext(); ) {
                    Event evt = i.nextEvent();
                    if(evt instanceof ClassPrepareEvent) {
                        ClassPrepareEvent cpe = (ClassPrepareEvent) evt;
                        ReferenceType refType = cpe.referenceType();
                        logClazz.debug("Loading: " + refType.name() + " [cl:" + refType.classLoader()+"]");
                        loadClassDebug(refType, cpe.thread());
View Full Code Here

                break;
            }
            eventSet = eventQueue.remove();
            EventIterator eventIterator = eventSet.eventIterator();
            while (eventIterator.hasNext()) {
                Event event = (Event) eventIterator.next();
                execute(event);
            }
            if (!isExit) {
                eventSet.resume();
            }
View Full Code Here

        if (es == null) {
          break;
        }
      }
      for (final EventIterator ei = es.eventIterator(); ei.hasNext();) {
        final Event e = ei.nextEvent();
        consoleOut.println("== Event received: " + e.toString());
        if (!done && e instanceof StepEvent) {
          final StepEvent se = (StepEvent) e;
          final ThreadReference tr = se.thread();
          vm.eventRequestManager().deleteEventRequest(se.request());
          final List stepRequests = new ArrayList(vm.eventRequestManager().stepRequests());
View Full Code Here

          if (es == null) {
            break;
          }
        }
        for (final EventIterator ei = es.eventIterator(); ei.hasNext();) {
          final Event e = ei.nextEvent();
          if (!done && e instanceof BreakpointEvent) {
            final BreakpointEvent be = (BreakpointEvent) e;
            final Location loc = be.location();
            final ThreadReference tr = be.thread()
            if (loc.equals(interceptIn)) {
              LocalVariable result = (LocalVariable) loc.method().variablesByName("result").get(0);
              LocalVariable buffer = (LocalVariable) loc.method().arguments().get(0);
              ArrayReference buf = (ArrayReference) tr.frame(0).getValue(buffer);
              new InputInterceptHandler(tr, buf, result).start();
            } else if (loc.equals(interceptOut)) {
              LocalVariable result = (LocalVariable) loc.method().variablesByName("result").get(0);
              LocalVariable data = (LocalVariable) loc.method().arguments().get(0);
              ArrayReference buf = (ArrayReference) tr.frame(0).getValue(data);
              List values = buf.getValues();
              byte[] temp = new byte[buf.length()];
              for (int i = 0; i < temp.length; i++) {
                temp[i] = ((ByteValue)values.get(i)).byteValue();
              }
              pipedOut.write(temp);
              pipedOut.flush();
              if (temp.length == 0) {
                pipedOut.close();
                pipedIn.close();
                done = true;
              }
              tr.frame(0).setValue(result, vm.mirrorOf(true));
              tr.resume();
            } else {
              throw new RuntimeException("Unknown location: "+loc);
           
          } else {
            System.out.println("== Unknown event received: " + e.toString());
            es.resume();
          }
        }
      }
    }
View Full Code Here

/* 216 */         EventSet events = null;
/*     */         try {
/* 218 */           events = HotSwapper.this.waitEvent();
/* 219 */           EventIterator iter = events.eventIterator();
/* 220 */           while (iter.hasNext()) {
/* 221 */             Event event = iter.nextEvent();
/* 222 */             if ((event instanceof MethodEntryEvent)) {
/* 223 */               HotSwapper.this.hotswap();
/* 224 */               break;
/*     */             }
/*     */           }
View Full Code Here

    while (iter.hasNext()) {
      index++;
      if (isShutdown()) {
        return;
      }
      Event event = iter.nextEvent();
      if (event == null) {
        continue;
      }
      // Dispatch events to registered listeners, if any
      IJDIEventListener listener = fEventHandlers.get(event.request());
      listeners[index] = listener;
      if (listener != null) {
        if (listener instanceof IJavaLineBreakpoint) {
          // Event dispatch to conditional breakpoints is deferred
          // until after
          // other listeners vote.
          try {
            if (((IJavaLineBreakpoint) listener).isConditionEnabled()) {
              if (deferredEvents == null) {
                deferredEvents = new ArrayList<Event>(5);
              }
              deferredEvents.add(event);
              continue;
            }
          } catch (CoreException exception) {
            JDIDebugPlugin.log(exception);
          }
        }
        vote = true;
        resume = listener.handleEvent(event, fTarget, !resume, eventSet) && resume;
        continue;
      }

      // Dispatch VM start/end events
      if (event instanceof VMDeathEvent) {
        fTarget.handleVMDeath((VMDeathEvent) event);
        shutdown(); // stop listening for events
      } else if (event instanceof VMDisconnectEvent) {
        fTarget.handleVMDisconnect((VMDisconnectEvent) event);
        shutdown(); // stop listening for events
      } else if (event instanceof VMStartEvent) {
        fTarget.handleVMStart((VMStartEvent) event);
      } else {
        // not handled
      }
    }

    // process deferred conditional breakpoint events
    if (deferredEvents != null) {
      Iterator<Event> deferredIter = deferredEvents.iterator();
      while (deferredIter.hasNext()) {
        if (isShutdown()) {
          return;
        }
        Event event = deferredIter.next();
        if (event == null) {
          continue;
        }
        // Dispatch events to registered listeners, if any
        IJDIEventListener listener = fEventHandlers
            .get(event.request());
        if (listener != null) {
          vote = true;
          resume = listener.handleEvent(event, fTarget, !resume, eventSet) && resume;
          continue;
        }
      }
    }

    // notify handlers of the end result
    index = -1;
    iter = eventSet.eventIterator();
    while (iter.hasNext()) {
      index++;
      Event event = iter.nextEvent();
      // notify registered listener, if any
      IJDIEventListener listener = listeners[index];
      if (listener != null) {
        listener.eventSetComplete(event, fTarget, !resume, eventSet);
      }
View Full Code Here

              public boolean belongsTo(Object family) {
                if (family instanceof Class) {
                  Class<?> clazz = (Class<?>) family;
                  EventIterator iterator = set.eventIterator();
                  while (iterator.hasNext()) {
                    Event event = iterator.nextEvent();
                    if (clazz.isInstance(event)) {
                      return true;
                    }
                  }
                }
View Full Code Here

TOP

Related Classes of com.sun.jdi.event.Event

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.