protected static DbgpBreakpointConfig createBreakpointConfig(IScriptBreakpoint breakpoint) throws CoreException { // Enabled boolean enabled = breakpoint.isEnabled() && getBreakpointManager().isEnabled(); DbgpBreakpointConfig config = new DbgpBreakpointConfig(enabled); // Hit value config.setHitValue(breakpoint.getHitValue()); // Hit condition config.setHitCondition(breakpoint.getHitCondition()); // Expression if (breakpoint.getExpressionState()) { config.setExpression(breakpoint.getExpression()); } if (breakpoint instanceof IScriptLineBreakpoint && !(breakpoint instanceof IScriptMethodEntryBreakpoint)) { IScriptLineBreakpoint lineBreakpoint = (IScriptLineBreakpoint) breakpoint; config.setLineNo(lineBreakpoint.getLineNumber()); } return config; }
private static int hasSpawnpointChanges(IMarkerDelta delta, IScriptBreakpoint breakpoint) { final String[] attrs = breakpoint.getUpdatableAttributes(); try { final IMarker marker = delta.getMarker(); for (int i = 0; i < attrs.length; ++i) { final String attr = attrs[i]; if (IBreakpoint.ENABLED.equals(attr) || IMarker.LINE_NUMBER.equals(attr)) { final Object oldValue = delta.getAttribute(attr); final Object newValue = marker.getAttribute(attr); if (oldValue == null) { if (newValue != null) { return IMarker.LINE_NUMBER.equals(attr) ? MAJOR_CHANGE : MINOR_CHANGE; } continue; } if (newValue == null) { return IMarker.LINE_NUMBER.equals(attr) ? MAJOR_CHANGE : MINOR_CHANGE; } if (!oldValue.equals(newValue)) { return IMarker.LINE_NUMBER.equals(attr) ? MAJOR_CHANGE : MINOR_CHANGE; } } } } catch (CoreException e) { DLTKDebugPlugin.log(e); } return NO_CHANGES; }
private int hasBreakpointChanges(IMarkerDelta delta, IScriptBreakpoint breakpoint) { final String[] attrs = breakpoint.getUpdatableAttributes(); try { final IMarker marker = delta.getMarker(); for (int i = 0; i < attrs.length; ++i) { final String attr = attrs[i]; final Object oldValue = delta.getAttribute(attr); final Object newValue = marker.getAttribute(attr); if (oldValue == null) { if (newValue != null) { return classifyBreakpointChange(delta, breakpoint, attr); } continue; } if (newValue == null) { return classifyBreakpointChange(delta, breakpoint, attr); } if (!oldValue.equals(newValue)) { return classifyBreakpointChange(delta, breakpoint, attr); } } } catch (CoreException e) { DLTKDebugPlugin.log(e); } return NO_CHANGES; }
protected static void removeBreakpoint(IDbgpSession session, IScriptBreakpoint breakpoint) throws DbgpException, CoreException { final IDbgpBreakpointCommands commands = session.getCoreCommands(); final String id = breakpoint.removeId(session); if (id != null) { commands.removeBreakpoint(id); } if (breakpoint instanceof IScriptMethodEntryBreakpoint) { IScriptMethodEntryBreakpoint entryBreakpoint = (IScriptMethodEntryBreakpoint) breakpoint; final String entryId = entryBreakpoint.getEntryBreakpointId(); if (entryId != null) { commands.removeBreakpoint(entryId); } final String exitId = entryBreakpoint.getExitBreakpointId(); if (exitId != null) { commands.removeBreakpoint(exitId); } } }
protected void changeBreakpoint(final IDbgpSession session, IScriptBreakpoint breakpoint) throws DbgpException, CoreException { if (!target.supportsBreakpoint(breakpoint)) return; final IDbgpBreakpointCommands commands = session.getCoreCommands(); URI bpUri = null; // map the outgoing uri if we're a line breakpoint if (breakpoint instanceof IScriptLineBreakpoint) { IScriptLineBreakpoint bp = (IScriptLineBreakpoint) breakpoint; bpUri = bpPathMapper.map(bp.getResourceURI()); } if (breakpoint instanceof IScriptMethodEntryBreakpoint) { DbgpBreakpointConfig config = createBreakpointConfig(breakpoint); IScriptMethodEntryBreakpoint entryBreakpoint = (IScriptMethodEntryBreakpoint) breakpoint; String entryId = entryBreakpoint.getEntryBreakpointId(); if (entryBreakpoint.breakOnEntry()) { if (entryId == null) { // Create entry breakpoint entryId = commands.setCallBreakpoint(bpUri, entryBreakpoint.getMethodName(), config); entryBreakpoint.setEntryBreakpointId(entryId); } else { // Update entry breakpoint commands.updateBreakpoint(entryId, config); } } else { if (entryId != null) { // Remove existing entry breakpoint commands.removeBreakpoint(entryId); entryBreakpoint.setEntryBreakpointId(null); } } String exitId = entryBreakpoint.getExitBreakpointId(); if (entryBreakpoint.breakOnExit()) { if (exitId == null) { // Create exit breakpoint exitId = commands.setReturnBreakpoint(bpUri, entryBreakpoint.getMethodName(), config); entryBreakpoint.setExitBreakpointId(exitId); } else { // Update exit breakpoint commands.updateBreakpoint(exitId, config); } } else { if (exitId != null) { // Remove exit breakpoint commands.removeBreakpoint(exitId); entryBreakpoint.setExitBreakpointId(null); } } } else { // All other breakpoints final String id = breakpoint.getId(session); if (id != null) { final DbgpBreakpointConfig config = createBreakpointConfig(breakpoint); if (breakpoint instanceof IScriptWatchpoint) { config.setExpression(makeWatchpointExpression((IScriptWatchpoint) breakpoint)); } commands.updateBreakpoint(id, config); } } }
// Adding, removing, updating protected void addBreakpoint(final IDbgpSession session, IScriptBreakpoint breakpoint) throws CoreException, DbgpException { if (!target.supportsBreakpoint(breakpoint)) return; final IDbgpCoreCommands commands = session.getCoreCommands(); DbgpBreakpointConfig config = createBreakpointConfig(breakpoint); String id = null; URI bpUri = null; // map the outgoing uri if we're a line breakpoint if (breakpoint instanceof IScriptLineBreakpoint) { IScriptLineBreakpoint bp = (IScriptLineBreakpoint) breakpoint; bpUri = bpPathMapper.map(bp.getResourceURI()); } // Type specific if (breakpoint instanceof IScriptWatchpoint) { IScriptWatchpoint watchpoint = (IScriptWatchpoint) breakpoint; config.setExpression(makeWatchpointExpression(watchpoint)); config.setLineNo(watchpoint.getLineNumber()); if (bpLineMapper != null) { bpLineMapper.toDebuggerBreakpoint(bpUri, config.getLineNo(), config); } id = commands.setWatchBreakpoint(bpUri, config.getLineNo(), config); } else if (breakpoint instanceof IScriptMethodEntryBreakpoint) { IScriptMethodEntryBreakpoint entryBreakpoint = (IScriptMethodEntryBreakpoint) breakpoint; if (entryBreakpoint.breakOnExit()) { final String exitId = commands.setReturnBreakpoint(bpUri, entryBreakpoint.getMethodName(), config); entryBreakpoint.setExitBreakpointId(exitId); } if (entryBreakpoint.breakOnEntry()) { final String entryId = commands.setCallBreakpoint(bpUri, entryBreakpoint.getMethodName(), config); entryBreakpoint.setEntryBreakpointId(entryId); } } else if (breakpoint instanceof IScriptLineBreakpoint) { IScriptLineBreakpoint lineBreakpoint = (IScriptLineBreakpoint) breakpoint; config.setLineNo(lineBreakpoint.getLineNumber()); if (bpLineMapper != null) { bpLineMapper.toDebuggerBreakpoint(bpUri, config.getLineNo(), config); } if (ScriptBreakpointUtils.isConditional(lineBreakpoint)) { id = commands.setConditionalBreakpoint(bpUri, config.getLineNo(), config); } else { id = commands.setLineBreakpoint(bpUri, config.getLineNo(), config); } } else if (breakpoint instanceof IScriptExceptionBreakpoint) { IScriptExceptionBreakpoint lineBreakpoint = (IScriptExceptionBreakpoint) breakpoint; id = commands.setExceptionBreakpoint(lineBreakpoint.getTypeName(), config); } // Identifier breakpoint.setId(session, id); }