/** * Call-back from a breakpoint that has been hit * * @param breakpoint * @param vote * @return if the thread should suspended */ public boolean suspendForBreakpoint(JSDIBreakpoint breakpoint, boolean vote) { addBreakpoint(breakpoint); try { String condition = breakpoint.getCondition(); if (condition != null) { // evaluate it // TODO This method has the negative effect that the frames will be loaded // for the underlying thread to do the evaluation // Ideally we should have an evaluation engine like JDT List frames = this.thread.frames(); if (frames.isEmpty()) { return false; } Value value = ((StackFrameReference) frames.get(0)).evaluate(condition); if (breakpoint.isConditionSuspendOnTrue()) { return suspendForValue(value); } else { return !suspendForValue(value); } } } catch (CoreException ce) { // TODO log this } return true; }
/** @return the status text for the thread */ private String statusText() { if (thread.status() == ThreadReference.THREAD_STATUS_ZOMBIE) { return ZOMBIE_STATUS; } else if (state == SUSPENDED) { if (breakpoints.size() > 0) { try { JSDIBreakpoint breakpoint = (JSDIBreakpoint) breakpoints.get(0); if (breakpoint instanceof JSDIScriptLoadBreakpoint) { return NLS.bind( ModelMessages.JSDIThread_suspended_loading_script, breakpoint.getScriptPath()); } } catch (CoreException ce) { // TODO log this ce.printStackTrace(); } } return SUSPENDED_STATUS; } return RUNNING_STATUS; }
/** * Call-back from {@link JSDIBreakpoint#eventSetComplete(Event, JSDIDebugTarget, boolean, * EventSet)} to handle suspending / cleanup * * @param breakpoint * @param suspend if the thread should suspend * @param eventSet */ public void suspendForBreakpointComplete( JSDIBreakpoint breakpoint, boolean suspend, EventSet eventSet) { // TODO clean up after voting - when added - and handle state / policy changes if (suspend) { try { if (breakpoint.getSuspendPolicy() == JSDIBreakpoint.SUSPEND_THREAD) { markSuspended(); } else { getDebugTarget().suspend(); } fireSuspendEvent(DebugEvent.BREAKPOINT); } catch (CoreException ce) { // TODO log this and do not suspend } } }