void compareAllVariables(String className, String methodName) throws Exception { println("compareAllVariables for method: " + className + "." + methodName); Method method = getMethod(className, methodName); List localVars; try { localVars = method.variables(); println("\n Success: got a list of all method variables: " + methodName); } catch (com.sun.jdi.AbsentInformationException ex) { failure("\n AbsentInformationException has been thrown"); return; } // We consider N*N combinations for set of N variables int index1 = 0; for (Iterator it1 = localVars.iterator(); it1.hasNext(); index1++) { LocalVariable lv1 = (LocalVariable) it1.next(); int index2 = 0; for (Iterator it2 = localVars.iterator(); it2.hasNext(); index2++) { LocalVariable lv2 = (LocalVariable) it2.next(); println("\n Two variables:"); printVariable(lv1, index1); printVariable(lv2, index2); println(""); if (index1 == index2) { compareTwoEqualVars(lv1, lv2); } else { compareTwoDifferentVars(lv1, lv2); } } } println(""); return; }
private static AttachingConnector getAttachingConnectorFor(String transport) { List acs = Bootstrap.virtualMachineManager().attachingConnectors(); AttachingConnector ac; int i, k = acs.size(); for (i = 0; i < k; i++) if ((ac = (AttachingConnector) acs.get(i)).transport().name().equals(transport)) return ac; return null; }
EventRequest request(int eventCmd, int requestId) { List rl = requestList(eventCmd); for (int i = rl.size() - 1; i >= 0; i--) { EventRequestImpl er = (EventRequestImpl) rl.get(i); if (er.id == requestId) { return er; } } return null; }
protected void runTests() throws Exception { /* * Get to the top of main() * to determine targetClass and mainThread */ BreakpointEvent bpe = startToMain("GetLocalVariables2Targ"); targetClass = bpe.location().declaringType(); mainThread = bpe.thread(); EventRequestManager erm = vm().eventRequestManager(); bpe = resumeTo("GetLocalVariables2Targ", "bar", "(I)Z"); /* * Inspect the stack frame for main(), not bar()... */ StackFrame frame = bpe.thread().frame(1); List localVars = frame.visibleVariables(); System.out.println(" Visible variables at this point are: "); for (Iterator it = localVars.iterator(); it.hasNext(); ) { LocalVariable lv = (LocalVariable) it.next(); System.out.print(lv.name()); System.out.print(" typeName: "); System.out.print(lv.typeName()); System.out.print(" signature: "); System.out.print(lv.type().signature()); System.out.print(" primitive type: "); System.out.println(lv.type().name()); if ("command".equals(lv.name())) { failure("Failure: LocalVariable \"command\" should not be visible at this point."); if (lv.isVisible(frame)) { System.out.println("Failure: \"command.isvisible(frame)\" returned true."); } } } /* * resume the target listening for events */ listenUntilVMDisconnect(); /* * deal with results of test * if anything has called failure("foo") testFailed will be true */ if (!testFailed) { println("GetLocalVariables2Test: passed"); } else { throw new Exception("GetLocalVariables2Test: failed"); } }
public void enableBreakpoints(final DebugProcessImpl debugProcess) { final List<Breakpoint> breakpoints = getBreakpoints(); if (!breakpoints.isEmpty()) { for (Breakpoint breakpoint : breakpoints) { breakpoint.markVerified(false); // clean cached state breakpoint.createRequest(debugProcess); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { updateBreakpointsUI(); } }); } }
@NotNull public synchronized List<Breakpoint> getBreakpoints() { if (myBreakpointsListForIteration == null) { myBreakpointsListForIteration = new ArrayList<Breakpoint>(myBreakpoints.size()); XBreakpoint<?>[] xBreakpoints = ApplicationManager.getApplication() .runReadAction( new Computable<XBreakpoint<?>[]>() { public XBreakpoint<?>[] compute() { return getXBreakpointManager().getAllBreakpoints(); } }); for (XBreakpoint<?> xBreakpoint : xBreakpoints) { if (isJavaType(xBreakpoint)) { Breakpoint breakpoint = myBreakpoints.get(xBreakpoint); if (breakpoint == null) { breakpoint = createJavaBreakpoint(xBreakpoint); myBreakpoints.put(xBreakpoint, breakpoint); } } } myBreakpointsListForIteration.addAll(myBreakpoints.values()); } return myBreakpointsListForIteration; }
// interaction with RequestManagerImpl public void disableBreakpoints(@NotNull final DebugProcessImpl debugProcess) { final List<Breakpoint> breakpoints = getBreakpoints(); if (!breakpoints.isEmpty()) { final RequestManagerImpl requestManager = debugProcess.getRequestsManager(); for (Breakpoint breakpoint : breakpoints) { breakpoint.markVerified(requestManager.isVerified(breakpoint)); requestManager.deleteRequest(breakpoint); } SwingUtilities.invokeLater( new Runnable() { @Override public void run() { updateBreakpointsUI(); } }); } }
@NotNull public List<BreakpointWithHighlighter> findBreakpoints( @NotNull Document document, @NotNull TextRange textRange) { ApplicationManager.getApplication().assertIsDispatchThread(); List<BreakpointWithHighlighter> result = new ArrayList<BreakpointWithHighlighter>(); int startLine = document.getLineNumber(textRange.getStartOffset()); int endLine = document.getLineNumber(textRange.getEndOffset()) + 1; TextRange lineRange = new TextRange(startLine, endLine); for (final Breakpoint breakpoint : getBreakpoints()) { if (breakpoint instanceof BreakpointWithHighlighter && lineRange.contains(((BreakpointWithHighlighter) breakpoint).getLineIndex())) { result.add((BreakpointWithHighlighter) breakpoint); } } return result; }
StepRequestImpl(ThreadReference thread, int size, int depth) { this.thread = (ThreadReferenceImpl) thread; this.size = size; this.depth = depth; /* * Make sure this isn't a duplicate */ List requests = stepRequests(); Iterator iter = requests.iterator(); while (iter.hasNext()) { StepRequest request = (StepRequest) iter.next(); if ((request != this) && request.isEnabled() && request.thread().equals(thread)) { throw new DuplicateRequestException("Only one step request allowed per thread"); } } }
/** ******** test assist ********* */ Method getMethod(String className, String methodName) { List refs = vm().classesByName(className); if (refs.size() != 1) { failure("Test failure: " + refs.size() + " ReferenceTypes named: " + className); return null; } ReferenceType refType = (ReferenceType) refs.get(0); List meths = refType.methodsByName(methodName); if (meths.size() != 1) { failure("Test failure: " + meths.size() + " methods named: " + methodName); return null; } return (Method) meths.get(0); }
public void readExternal(@NotNull final Element parentNode) { // save old breakpoints for (Element element : parentNode.getChildren()) { myOriginalBreakpointsNodes.add(element.clone()); } if (myProject.isOpen()) { doRead(parentNode); } else { myStartupManager.registerPostStartupActivity( new Runnable() { @Override public void run() { doRead(parentNode); } }); } }