|
From: <mba...@us...> - 2006-10-08 13:31:22
|
Revision: 1619
http://svn.sourceforge.net/rubyeclipse/?rev=1619&view=rev
Author: mbarchfe
Date: 2006-10-08 06:30:57 -0700 (Sun, 08 Oct 2006)
Log Message:
-----------
changes for ruby-debug and adapting to Eclipse 3.2 debug framework
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/model/RubyDebugTarget.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/ruby-debug-0.4.2-mswin32.zip
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 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebuggerProxy.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -144,7 +144,7 @@
if (breakpoint instanceof RubyExceptionBreakpoint) {
this.println("catch " + ((RubyExceptionBreakpoint) breakpoint).getException());
} else {
- this.printBreakpoint("add", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1));
+ this.printBreakpoint("", breakpoint.getMarker().getResource().getName(), breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, -1));
}
}
} catch (IOException e) {
@@ -292,7 +292,7 @@
public RubyStackFrame[] readFrames(RubyThread thread) {
try {
- this.println("th " + thread.getId() + " ; f ");
+ this.println("th " + thread.getId() + " ; w");
return new FramesReader(getMultiReaderStrategy()).readFrames(thread);
} catch (IOException e) {
RdtDebugCorePlugin.log(e);
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 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -67,13 +67,13 @@
}
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 });
} else {
updatedThreads[i] = threads[threadIndex];
}
}
threads = updatedThreads;
- DebugEvent ev = new DebugEvent(this, DebugEvent.CHANGE);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
}
@@ -101,6 +101,7 @@
}
public boolean hasThreads() throws DebugException {
+ System.out.println("THREADS: " + threads.length) ;
return threads.length > 0;
}
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyStackFrame.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -43,10 +43,7 @@
}
public boolean hasVariables() throws DebugException {
- if (variables == null) {
- return false;
- }
- return variables.length > 0;
+ return getVariables().length > 0;
}
public int getLineNumber() {
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 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyThread.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -15,37 +15,56 @@
// see RubyDebugTarget for the reason why PlatformObject is being extended
public class RubyThread extends PlatformObject implements IThread {
private RubyStackFrame[] frames;
+
private IDebugTarget target;
+
private boolean isSuspended = false;
+
private boolean isTerminated = false;
+
private boolean isStepping = false;
- private String name ;
- private int id ;
-
+
+ private String name;
+
+ private int id;
+
public RubyThread(IDebugTarget target, int id) {
this.target = target;
- this.setId(id) ;
- this.createName() ;
+ this.setId(id);
+ this.createName();
}
- public IStackFrame[] getStackFrames() throws DebugException {
- // Not all clients ask hasStackFrames before calling this method (DeferredThread)
+ public IStackFrame[] getStackFrames() {
+ // Not all clients ask hasStackFrames before calling this method
+ // (DeferredThread)
// Therefore we must not return null
+ // Since 3.2: It seems as if the first method called on a thread is
+ // hasStackFrames
+ // this is done frome AsynchronousContentAdapter and therefore we have
+ // the time to
+ // send this call to the debuggger ;
if (frames == null) {
- return new RubyStackFrame[0];
+ createStackFrames();
}
- return frames ;
+ return frames;
}
+ private void createStackFrames() {
+ getRubyDebuggerProxy().readFrames(this);
+ for (int i = 0; i < frames.length; i++) {
+ RubyStackFrame frame = frames[i];
+ DebugEvent ev = new DebugEvent(frame, DebugEvent.CREATE);
+ DebugPlugin.getDefault().fireDebugEventSet(
+ new DebugEvent[] { ev });
+ }
+ }
+
public int getStackFramesSize() {
return frames.length;
}
public boolean hasStackFrames() {
- if (frames == null) {
- return false;
- }
- return frames.length > 0;
+ return getStackFrames().length > 0;
}
public int getPriority() throws DebugException {
@@ -59,10 +78,11 @@
return frames[0];
}
-
public IBreakpoint[] getBreakpoints() {
// TODO: Experimental Code
- return new IBreakpoint[] { DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IRubyDebugTarget.MODEL_IDENTIFIER)[0] } ;
+ return new IBreakpoint[] { DebugPlugin.getDefault()
+ .getBreakpointManager().getBreakpoints(
+ IRubyDebugTarget.MODEL_IDENTIFIER)[0] };
}
public String getModelIdentifier() {
@@ -95,27 +115,30 @@
protected void prepareForResume() {
isSuspended = false;
- this.createName() ;
- this.frames = null ;
- DebugEvent ev = new DebugEvent(this, DebugEvent.RESUME, DebugEvent.CLIENT_REQUEST);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
+ this.createName();
+ this.frames = null;
+ DebugEvent ev = new DebugEvent(this, DebugEvent.RESUME,
+ DebugEvent.CLIENT_REQUEST);
+ DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
}
public void resume() throws DebugException {
- this.prepareForResume() ;
- ((RubyDebugTarget) this.getDebugTarget()).getRubyDebuggerProxy().resume(this);
+ this.prepareForResume();
+ ((RubyDebugTarget) this.getDebugTarget()).getRubyDebuggerProxy()
+ .resume(this);
}
public void doSuspend(SuspensionPoint suspensionPoint) {
- this.getRubyDebuggerProxy().readFrames(this);
- this.createName(suspensionPoint) ;
- this.suspend() ;
+ this.createStackFrames() ;
+ this.createName(suspensionPoint);
+ this.suspend();
}
- public void suspend() {
- isStepping = false ;
+ public void suspend() {
+ isStepping = false;
isSuspended = true;
- DebugEvent ev = new DebugEvent(this, DebugEvent.SUSPEND, DebugEvent.BREAKPOINT);
+ DebugEvent ev = new DebugEvent(this, DebugEvent.SUSPEND,
+ DebugEvent.BREAKPOINT);
DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
}
@@ -136,17 +159,17 @@
}
public void stepInto() throws DebugException {
- isStepping = true ;
- this.createName() ;
- this.frames = null ;
+ isStepping = true;
+ this.createName();
+ this.frames = null;
frames[0].stepInto();
}
public void stepOver() throws DebugException {
- isStepping = true ;
- this.createName() ;
- this.frames = null ;
- frames[0].stepOver() ;
+ isStepping = true;
+ this.createName();
+ this.frames = null;
+ frames[0].stepOver();
}
public void stepReturn() throws DebugException {
@@ -161,7 +184,7 @@
}
public void terminate() throws DebugException {
- this.getDebugTarget().terminate() ;
+ this.getDebugTarget().terminate();
isTerminated = true;
this.frames = null;
}
@@ -183,13 +206,13 @@
}
protected void createName() {
- this.createName(null) ;
+ this.createName(null);
}
-
+
protected void createName(SuspensionPoint suspensionPoint) {
- this.name = "Ruby Thread - " + this.getId() ;
- if (suspensionPoint != null) {
- this.name += " (" + suspensionPoint + ")" ;
+ this.name = "Ruby Thread - " + this.getId();
+ if (suspensionPoint != null) {
+ this.name += " (" + suspensionPoint + ")";
}
}
Added: trunk/org.rubypeople.rdt.launching/ruby-debug-0.4.2-mswin32.zip
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.launching/ruby-debug-0.4.2-mswin32.zip
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -4,50 +4,91 @@
import java.util.List;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IProcess;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.parser.RdtPosition;
import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
public class DebuggerRunner extends InterpreterRunner {
- private RubyDebugTarget debugTarget ;
- public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) throws CoreException {
- debugTarget = new RubyDebugTarget(launch);
+ private RubyDebugTarget debugTarget;
+
+ public IProcess run(InterpreterRunnerConfiguration configuration,
+ ILaunch launch) throws CoreException {
+ debugTarget = new RubyDebugTarget(launch);
IProcess process = super.run(configuration, launch);
- debugTarget.setProcess(process) ;
- RubyDebuggerProxy proxy = new RubyDebuggerProxy(debugTarget) ;
+ debugTarget.setProcess(process);
+ RubyDebuggerProxy proxy = new RubyDebuggerProxy(debugTarget);
if (proxy.checkConnection()) {
proxy.start();
- launch.addDebugTarget(debugTarget);
- }
- else {
- RdtLaunchingPlugin.log(new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, RdtLaunchingMessages.getString("RdtLaunchingPlugin.processTerminatedBecauseNoDebuggerConnection"),null)) ;
+ launch.addDebugTarget(debugTarget);
+ } else {
+ RdtLaunchingPlugin
+ .log(new Status(
+ IStatus.ERROR,
+ RdtLaunchingPlugin.PLUGIN_ID,
+ IStatus.ERROR,
+ RdtLaunchingMessages
+ .getString("RdtLaunchingPlugin.processTerminatedBecauseNoDebuggerConnection"),
+ null));
debugTarget.terminate();
}
return process;
}
protected void addDebugCommandLineArgument(List commandLine) {
- if (!debugTarget.isUsingDefaultPort()) {
- commandLine.add("-r" + debugTarget.getDebugParameterFile().getAbsolutePath());
- }
-
- if (RdtDebugCorePlugin.isRubyDebuggerVerbose()) {
- commandLine.add("-reclipseDebugVerbose");
+ if (isUseRubyDebug()) {
+ commandLine.add("--server");
+ commandLine.add("--port");
+ commandLine.add(Integer.toString(debugTarget.getPort()));
+ commandLine.add("--wait");
+ commandLine.add("--eclipse");
} else {
- commandLine.add("-reclipseDebug");
+ if (!debugTarget.isUsingDefaultPort()) {
+ commandLine
+ .add("-r"
+ + debugTarget.getDebugParameterFile()
+ .getAbsolutePath());
+ }
+
+ if (RdtDebugCorePlugin.isRubyDebuggerVerbose()) {
+ commandLine.add("-reclipseDebugVerbose");
+ } else {
+ commandLine.add("-reclipseDebug");
+ }
+ commandLine.add("-I");
+ commandLine.add(RdtLaunchingPlugin.osDependentPath(DebuggerRunner
+ .getDirectoryOfRubyDebuggerFile().replace('/',
+ File.separatorChar)));
}
-
- commandLine.add("-I");
- commandLine.add(RdtLaunchingPlugin.osDependentPath(DebuggerRunner.getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar)));
}
public static String getDirectoryOfRubyDebuggerFile() {
- return RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault()) + "ruby" ;
+ return RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault())
+ + "ruby";
}
+
+ public boolean isUseRubyDebug() {
+ // TODO: use PrefernceConstants ?
+ return RdtLaunchingPlugin.getDefault().getPluginPreferences().getBoolean(
+ "useRubyDebug");
+ }
+
+ protected RubyInterpreter convertInterpreter(RubyInterpreter rubyInterpreter) {
+ if (isUseRubyDebug()) {
+ IPath rdebugLocation = rubyInterpreter.getInstallLocation()
+ .removeLastSegments(1);
+ rdebugLocation = rdebugLocation.append("rdebug.cmd");
+ return new RubyInterpreter("rdebug", rdebugLocation);
+ } else {
+ return rubyInterpreter;
+ }
+ }
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -19,7 +19,7 @@
List commandLine = renderCommandLine(configuration);
File workingDirectory = configuration.getAbsoluteWorkingDirectory();
- RubyInterpreter interpreter = configuration.getInterpreter() ;
+ RubyInterpreter interpreter = convertInterpreter(configuration.getInterpreter()) ;
Process nativeRubyProcess = interpreter.exec(commandLine, workingDirectory);
Map defaultAttributes = new HashMap();
defaultAttributes.put(IProcess.ATTR_PROCESS_TYPE, "ruby");
@@ -27,9 +27,11 @@
process.setAttribute(RdtLaunchingPlugin.PLUGIN_ID + ".launcher.cmdline", commandLine.toString());
return process ;
}
+
+ protected RubyInterpreter convertInterpreter(RubyInterpreter rubyInterpreter) {
+ return rubyInterpreter ;
+ }
-
-
protected String renderLabel(InterpreterRunnerConfiguration configuration) {
StringBuffer buffer = new StringBuffer();
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java 2006-10-08 13:29:41 UTC (rev 1618)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java 2006-10-08 13:30:57 UTC (rev 1619)
@@ -61,7 +61,7 @@
List rubyCmd = new ArrayList();
rubyCmd.add(this.getCommand());
rubyCmd.addAll(args);
- return commandExecutor.exec((String[]) rubyCmd.toArray(new String[0]), workingDirectory);
+ return commandExecutor.exec((String[]) rubyCmd.toArray(new String[] {}), workingDirectory);
} catch (IOException e) {
IStatus errorStatus = new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.OK,
"Unable to execute interpreter: " + args + workingDirectory, e);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|