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; }
@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; }
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(); } }
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; }
public boolean isVisible(StackFrame frame) { validateMirror(frame); Method frameMethod = frame.location().method(); if (!frameMethod.equals(method)) { throw new IllegalArgumentException("frame method different than variable's method"); } // this is here to cover the possibility that we will // allow LocalVariables for native methods. If we do // so we will have to re-examinine this. if (frameMethod.isNative()) { return false; } return ((scopeStart.compareTo(frame.location()) <= 0) && (scopeEnd.compareTo(frame.location()) >= 0)); }