|
From: <mba...@us...> - 2007-03-31 18:00:56
|
Revision: 2251
http://svn.sourceforge.net/rubyeclipse/?rev=2251&view=rev
Author: mbarchfe
Date: 2007-03-31 11:00:53 -0700 (Sat, 31 Mar 2007)
Log Message:
-----------
switched to rdebug-ide; pull thread state
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/AbstractDebuggerConnection.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/ClassicDebuggerConnection.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/RubyDebugConnection.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/AbstractReadStrategy.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/SingleReaderStrategy.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerProxyTest.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_Single.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
Added Paths:
-----------
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TC_RubyDebugTarget.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -13,6 +13,7 @@
import org.rubypeople.rdt.internal.debug.core.commands.GenericCommand;
import org.rubypeople.rdt.internal.debug.core.commands.RubyDebugConnection;
import org.rubypeople.rdt.internal.debug.core.model.IRubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
import org.rubypeople.rdt.internal.debug.core.model.RubyThread;
@@ -33,12 +34,15 @@
private IRubyDebugTarget debugTarget;
private RubyLoop rubyLoop;
private ICommandFactory commandFactory;
+ private Thread threadUpdater;
+ private Thread errorReader;
+ private boolean isLoopFinished ;
- public RubyDebuggerProxy(IRubyDebugTarget debugTarget, String rubyFileDirectory, boolean isRubyDebug) {
+ public RubyDebuggerProxy(IRubyDebugTarget debugTarget, boolean isRubyDebug) {
this.debugTarget = debugTarget;
debugTarget.setRubyDebuggerProxy(this);
commandFactory = isRubyDebug ? new RubyDebugCommandFactory() : new ClassicDebuggerCommandFactory();
- debuggerConnection = isRubyDebug ? new RubyDebugConnection(rubyFileDirectory, debugTarget.getPort()) : new ClassicDebuggerConnection(debugTarget.getPort());
+ debuggerConnection = isRubyDebug ? new RubyDebugConnection(debugTarget.getPort()) : new ClassicDebuggerConnection(debugTarget.getPort());
}
public boolean checkConnection() {
@@ -46,7 +50,7 @@
}
public void start() throws RubyProcessingException, IOException {
-
+ isLoopFinished = false ;
debuggerConnection.connect();
this.setBreakPoints();
this.startRubyLoop();
@@ -132,15 +136,48 @@
Runnable runnable = new Runnable() {
public void run() {
try {
- while (true) {
+ RdtDebugCorePlugin.debug("Command Connection error handler started.") ;
+ while (debuggerConnection.getCommandReadStrategy().isConnected()) {
+ // The read strategy resumes read() after the connection to the debugger
+ // has been dropped
new ErrorReader(debuggerConnection.getCommandReadStrategy()).read();
}
} catch (Exception e) {
RdtDebugCorePlugin.log(e);
+ } finally {
+ RdtDebugCorePlugin.debug("Command Connection error handler finished.") ;
}
};
};
- new Thread(runnable).start();
+ errorReader = new Thread(runnable, "Error Reader");
+ errorReader.start();
+ // TODO: Check if it would not be better if the ruby part created the threadinfos
+ // only after a change to the thread status has occurred
+ Runnable threadListener = new Runnable() {
+ public void run() {
+ try {
+ RdtDebugCorePlugin.debug("Thread updater started.") ;
+ Thread.sleep(2000) ;
+ GenericCommand cmd = null ;
+ while (cmd == null || (cmd != null && cmd.getReadStrategy().isConnected())) {
+ if (!getDebugTarget().isSuspended()) {
+ String command = commandFactory.createReadThreads() ;
+ cmd = new GenericCommand(command, true /* isControl */) ;
+ cmd.execute(debuggerConnection);
+ ThreadInfo[] threadInfos = new ThreadInfoReader(cmd.getReadStrategy()).readThreads() ;
+ ((RubyDebugTarget)getDebugTarget()).updateThreads(threadInfos) ;
+ }
+ Thread.sleep(2000) ;
+ }
+ } catch (Exception e) {
+ RdtDebugCorePlugin.log(e);
+ } finally {
+ RdtDebugCorePlugin.debug("Thread updater finished.") ;
+ }
+ };
+ };
+ threadUpdater = new Thread(threadListener, "Ruby Thread Updater");
+ threadUpdater.start();
}
public void resume(RubyThread thread) {
@@ -247,7 +284,8 @@
public ThreadInfo[] readThreads() {
try {
- this.println(commandFactory.createReadThreads());
+ String command = commandFactory.createReadThreads() ;
+ new GenericCommand(command, true /* isControl */).execute(debuggerConnection);
return new ThreadInfoReader(getMultiReaderStrategy()).readThreads();
} catch (Exception e) {
RdtDebugCorePlugin.log(e);
@@ -284,8 +322,6 @@
try {
System.setProperty(DEBUGGER_ACTIVE_KEY, "true");
- // TODO Update threads?
- //getDebugTarget().updateThreads();
RdtDebugCorePlugin.debug("Waiting for breakpoints.");
while (true) {
final SuspensionPoint hit = new SuspensionReader(getMultiReaderStrategy()).readSuspension();
@@ -319,4 +355,5 @@
}
+
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/AbstractDebuggerConnection.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/AbstractDebuggerConnection.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/AbstractDebuggerConnection.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -36,7 +36,8 @@
*/
public abstract SuspensionReader start() throws DebuggerNotFoundException, IOException;
-
+ public abstract boolean isStarted() ;
+
/*
* always call via Command.execute
*/
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/ClassicDebuggerConnection.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/ClassicDebuggerConnection.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/ClassicDebuggerConnection.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -7,6 +7,8 @@
public class ClassicDebuggerConnection extends AbstractDebuggerConnection {
+ private boolean isStarted;
+
public ClassicDebuggerConnection(int port) {
super(port);
}
@@ -20,7 +22,13 @@
public SuspensionReader start() throws DebuggerNotFoundException, IOException {
StepCommand stepCommand = new StepCommand("cont");
stepCommand.execute(this) ;
+ isStarted = true ;
return stepCommand.getSuspensionReader() ;
}
+ @Override
+ public boolean isStarted() {
+ return isStarted;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/RubyDebugConnection.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/RubyDebugConnection.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/commands/RubyDebugConnection.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -1,110 +1,45 @@
package org.rubypeople.rdt.internal.debug.core.commands;
-import java.io.File;
import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.Socket;
import org.rubypeople.rdt.internal.debug.core.DebuggerNotFoundException;
-import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
-import org.rubypeople.rdt.internal.debug.core.model.RubyProcessingException;
import org.rubypeople.rdt.internal.debug.core.parsing.AbstractReadStrategy;
-import org.rubypeople.rdt.internal.debug.core.parsing.MultiReaderStrategy;
import org.rubypeople.rdt.internal.debug.core.parsing.SuspensionReader;
-import org.xmlpull.v1.XmlPullParser;
public class RubyDebugConnection extends AbstractDebuggerConnection {
- private Socket controlSocket ;
- private MultiReaderStrategy controlReadStrategy;
- private PrintWriter controlWriter;
- private String rdebugExtensionPath ;
- public RubyDebugConnection(String rdebugExtensionPath, int port) {
+ private boolean isStarted;
+
+ public RubyDebugConnection(int port) {
super(port);
- this.rdebugExtensionPath = rdebugExtensionPath + File.separatorChar + "rdebugExtension.rb";
}
@Override
- public void connect() throws DebuggerNotFoundException, IOException{
- createControlConnection() ;
-
- String expression = "eval require '" + rdebugExtensionPath + "'";
- EvalCommand command = new EvalCommand(expression, true) ;
- command.execute(this) ;
- String evalResult = null;
- try {
- evalResult = command.getEvalReader().readEvalResult();
- } catch (RubyProcessingException e) {
- RdtDebugCorePlugin.log(e) ;
- }
- if (evalResult == null || !evalResult.equals("true")) {
- // TODO: go on ?
- throw new DebuggerNotFoundException("Could not add extension to ruby debug") ;
- }
- // set trace: show stack trace if evaluation fails
- new GenericCommand("set trace", true).execute(this) ;
+ public void connect() throws DebuggerNotFoundException, IOException {
+ createCommandConnection();
}
@Override
public SuspensionReader start() throws DebuggerNotFoundException, IOException {
- createCommandConnection() ;
- return new SuspensionReader(getCommandReadStrategy()) ;
+ AbstractReadStrategy strategy = sendControlCommand(new GenericCommand("start", true));
+ isStarted = true ;
+ return new SuspensionReader(strategy);
}
-
- @Override
- public AbstractReadStrategy sendCommand(AbstractCommand command) throws DebuggerNotFoundException, IOException {
- AbstractReadStrategy result = null ;
- if (command.isControl()) {
- result =sendControlCommand(command) ;
- } else {
- result = super.sendCommand(command);
- }
- return result ;
- }
-
+
private AbstractReadStrategy sendControlCommand(AbstractCommand command) throws IOException {
- if (!isControlPortConnected()) {
- throw new IllegalStateException(command + " could not be executed since control socket is not opened.") ;
- }
- RdtDebugCorePlugin.debug("Sending control command: " + command.getCommand()) ;
- getControlWriter().println(command.getCommand()) ;
- return getControlReadStrategy() ;
+ return sendCommand(command);
}
-
- private PrintWriter getControlWriter() throws IOException {
- if (controlWriter == null) {
- controlWriter = new PrintWriter(getControlSocket().getOutputStream(), true);
- }
- return controlWriter;
- }
-
- protected boolean isControlPortConnected() {
- return controlReadStrategy != null;
- }
-
- protected void createControlConnection() throws DebuggerNotFoundException, IOException {
- Socket socket = getControlSocket() ;
- XmlPullParser xpp = createXpp(socket) ;
- controlReadStrategy = new MultiReaderStrategy(xpp) ;
- }
-
- private Socket getControlSocket() throws IOException {
- if (controlSocket == null) {
- controlSocket = acquireSocket(getCommandPort() + 1) ;
- }
- return controlSocket ;
- }
- public MultiReaderStrategy getControlReadStrategy() {
- return controlReadStrategy;
- }
-
@Override
public void exit() throws IOException {
super.exit();
- GenericCommand command = new GenericCommand("exit", true) ;
- command.execute(this) ;
- controlSocket.close() ;
+ GenericCommand command = new GenericCommand("exit", true);
+ command.execute(this);
}
+ @Override
+ public boolean isStarted() {
+ return isStarted;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -4,7 +4,13 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import org.eclipse.core.internal.runtime.FindSupport;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
@@ -40,19 +46,21 @@
public RubyDebugTarget(ILaunch launch) {
this(launch, null);
}
-
+
public RubyDebugTarget(ILaunch launch, IProcess process) {
this(launch, process, DEFAULT_PORT);
}
-
+
public RubyDebugTarget(ILaunch launch, IProcess process, int port) {
this.launch = launch;
this.port = port;
this.process = process;
- this.threads = new RubyThread[0] ;
- this.isTerminated = false ;
- IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager();
- manager.addBreakpointListener(this);
+ this.threads = new RubyThread[0];
+ this.isTerminated = false;
+ if (DebugPlugin.getDefault() != null) { // null only expected in Unit test
+ IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
+ manager.addBreakpointListener(this);
+ }
addDebugParameter("$RemoteDebugPort=" + port);
}
@@ -61,29 +69,62 @@
}
public void updateThreads() {
- // preconditions:
- // 1) both threadInfos and updatedThreads are sorted by their id attribute
- // 2) once a thread has died its id is never reused for new threads again. Instead each new
- // thread gets an id which is the currently highest id + 1.
-
RdtDebugCorePlugin.debug("udpating threads");
ThreadInfo[] threadInfos = this.getRubyDebuggerProxy().readThreads();
- RubyThread[] updatedThreads = new RubyThread[threadInfos.length];
+ updateThreads(threadInfos);
+ }
+
+ public synchronized void updateThreads(ThreadInfo[] threadInfos) {
+ if (isSuspended()) {
+ return ;
+ }
+ DebugEvent[] events = updateThreadsInternal(threadInfos) ;
+ DebugPlugin.getDefault().fireDebugEventSet(events);
+ }
+
+ // only public for testing
+ public DebugEvent[] updateThreadsInternal(ThreadInfo[] threadInfos) {
+
+ // preconditions:
+ // 1) once a thread has died its id is never reused for new threads
+ // again. Instead each new
+ // thread gets an id which is the currently highest id + 1.
+ List<DebugEvent> events = new ArrayList<DebugEvent>() ;
+ RubyThread[] newThreads = new RubyThread[threadInfos.length] ;
+ Set<Integer> newIds = new TreeSet<Integer>() ;
+ boolean changed = false ;
int threadIndex = 0;
for (int i = 0; i < threadInfos.length; i++) {
- while (threadIndex < threads.length && threadInfos[i].getId() != threads[threadIndex].getId()) {
- // step over dead threads, which do not occur in threadInfos anymore
- threadIndex += 1;
- }
- if (threadIndex == threads.length) {
- updatedThreads[i] = new RubyThread(this, threadInfos[i].getId());
- DebugEvent ev = new DebugEvent(updatedThreads[i], DebugEvent.CREATE);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
+ ThreadInfo currentThreadInfo = threadInfos[i] ;
+ RubyThread existingThread = getThreadById(currentThreadInfo.getId()) ;
+
+ if (existingThread == null) {
+ newThreads[i] = new RubyThread(this, currentThreadInfo.getId(), currentThreadInfo.getStatus());
+ DebugEvent ev = new DebugEvent(newThreads[i], DebugEvent.CREATE);
+ events.add(ev) ;
} else {
- updatedThreads[i] = threads[threadIndex];
+ newThreads[i] =existingThread;
+ if (!existingThread.getStatus().equals(currentThreadInfo.getStatus())) {
+ existingThread.setStatus(currentThreadInfo.getStatus());
+ existingThread.updateName();
+ DebugEvent ev = new DebugEvent(newThreads[i], DebugEvent.CHANGE);
+ events.add(ev) ;
+ }
}
+ newIds.add(newThreads[i].getId()) ;
}
- threads = updatedThreads;
+ for (int i = 0; i < threads.length ; i++) {
+ if (!newIds.contains(threads[i].getId())) {
+ DebugEvent ev = new DebugEvent(threads[i], DebugEvent.TERMINATE);
+ events.add(ev) ;
+ }
+ }
+ threads = newThreads;
+ if (changed) {
+ DebugEvent ev1 = new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT);
+ events.add(ev1) ;
+ }
+ return events.toArray(new DebugEvent[] {}) ;
}
protected RubyThread getThreadById(int id) {
@@ -141,27 +182,27 @@
return isTerminated;
}
- public void terminate() {
+ public synchronized void terminate() {
if (isTerminated) {
- return ;
+ return;
}
try {
- this.getProcess().terminate() ;
- this.threads = new RubyThread[0] ;
+ this.getProcess().terminate();
+ this.threads = new RubyThread[0];
isTerminated = true;
- rubyDebuggerProxy.stop() ;
+ rubyDebuggerProxy.stop();
} catch (DebugException e) {
- RdtDebugCorePlugin.debug("Exception while terminating process.", e) ;
+ RdtDebugCorePlugin.debug("Exception while terminating process.", e);
}
-
+
// launch is one of the listeners
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)});
-
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { new DebugEvent(this, DebugEvent.TERMINATE) });
+
// delete the debugParameteFile if it could be created
if (debugParameterFile.exists()) {
- boolean deleted = debugParameterFile.delete() ;
+ boolean deleted = debugParameterFile.delete();
if (!deleted) {
- RdtDebugCorePlugin.debug("Could not delete debugParameteFile:" + debugParameterFile.toURI()) ;
+ RdtDebugCorePlugin.debug("Could not delete debugParameteFile:" + debugParameterFile.toURI());
}
}
}
@@ -175,46 +216,51 @@
}
public boolean isSuspended() {
- return false;
+ boolean isSuspended = false ;
+ for (int i = 0; i < getThreads().length; i++) {
+ if (getThreads()[i].isSuspended()) {
+ isSuspended = true ;
+ break ;
+ }
+ }
+ return isSuspended;
}
- public void resume() throws DebugException {
- }
+ public void resume() throws DebugException {}
- public void suspend() throws DebugException {
- }
+ public void suspend() throws DebugException {}
public void breakpointAdded(IBreakpoint breakpoint) {
if (isTerminated) {
- return ;
+ return;
}
- this.getRubyDebuggerProxy().addBreakpoint(breakpoint) ;
+ this.getRubyDebuggerProxy().addBreakpoint(breakpoint);
}
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta arg1) {
if (isTerminated) {
- return ;
- }
- this.getRubyDebuggerProxy().removeBreakpoint(breakpoint) ;
+ return;
+ }
+ this.getRubyDebuggerProxy().removeBreakpoint(breakpoint);
}
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta arg1) {
// is called e.g. after a line has been inserted before a breakpoint
// or the enablement status has changed
- // in the first case it is essential that the debugger has reloaded the file
+ // in the first case it is essential that the debugger has reloaded the
+ // file
// so that the breakpoint moving is in synch with the new file
if (isTerminated) {
- return ;
- }
- this.getRubyDebuggerProxy().updateBreakpoint(breakpoint, arg1) ;
+ return;
+ }
+ this.getRubyDebuggerProxy().updateBreakpoint(breakpoint, arg1);
}
public boolean canDisconnect() {
return false;
}
- public void disconnect() throws DebugException {
- }
+ public void disconnect() throws DebugException {}
public boolean isDisconnected() {
return false;
@@ -243,18 +289,18 @@
public void setRubyDebuggerProxy(RubyDebuggerProxy rubyDebuggerProxy) {
this.rubyDebuggerProxy = rubyDebuggerProxy;
}
-
+
public File getDebugParameterFile() {
if (debugParameterFile == null) {
try {
- debugParameterFile = File.createTempFile("classic-debug",".rb") ;
+ debugParameterFile = File.createTempFile("classic-debug", ".rb");
} catch (IOException e) {
- RdtDebugCorePlugin.log("Could not create debugParameterFile", e) ;
+ RdtDebugCorePlugin.log("Could not create debugParameterFile", e);
}
}
return debugParameterFile;
}
-
+
private boolean addDebugParameter(String line) {
PrintWriter writer = null;
try {
@@ -269,12 +315,12 @@
writer.close();
}
}
-
+
public int getPort() {
return port;
}
-
+
public boolean isUsingDefaultPort() {
- return getPort() == DEFAULT_PORT ;
+ return getPort() == DEFAULT_PORT;
}
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -21,11 +21,13 @@
private boolean isTerminated = false;
private boolean isStepping = false;
private String name;
+ private String status;
private int id;
- public RubyThread(IDebugTarget target, int id) {
+ public RubyThread(IDebugTarget target, int id, String status) {
this.target = target;
this.setId(id);
+ this.status = status ;
this.updateName();
}
@@ -99,7 +101,9 @@
}
public boolean canSuspend() {
- return !isSuspended;
+ // TODO: manually suspending a thread is not yet possible with ruby-debug
+ //return !isSuspended;
+ return false ;
}
public boolean isSuspended() {
@@ -229,6 +233,8 @@
this.name = "Ruby Thread - " + this.getId();
if (suspensionPoint != null) {
this.name += " (" + suspensionPoint + ")";
+ } else {
+ this.name += " (" + status + ")";
}
}
@@ -248,4 +254,12 @@
}
return super.getAdapter(adapterType);
}
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/AbstractReadStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/AbstractReadStrategy.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/AbstractReadStrategy.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -15,5 +15,7 @@
public abstract void readElement(XmlStreamReader streamReader) throws XmlPullParserException, IOException, XmlStreamReaderException ;
public abstract void readElement(XmlStreamReader streamReader, long maxWaitTime) throws XmlPullParserException, IOException, XmlStreamReaderException ;
+
+ public abstract boolean isConnected() ;
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -14,9 +14,12 @@
private Map<XmlStreamReader, Thread> threads;
private XmlStreamReader currentReader;
+ private boolean isConnected ;
+
public MultiReaderStrategy(XmlPullParser xpp) {
super(xpp);
+ isConnected = true ;
threads = new HashMap<XmlStreamReader, Thread>();
new Thread("xml reader") {
@@ -35,6 +38,7 @@
Thread.sleep(1000) ; // Avoid Commodfication Exceptions
} catch (InterruptedException e) {
}
+ isConnected = false;
releaseAllReaders();
}
@@ -93,6 +97,7 @@
}
private synchronized void findReaderForTag() throws XmlStreamReaderException {
+ System.out.println("There are no threads:" + threads.size()) ;
for (XmlStreamReader streamReader : threads.keySet()) {
if (streamReader.processStartElement(xpp)) {
currentReader = streamReader;
@@ -118,11 +123,14 @@
threads.put(streamReader, Thread.currentThread());
}
- public void readElement(XmlStreamReader streamReader) {
+ public void readElement(XmlStreamReader streamReader) throws IOException {
readElement(streamReader, Long.MAX_VALUE) ;
}
- public void readElement(XmlStreamReader streamReader, long maxWaitTime) {
+ public void readElement(XmlStreamReader streamReader, long maxWaitTime) throws IOException {
+ if (!isConnected) {
+ throw new IOException("Read loop has finished") ;
+ }
this.addReader(streamReader);
try {
RdtDebugCorePlugin.debug("Thread is waiting for input: " + Thread.currentThread());
@@ -133,4 +141,8 @@
}
}
+ public boolean isConnected() {
+ return isConnected;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/SingleReaderStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/SingleReaderStrategy.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/SingleReaderStrategy.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -40,4 +40,9 @@
readElement(streamReader) ;
}
+ @Override
+ public boolean isConnected() {
+ return true;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -294,7 +294,7 @@
private void runTo(String filename, int lineNumber) throws Exception {
setBreakpoint(filename, lineNumber) ;
SuspensionReader reader;
- if (!debuggerConnection.isCommandPortConnected()) {
+ if (!debuggerConnection.isStarted()) {
reader = debuggerConnection.start();
} else {
StepCommand stepCommand = new StepCommand("cont");
@@ -979,7 +979,7 @@
sendRuby("b test.rb:4");
getBreakpointAddedReader().readBreakpointNo();
sendRuby("w");
- RubyThread thread = new RubyThread(null, 0);
+ RubyThread thread = new RubyThread(null, 0, "run");
getFramesReader().readFrames(thread);
assertEquals(2, thread.getStackFrames().length);
RubyStackFrame frame1 = (RubyStackFrame) thread.getStackFrames()[0];
@@ -1001,7 +1001,7 @@
public void testFramesWhenThreadSpawned() throws Exception {
createSocket(new String[] { "def startThread", "Thread.new() { a = 5 }", "end", "def calc", "5 + 5", "end", "startThread()", "calc()" });
runTo("test.rb", 5);
- RubyThread thread = new RubyThread(null, 0);
+ RubyThread thread = new RubyThread(null, 0, "run");
sendRuby("w");
getFramesReader().readFrames(thread);
assertEquals(2, thread.getStackFramesSize());
@@ -1023,7 +1023,7 @@
assertEquals(2, threads.length);
sendRuby("th " + threads[0].getId() + " ; w ");
- RubyStackFrame[] stackFrames = getFramesReader().readFrames(new RubyThread(null, 1));
+ RubyStackFrame[] stackFrames = getFramesReader().readFrames(new RubyThread(null, 1, "run"));
assertEquals(1, stackFrames.length);
assertEquals(7, stackFrames[0].getLineNumber());
sendRuby("th " + threads[0].getId() + " ; v l");
@@ -1031,7 +1031,7 @@
assertEquals(1, variables.length);
assertEquals("b", variables[0].getName());
sendRuby("th " + threads[1].getId() + " ; w");
- stackFrames = getFramesReader().readFrames(new RubyThread(null, 1));
+ stackFrames = getFramesReader().readFrames(new RubyThread(null, 1, "run"));
assertEquals(1, stackFrames.length);
assertEquals(3, stackFrames[0].getLineNumber());
sendRuby("th " + threads[1].getId() + " ; v l");
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerProxyTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerProxyTest.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerProxyTest.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -51,9 +51,7 @@
public void setUp() throws Exception {
target = new TestRubyDebugTarget() ;
- //TODO: get proper directory
- String rubyFileDirectory ="launching/ruby " ;
- proxy = new RubyDebuggerProxy(target, rubyFileDirectory, false /*useRubyDebug*/) ;
+ proxy = new RubyDebuggerProxy(target, false /*useRubyDebug*/) ;
PipedInputStream pipedInputStream = new PipedInputStream() ;
PipedOutputStream pipedOutputStream = new PipedOutputStream(pipedInputStream) ;
@@ -85,9 +83,7 @@
}
}.start() ;
- // blocks until threads are read
- ThreadInfo[] threadInfos = getProxy().readThreads() ;
- assertEquals(1, threadInfos.length) ;
+
Thread.sleep(1000) ;
assertEquals(55, getTarget().getLastSuspensionPoint().getLine()) ;
}
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -67,7 +67,7 @@
@Override
public void startRubyProcess() throws Exception {
// TODO Auto-generated method stub
- String cmd = "rdebug -s -w -n -p 1098 --cport 1099 -d -f xml -I " + getTmpDir().replace('\\', '/') + " " + getRubyTestFilename();
+ String cmd = "rdebug-ide -p 1098 -d -I " + getTmpDir().replace('\\', '/') + " " + getRubyTestFilename();
// "FTC_DebuggerCommunicationTest.RUBY_INTERPRETER + " -I" +
// createIncludeDir() + " -I" + getTmpDir().replace('\\', '/') + "
// -rclassic-debug-verbose.rb " + ;
@@ -89,40 +89,10 @@
}
return result;
}
-
-// @Override
-// protected void createControlSocket() throws Exception {
-// try {
-// controlSocket = new Socket("localhost", 1099);
-// } catch (ConnectException cex) {
-// throw new RuntimeException(
-// "Ruby process finished prematurely. Last line in stderr: "
-// + rubyStderrRedirectorThread.getLastLine(), cex);
-// }
-// controlReaderStrategy = new MultiReaderStrategy(getXpp(controlSocket));
-//
-// Runnable runnable = new Runnable() {
-// public void run() {
-// try {
-// while (true) {
-// new WasteReader(controlReaderStrategy).read();
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// }
-// };
-// };
-// new Thread(runnable).start();
-// Thread.sleep(500) ;
-// controlWriter = new PrintWriter(controlSocket.getOutputStream(), true);
-// registerRubyDebugExtensions() ;
-// }
@Override
protected AbstractDebuggerConnection createDebuggerConnection() {
- return new RubyDebugConnection(getDirectoryOfRubyDebuggerFile(), 1098);
+ return new RubyDebugConnection(1098);
}
-
-
}
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_Single.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_Single.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_Single.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -2,14 +2,16 @@
import junit.framework.TestSuite;
/*
- * purpose of this test suite is to provide temporary smaller test suites for development
+ * purpose of this test suite is to provide small temporary test suites for development
*/
public class FTC_Single extends TestSuite {
public static junit.framework.TestSuite suite() {
TestSuite suite = new TestSuite();
- suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testBreakpointAddAndRemove"));
- suite.addTest(new FTC_RubyDebugCommunicationTest("testBreakpointAddAndRemove"));
+ //suite.addTest(new FTC_ClassicDebuggerCommunicationTest("testBreakpointAddAndRemove"));
+ //suite.addTest(new FTC_RubyDebugCommunicationTest("testBreakpointAddAndRemove"));
+ suite.addTest(new FTC_RubyDebugCommunicationTest("testInspectError"));
+
//suite.addTest(classicSuite()) ;
//suite.addTest(rdebugSuite()) ;
return suite ;
Added: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TC_RubyDebugTarget.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TC_RubyDebugTarget.java (rev 0)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/TC_RubyDebugTarget.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -0,0 +1,37 @@
+package org.rubypeople.rdt.debug.core.tests;
+
+import org.eclipse.debug.core.DebugEvent;
+import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
+import org.rubypeople.rdt.internal.debug.core.model.ThreadInfo;
+
+import junit.framework.TestCase;
+
+public class TC_RubyDebugTarget extends TestCase {
+
+
+ public void testThread() {
+ RubyDebugTarget target = new RubyDebugTarget(null) ;
+ ThreadInfo[] initial = new ThreadInfo[] { new ThreadInfo(1, "run")} ;
+ DebugEvent[] events = target.updateThreadsInternal(initial) ;
+ assertEquals(1, events.length) ;
+ assertEquals(DebugEvent.CREATE, events[0].getKind()) ;
+ ThreadInfo[] threadAdded = new ThreadInfo[] { new ThreadInfo(1, "run"), new ThreadInfo(2, "sleep")} ;
+ events = target.updateThreadsInternal(threadAdded) ;
+ assertEquals(1, events.length) ;
+ assertEquals(DebugEvent.CREATE, events[0].getKind()) ;
+ events = target.updateThreadsInternal(initial) ;
+ assertEquals(1, events.length) ;
+ assertEquals(DebugEvent.TERMINATE, events[0].getKind()) ;
+ ThreadInfo[] changed = new ThreadInfo[] { new ThreadInfo(1, "sleep")} ;
+ events = target.updateThreadsInternal(changed) ;
+ assertEquals(1, events.length) ;
+ assertEquals(DebugEvent.CHANGE, events[0].getKind()) ;
+
+ ThreadInfo[] addAndRemove = new ThreadInfo[] { new ThreadInfo(2, "run")} ;
+ events = target.updateThreadsInternal(addAndRemove) ;
+ assertEquals(2, events.length) ;
+ assertEquals(DebugEvent.CREATE, events[0].getKind()) ;
+ assertEquals(DebugEvent.TERMINATE, events[1].getKind()) ;
+
+ }
+}
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestRubyDebugDebugger.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -23,13 +23,13 @@
@Override
protected RubyDebuggerProxy getDebugProxy(RubyDebugTarget debugTarget) {
- return new TestDebuggerProxy(debugTarget, getDirectoryOfRubyDebuggerFile(), true);
+ return new TestDebuggerProxy(debugTarget, true);
}
private static class TestDebuggerProxy extends RubyDebuggerProxy {
- public TestDebuggerProxy(IRubyDebugTarget debugTarget, String rubyFileDirectory, boolean isRubyDebug) {
- super(debugTarget, rubyFileDirectory, isRubyDebug);
+ public TestDebuggerProxy(IRubyDebugTarget debugTarget, boolean isRubyDebug) {
+ super(debugTarget, isRubyDebug);
}
@Override
Modified: trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TestVMDebugger.java 2007-03-31 18:00:53 UTC (rev 2251)
@@ -24,13 +24,13 @@
@Override
protected RubyDebuggerProxy getDebugProxy(RubyDebugTarget debugTarget) {
- return new TestDebuggerProxy(debugTarget, getDirectoryOfRubyDebuggerFile(), false);
+ return new TestDebuggerProxy(debugTarget, false);
}
private static class TestDebuggerProxy extends RubyDebuggerProxy {
- public TestDebuggerProxy(IRubyDebugTarget debugTarget, String rubyFileDirectory, boolean isRubyDebug) {
- super(debugTarget, rubyFileDirectory, isRubyDebug);
+ public TestDebuggerProxy(IRubyDebugTarget debugTarget, boolean isRubyDebug) {
+ super(debugTarget, isRubyDebug);
}
@Override
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-03-30 16:09:17 UTC (rev 2250)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-03-31 18:00:53 UTC (rev 2251)
@@ -172,7 +172,7 @@
DebuggerPreferencePage_description_label=Debugger preferences
DebuggerPreferencePage_useRubyDebug_label=Use ruby-debug library
DebuggerPreferencePage_verboseDebugger_label=Debugger verbose mode
-DebuggerPreferencePage_useRubyDebug_comment=ruby-debug requires a ruby version >= 1.8.4.\nAt the time being a patched ruby-debug version must be used.\nIt is packaged with RDT and can be found at:\n {0}.\nIt can be installed with the command 'gem install'.\nPlease be aware that the package contains native code and therefore a c-compiler for your platform must be available.
+DebuggerPreferencePage_useRubyDebug_comment=ruby-debug requires a ruby version >= 1.8.4.\nThere must be two gems installed: ruby-debug-base (version 0.9) and ruby-debug-ide (version 0.1.0). They are packaged with RDT and can be found at:\n {0}.\nInstall with the command 'gem install' but please be aware that ruby-debug-base contains native code and therefore requires a C compiler.
PropertyAndPreferencePage_useprojectsettings_label=Enable pr&oject specific settings
PropertyAndPreferencePage_useworkspacesettings_change=Configure Workspace Settings...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|