예제 #1
0
 // INewDbgpServerListener
 public void clientConnected(IDbgpSession session) {
   final IDbgpSessionInfo info = session.getInfo();
   if (info != null) {
     final IDbgpThreadAcceptor acceptor = (IDbgpThreadAcceptor) acceptors.get(info.getIdeKey());
     if (acceptor != null) {
       acceptor.acceptDbgpThread(session, new NullProgressMonitor());
     } else {
       session.requestTermination();
     }
   }
 }
 private void removeBreakpoint() {
   try {
     final IDbgpSession[] sessions = manager.getSessions();
     for (int i = 0; i < sessions.length; ++i) {
       final IDbgpSession session = sessions[i];
       final String id = ids.remove(session);
       if (id != null) {
         session.getCoreCommands().removeBreakpoint(id);
       }
     }
   } catch (DbgpException e) {
     DLTKDebugPlugin.log(e);
   }
 }
 private static void changeSpawnpoint(final IDbgpSession session, IScriptSpawnpoint spawnpoint)
     throws DbgpException, CoreException {
   final IDbgpSpawnpointCommands commands =
       (IDbgpSpawnpointCommands) session.get(IDbgpSpawnpointCommands.class);
   if (commands != null) {
     final String id = spawnpoint.getId(session);
     if (id != null) {
       commands.updateSpawnpoint(id, spawnpoint.isEnabled());
     }
   }
 }
 private synchronized boolean addSession(IDbgpSession session) {
   for (int i = 0; i < sessions.length; ++i) {
     if (session.equals(sessions[i])) {
       return false;
     }
   }
   final IDbgpSession[] temp = new IDbgpSession[sessions.length + 1];
   System.arraycopy(sessions, 0, temp, 0, sessions.length);
   temp[sessions.length] = session;
   sessions = temp;
   return true;
 }
 protected void removeSpawnpoint(final IDbgpSession session, IScriptSpawnpoint spawnpoint)
     throws DbgpException, CoreException {
   final IDbgpSpawnpointCommands commands =
       (IDbgpSpawnpointCommands) session.get(IDbgpSpawnpointCommands.class);
   if (commands != null) {
     final String id = spawnpoint.getId(session);
     if (id != null) {
       commands.removeSpawnpoint(id);
       spawnpoint.setId(session, null);
     }
   }
 }
 private void addSpawnpoint(final IDbgpSession session, IScriptSpawnpoint spawnpoint)
     throws DbgpException, CoreException {
   if (!target.supportsBreakpoint(spawnpoint)) return;
   final IDbgpSpawnpointCommands commands =
       (IDbgpSpawnpointCommands) session.get(IDbgpSpawnpointCommands.class);
   final IDbgpSpawnpoint p =
       commands.setSpawnpoint(
           bpPathMapper.map(spawnpoint.getResourceURI()),
           spawnpoint.getLineNumber(),
           spawnpoint.isEnabled());
   if (p != null) {
     spawnpoint.setId(session, p.getId());
   }
 }
 synchronized boolean removeSession(IDbgpSession session) {
   for (int i = 0; i < sessions.length; ++i) {
     if (session.equals(sessions[i])) {
       if (sessions.length == 1) {
         sessions = NO_SESSIONS;
       } else {
         final IDbgpSession[] temp = new IDbgpSession[sessions.length - 1];
         if (i > 0) {
           System.arraycopy(sessions, 0, temp, 0, i);
         }
         ++i;
         if (i < sessions.length) {
           System.arraycopy(sessions, i, temp, i - 1, sessions.length - i);
         }
         sessions = temp;
       }
       return true;
     }
   }
   return false;
 }
  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);
      }
    }
  }
예제 #10
0
  // 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);
  }