private void processThreadSuspended(String payload) { Object[] threadNstack; try { threadNstack = XMLUtils.XMLToStack(this, payload); } catch (CoreException e) { PydevDebugPlugin.errorDialog("Error reading ThreadSuspended", e); return; } PyThread t = (PyThread) threadNstack[0]; int reason = DebugEvent.UNSPECIFIED; String stopReason = (String) threadNstack[1]; if (stopReason != null) { int stopReason_i = Integer.parseInt(stopReason); if (stopReason_i == AbstractDebuggerCommand.CMD_STEP_OVER || stopReason_i == AbstractDebuggerCommand.CMD_STEP_INTO || stopReason_i == AbstractDebuggerCommand.CMD_STEP_RETURN || stopReason_i == AbstractDebuggerCommand.CMD_RUN_TO_LINE || stopReason_i == AbstractDebuggerCommand.CMD_SET_NEXT_STATEMENT) { reason = DebugEvent.STEP_END; } else if (stopReason_i == AbstractDebuggerCommand.CMD_THREAD_SUSPEND) { reason = DebugEvent.CLIENT_REQUEST; } else if (stopReason_i == AbstractDebuggerCommand.CMD_SET_BREAK) { reason = DebugEvent.BREAKPOINT; } else { PydevDebugPlugin.log(IStatus.ERROR, "Unexpected reason for suspension", null); reason = DebugEvent.UNSPECIFIED; } } if (t != null) { modificationChecker.onlyLeaveThreads((PyThread[]) this.threads); IStackFrame stackFrame[] = (IStackFrame[]) threadNstack[2]; t.setSuspended(true, stackFrame); fireEvent(new DebugEvent(t, DebugEvent.SUSPEND, reason)); } }
/** * Adds the breakpoints associated with a container. * * @param container the container we're interested in (usually workspace root) */ private void addBreakpointsFor(IContainer container) { try { IMarker[] markers = container.findMarkers(PyBreakpoint.PY_BREAK_MARKER, true, IResource.DEPTH_INFINITE); IMarker[] condMarkers = container.findMarkers( PyBreakpoint.PY_CONDITIONAL_BREAK_MARKER, true, IResource.DEPTH_INFINITE); IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager(); for (IMarker marker : markers) { PyBreakpoint brk = (PyBreakpoint) breakpointManager.getBreakpoint(marker); breakpointAdded(brk); } for (IMarker marker : condMarkers) { PyBreakpoint brk = (PyBreakpoint) breakpointManager.getBreakpoint(marker); breakpointAdded(brk); } } catch (Throwable t) { PydevDebugPlugin.errorDialog("Error setting breakpoints", t); } }
/** Add it to the list of threads */ private void processThreadCreated(String payload) { PyThread[] newThreads; try { newThreads = XMLUtils.ThreadsFromXML(this, payload); } catch (CoreException e) { PydevDebugPlugin.errorDialog("Error in processThreadCreated", e); return; } // Hide Pydevd threads if requested if (PydevDebugPlugin.getDefault() .getPreferenceStore() .getBoolean(PydevDebugPreferencesInitializer.HIDE_PYDEVD_THREADS)) { int removeThisMany = 0; for (int i = 0; i < newThreads.length; i++) { if (((PyThread) newThreads[i]).isPydevThread()) { removeThisMany++; } } if (removeThisMany > 0) { int newSize = newThreads.length - removeThisMany; if (newSize == 0) { // no threads to add return; } else { PyThread[] newnewThreads = new PyThread[newSize]; int i = 0; for (PyThread newThread : newThreads) { if (!((PyThread) newThread).isPydevThread()) { newnewThreads[i] = newThread; i += 1; } } newThreads = newnewThreads; } } } // add threads to the thread list, and fire event if (threads == null) { threads = newThreads; } else { PyThread[] combined = new PyThread[threads.length + newThreads.length]; int i = 0; for (i = 0; i < threads.length; i++) { combined[i] = threads[i]; } for (int j = 0; j < newThreads.length; i++, j++) { combined[i] = newThreads[j]; } threads = combined; } // Now notify debugger that new threads were added for (int i = 0; i < newThreads.length; i++) { fireEvent(new DebugEvent(newThreads[i], DebugEvent.CREATE)); } }