コード例 #1
0
 /** Performs stop action. */
 void stop(boolean stop, final AbstractThread thread) {
   final ResourceBundle bundle = NbBundle.getBundle(JPDADebugger.class);
   if (stop) {
     removeStepRequest();
     setLastAction(ACTION_BREAKPOINT_HIT);
     setDebuggerState(DEBUGGER_STOPPED);
     operator.stopRequest();
     SwingUtilities.invokeLater(
         new Runnable() {
           public void run() {
             thread.setCurrent(true);
             updateWatches();
             threadGroup.refresh();
           }
         });
   } else operator.resume();
 }
コード例 #2
0
 /**
  * If this line can not be current => stepOver & return true. {support for non java languages}
  *
  * <p>return false on the other hand.
  */
 boolean resolveCanBeCurrent(ThreadReference tr, Line l) {
   if ((l != null) && (!canBeCurrent(l, false))) {
     try {
       removeStepRequest();
       findSourceSR =
           requestManager.createStepRequest(tr, StepRequest.STEP_LINE, StepRequest.STEP_OVER);
       findSourceSR.addCountFilter(1);
       findSourceSR.setSuspendPolicy(EventRequest.SUSPEND_ALL);
       operator.register(findSourceSR, this);
       findSourceSR.enable();
       operator.resume();
     } catch (DuplicateRequestException e) {
       e.printStackTrace();
     }
     return true;
   }
   return false;
 }
コード例 #3
0
  /** Finds the first executed line with source code. */
  public void traceToSourceCode(ThreadReference thread) {
    // S ystem.out.println ("Start finding!!! "); // NOI18N

    // create Step Request for searching a source code
    try {
      findSourceSR =
          requestManager.createStepRequest(thread, StepRequest.STEP_LINE, StepRequest.STEP_OUT);
      findSourceSR.addCountFilter(1);
      findSourceSR.setSuspendPolicy(EventRequest.SUSPEND_ALL);
      operator.register(findSourceSR, this);
      findSourceSR.enable();
    } catch (DuplicateRequestException e) {
      e.printStackTrace();
    }

    // create Method Entry Request for searching a source code
    findSourceMER = requestManager.createMethodEntryRequest();
    findSourceMER.setSuspendPolicy(EventRequest.SUSPEND_ALL);
    findSourceMER.addThreadFilter(thread);
    findSourceCounter = 0;
    operator.register(
        findSourceMER,
        new Executor() {
          public void exec(com.sun.jdi.event.Event event) {
            if (findSourceCounter == 500) {
              // finding source takes a long time
              operator.resume();
              if (findSourceMER != null) {
                requestManager.deleteEventRequest(findSourceMER);
                findSourceMER = null;
              }
              return;
            }
            findSourceCounter++;

            Location loc = ((MethodEntryEvent) event).location();
            if (loc == null) {
              // no line => continue finding
              operator.resume();
              return;
            }
            String className = loc.declaringType().name();
            int ln = loc.lineNumber();
            // S ystem.out.println ("FIND " + className + " : " + ln); // NOI18N
            try {
              Line l = null;
              if ((l = Utils.getLineForSource(className, loc.sourceName(), ln)) == null) {
                // no line => continue finding
                operator.resume();
                return;
              }

              // WOW I have a nice line!
              ThreadReference tr = ((MethodEntryEvent) event).thread();
              if (resolveCanBeCurrent(tr, l))
                // if can not be current => steps to some line
                return;

              // line can be current!
              String threadName = tr.name();
              String methodName = loc.method() != null ? loc.method().name() : ""; // NOI18N
              String lineNumber = ln == -1 ? "?" : "" + ln; // NOI18N
              makeCurrent(threadName, className, methodName, lineNumber, true, tr);
              operator.stopRequest();
            } catch (AbsentInformationException e) {
            }
          }
        });
    findSourceMER.enable();

    operator.resume();
    return;
  }