X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java index db66060..77d751e 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java @@ -15,6 +15,7 @@ import java.net.ServerSocket; import java.net.Socket; import java.net.SocketTimeoutException; import java.util.Map; +import java.util.Vector; import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint; import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget; @@ -95,6 +96,14 @@ public class PHPDBGProxy { phpLoop.notifyWait (); } + + public void setTerminated () { + try { + PHPMainThread.terminate (); + } + catch (DebugException e) { + } + } /** * TODO Is this method called from anywhere? @@ -114,15 +123,26 @@ public class PHPDBGProxy { } /** - * - * TODO The example for setting up DBG within PHP.ini shows ports from 10000 to 10016 ??? - * if my interpretation is correct. - * How can we find the correct DBG port? + * Find a free unused port between 10001 and 10101 if the current debug session + * is for remote debugging, and a unused port 7869 if it is used as non remote debugging. + * + * For remote debugging the used port is submitted with the URL. + * E.g. http://localhost/index.php?DBGSESSID=1@localhost:10001 + * For non remote debugging (if PHPeclipse used e.g. php cli directly) no port + * can be submitted by parameter, and only the default port (7869) can be used. + * + * @note: The free dbg version doesn't allow to set the appropriate port within php.ini! + * + * */ protected void createServerSocket () { - port = SocketUtil.findUnusedLocalPort ("localhost", 10001, 10101); // Get the first free port in the range from 10001 to 10101 - -// port = 10001; + if (this.remote) { + port = SocketUtil.findUnusedLocalPort ("localhost", 10001, 10101); // Get the first free port in the range from 10001 to 10101 + } + else { + port = SocketUtil.findUnusedLocalPort ("localhost", 7869, 7869); // Get the first free port in the range from 7869 to 7869 + } + if (port == -1) { // Did we get a free port? PHPDebugCorePlugin.log (5, "Cannot find free port!!!!"); // No, output a error message @@ -134,7 +154,6 @@ public class PHPDBGProxy { //System.out.println("ServerSocket on port: " + port); } } catch (IOException e) { - // IO Error PHPDebugCorePlugin.log (e); stop (); } @@ -207,7 +226,11 @@ public class PHPDBGProxy { * */ private String MapPath (PHPLineBreakpoint phpLBP) { - IPath filename; + IPath filename; + IPath remotePath; + IPath newpath; + IPath localPath; + String local; if (remote) { filename = phpLBP.getMarker().getResource().getProjectRelativePath(); @@ -230,14 +253,43 @@ public class PHPDBGProxy { } } - if (pathtranslation && remote) { - if (remoteSourcePath.toString ().substring (0, 1).equals ("/")) { - path = path.replace ('\\', '/'); - } - else { - path = path.replace ('/', '\\'); + if (remoteSourcePath.isEmpty ()) { + if ((pathmap != null) && remote) { + java.util.Iterator iterator = pathmap.keySet().iterator(); + + while (iterator.hasNext ()) { + local = (String) iterator.next (); // Get the local/client side path of the mapping + remotePath = new Path ((String) pathmap.get (local)); // Get the remote/server side path of the mapping + localPath = new Path (local); // Get the remote/server side path of the mapping + + if (localPath.isPrefixOf (filename)) { // Starts the remote/server side file path with the remote/server side mapping path + // dann prefix abhängen und den remote path davorhägen + newpath = filename.removeFirstSegments (localPath.matchingFirstSegments (filename)); + newpath = remotePath.append (newpath); + path = newpath.toString (); + + if (path.substring (0, 1).equals ("/")) { + path = path.replace ('\\', '/'); + } + else { + path = path.replace ('/', '\\'); + } + + return path; + } + } } - } + } + else { + if (pathtranslation && remote) { + if (remoteSourcePath.toString ().substring (0, 1).equals ("/")) { + path = path.replace ('\\', '/'); + } + else { + path = path.replace ('/', '\\'); + } + } + } return path; } @@ -259,8 +311,19 @@ public class PHPDBGProxy { phpLBP = (PHPLineBreakpoint) breakpoint; // bpNo= DBGInt.addBreakpoint(phpLBP.getMarker().getResource().getLocation().toOSString(), phpLBP.getLineNumber()); - - bpNo = DBGInt.addBreakpoint(MapPath(phpLBP), phpLBP.getLineNumber()); + if (phpLBP.isConditionEnabled ()) { + bpNo = DBGInt.addBreakpoint (MapPath(phpLBP), + phpLBP.getLineNumber(), + phpLBP.getHitCount(), + phpLBP.getCondition ()); + } + else { + bpNo = DBGInt.addBreakpoint (MapPath(phpLBP), + phpLBP.getLineNumber(), + phpLBP.getHitCount(), + ""); + } + phpLBP.setDBGBpNo(bpNo); } } catch (IOException e) { @@ -367,9 +430,9 @@ public class PHPDBGProxy { * It reads the variables from PHP via DBG * * @param frame The stackframe which wants the variables. - * @return The array of variables for this stackframe. + * @return The list of variables for this stackframe. */ - public PHPVariable[] readVariables (PHPStackFrame frame) { + public Vector readVariables (PHPStackFrame frame) { try { return DBGInt.getVariables (frame); // Get the variables from DBG interface } catch (IOException ioex) {