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; }
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); }