|
From: Markus B. <mba...@us...> - 2005-10-09 21:22:15
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1010/src/org/rubypeople/rdt/internal/debug/core/model Modified Files: IRubyDebugTarget.java RubyDebugTarget.java Log Message: fixed port 1098 replaced by variable port Index: RubyDebugTarget.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/RubyDebugTarget.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** RubyDebugTarget.java 3 Oct 2005 07:16:25 -0000 1.10 --- RubyDebugTarget.java 9 Oct 2005 21:22:08 -0000 1.11 *************** *** 1,4 **** --- 1,9 ---- package org.rubypeople.rdt.internal.debug.core.model; + import java.io.File; + import java.io.FileWriter; + import java.io.IOException; + import java.io.PrintWriter; + import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.runtime.IStatus; *************** *** 14,17 **** --- 19,23 ---- import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IThread; + import org.rubypeople.rdt.core.SocketUtil; import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin; import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy; *************** *** 24,28 **** public class RubyDebugTarget extends PlatformObject implements IRubyDebugTarget { ! private IProcess process; private boolean isTerminated; --- 30,34 ---- public class RubyDebugTarget extends PlatformObject implements IRubyDebugTarget { ! private static int DEFAULT_PORT = 1098 ; private IProcess process; private boolean isTerminated; *************** *** 30,34 **** --- 36,46 ---- private RubyThread[] threads; private RubyDebuggerProxy rubyDebuggerProxy; + private int port = -1 ; + private File debugParameterFile; + public RubyDebugTarget(ILaunch launch) { + this(launch, null) ; + } + public RubyDebugTarget(ILaunch launch, IProcess process) { this.launch = launch; *************** *** 37,41 **** IBreakpointManager manager= DebugPlugin.getDefault().getBreakpointManager(); manager.addBreakpointListener(this); - } --- 49,52 ---- *************** *** 137,141 **** // launch is one of the listeners DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] {new DebugEvent(this, DebugEvent.TERMINATE)}); ! } --- 148,159 ---- // launch is one of the listeners 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() ; ! if (!deleted) { ! RdtDebugCorePlugin.debug("Could not delete debugParameteFile:" + debugParameterFile.toURI()) ; ! } ! } } *************** *** 217,220 **** this.rubyDebuggerProxy = rubyDebuggerProxy; } ! } --- 235,284 ---- this.rubyDebuggerProxy = rubyDebuggerProxy; } ! ! public File getDebugParameterFile() { ! if (debugParameterFile == null) { ! try { ! debugParameterFile = File.createTempFile("eclipseDebug",".rb") ; ! } catch (IOException e) { ! RdtDebugCorePlugin.log("Could not create debugParameterFile", e) ; ! } ! } ! return debugParameterFile ; ! } ! ! public boolean addDebugParameter(String line) { ! try { ! FileWriter writer = new FileWriter(this.getDebugParameterFile()); ! new PrintWriter(writer).println(line); ! writer.flush(); ! writer.close(); ! return true; ! } catch (IOException ex) { ! RdtDebugCorePlugin.log(ex); ! return false; ! } ! } ! ! public int getPort() { ! if (port == -1) { ! port = SocketUtil.findFreePort() ; ! // port can still be -1, if findFreePort fails ! if (port != -1) { ! // see eclipseDebug.rb for how $EclipseListenPort is used from ruby side ! if (!addDebugParameter("$EclipseListenPort=" + port)) { ! port = -1 ; ! } ! } ! // if we couldn't find a free port a write the free port to the file, use the default ! if (port == -1) { ! port = DEFAULT_PORT ; ! } ! RdtDebugCorePlugin.debug("Using port: " + port) ; ! } ! return port ; ! } ! ! public boolean isUsingDefaultPort() { ! return this.getPort() == DEFAULT_PORT ; ! } } Index: IRubyDebugTarget.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/model/IRubyDebugTarget.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** IRubyDebugTarget.java 20 Mar 2004 15:37:09 -0000 1.3 --- IRubyDebugTarget.java 9 Oct 2005 21:22:08 -0000 1.4 *************** *** 11,14 **** --- 11,15 ---- public void terminate() ; public void setRubyDebuggerProxy(RubyDebuggerProxy rubyDebuggerProxy) ; + public int getPort() ; |