public String getEventMessage(LocatableEvent event) {
    final Location location = event.location();
    final String locationQName = location.declaringType().name() + "." + location.method().name();
    String locationFileName = "";
    try {
      locationFileName = location.sourceName();
    } catch (AbsentInformationException e) {
      locationFileName = "";
    }
    final int locationLine = location.lineNumber();

    if (event instanceof MethodEntryEvent) {
      MethodEntryEvent entryEvent = (MethodEntryEvent) event;
      final Method method = entryEvent.method();
      return DebuggerBundle.message(
          "status.method.entry.breakpoint.reached",
          method.declaringType().name() + "." + method.name() + "()",
          locationQName,
          locationFileName,
          locationLine);
    }

    if (event instanceof MethodExitEvent) {
      MethodExitEvent exitEvent = (MethodExitEvent) event;
      final Method method = exitEvent.method();
      return DebuggerBundle.message(
          "status.method.exit.breakpoint.reached",
          method.declaringType().name() + "." + method.name() + "()",
          locationQName,
          locationFileName,
          locationLine);
    }
    return "";
  }
Exemplo n.º 2
0
 private void commandMethods(StringTokenizer t) throws NoSessionException {
   if (!t.hasMoreTokens()) {
     env.error("No class specified.");
     return;
   }
   String idClass = t.nextToken();
   ReferenceType cls = findClass(idClass);
   if (cls != null) {
     List<Method> methods = cls.allMethods();
     OutputSink out = env.getOutputSink();
     for (int i = 0; i < methods.size(); i++) {
       Method method = methods.get(i);
       out.print(method.declaringType().name() + " " + method.name() + "(");
       Iterator<String> it = method.argumentTypeNames().iterator();
       if (it.hasNext()) {
         while (true) {
           out.print(it.next());
           if (!it.hasNext()) {
             break;
           }
           out.print(", ");
         }
       }
       out.println(")");
     }
     out.show();
   } else {
     // ### Should validate class name syntax.
     env.failure("\"" + idClass + "\" is not a valid id or class name.");
   }
 }
Exemplo n.º 3
0
 protected boolean handleMethodEvent(
     LocatableEvent event, Method method, JDXDebugTarget target, JDXThread thread) {
   try {
     if (isNativeOnly()) {
       if (!method.isNative()) {
         return true;
       }
     }
     if (getMethodName() != null) {
       if (!method.name().equals(getMethodName())) {
         return true;
       }
     }
     if (getMethodSignature() != null) {
       if (!method.signature().equals(getMethodSignature())) {
         return true;
       }
     }
     if (fPattern != null) {
       if (!fPattern.matcher(method.declaringType().name()).find()) {
         return true;
       }
     }
     Integer count = (Integer) event.request().getProperty(HIT_COUNT);
     if (count != null && handleHitCount(event, count)) {
       return true;
     }
     return !suspendForEvent(event, thread); // Resume if suspend fails
   } catch (CoreException e) {
     Plugin.log(e);
   }
   return true;
 }
Exemplo n.º 4
0
    @Override
    public Component getListCellRendererComponent(
        JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

      // ### We should indicate the current thread independently of the
      // ### selection, e.g., with an icon, because the user may change
      // ### the selection graphically without affecting the current
      // ### thread.

      super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
      if (value == null) {
        this.setText("<unavailable>");
      } else {
        StackFrame frame = (StackFrame) value;
        Location loc = frame.location();
        Method meth = loc.method();
        String methName = meth.declaringType().name() + '.' + meth.name();
        String position = "";
        if (meth.isNative()) {
          position = " (native method)";
        } else if (loc.lineNumber() != -1) {
          position = ":" + loc.lineNumber();
        } else {
          long pc = loc.codeIndex();
          if (pc != -1) {
            position = ", pc = " + pc;
          }
        }
        // Indices are presented to the user starting from 1, not 0.
        this.setText("[" + (index + 1) + "] " + methName + position);
      }
      return this;
    }
Exemplo n.º 5
0
 private void dumpStack(ThreadReference thread, boolean showPC) {
   // ### Check for these.
   // env.failure("Thread no longer exists.");
   // env.failure("Target VM must be in interrupted state.");
   // env.failure("Current thread isn't suspended.");
   // ### Should handle extremely long stack traces sensibly for user.
   List<StackFrame> stack = null;
   try {
     stack = thread.frames();
   } catch (IncompatibleThreadStateException e) {
     env.failure("Thread is not suspended.");
   }
   // ### Fix this!
   // ### Previously mishandled cases where thread was not current.
   // ### Now, prints all of the stack regardless of current frame.
   int frameIndex = 0;
   // int frameIndex = context.getCurrentFrameIndex();
   if (stack == null) {
     env.failure("Thread is not running (no stack).");
   } else {
     OutputSink out = env.getOutputSink();
     int nFrames = stack.size();
     for (int i = frameIndex; i < nFrames; i++) {
       StackFrame frame = stack.get(i);
       Location loc = frame.location();
       Method meth = loc.method();
       out.print("  [" + (i + 1) + "] ");
       out.print(meth.declaringType().name());
       out.print('.');
       out.print(meth.name());
       out.print(" (");
       if (meth.isNative()) {
         out.print("native method");
       } else if (loc.lineNumber() != -1) {
         try {
           out.print(loc.sourceName());
         } catch (AbsentInformationException e) {
           out.print("<unknown>");
         }
         out.print(':');
         out.print(loc.lineNumber());
       }
       out.print(')');
       if (showPC) {
         long pc = loc.codeIndex();
         if (pc != -1) {
           out.print(", pc = " + pc);
         }
       }
       out.println();
     }
     out.show();
   }
 }
Exemplo n.º 6
0
  public Method concreteMethodByName(String name, String signature) {
    Method method = null;
    for (Method candidate : visibleMethods()) {
      if (candidate.name().equals(name)
          && candidate.signature().equals(signature)
          && !candidate.isAbstract()) {

        method = candidate;
        break;
      }
    }
    return method;
  }
Exemplo n.º 7
0
 @Override
 public int compare(Method m1, Method m2) {
   return LambdaMethodFilter.getLambdaOrdinal(m1.name())
       - LambdaMethodFilter.getLambdaOrdinal(m2.name());
 }
Exemplo n.º 8
0
 public static String methodName(final Method m) {
   return methodName(signatureToName(m.declaringType().signature()), m.name(), m.signature());
 }
 public boolean matchesEvent(final LocatableEvent event) {
   final Method method = event.location().method();
   return method != null && myMethodName.equals(method.name());
 }