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 d336d7e..b28f529 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 @@ -14,6 +14,7 @@ import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketTimeoutException; +import java.util.Map; import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint; import net.sourceforge.phpdt.internal.debug.core.logview.LogView; @@ -53,16 +54,22 @@ public class PHPDBGProxy { private boolean remote; + private boolean pathtranslation; + + private Map pathmap; + private IPath remoteSourcePath; public PHPDBGProxy() { thisProxy = this; } - public PHPDBGProxy(boolean remote, String remoteSourcePath) { + public PHPDBGProxy(boolean remote, String remoteSourcePath,boolean pathTranslate,Map paths) { thisProxy = this; this.remote = remote; this.remoteSourcePath = new Path(remoteSourcePath); + this.pathmap=paths; + this.pathtranslation=pathTranslate; } public void start() { @@ -92,8 +99,8 @@ public class PHPDBGProxy { } protected void createServerSocket() { - // port = SocketUtil.findUnusedLocalPort("localhost", 10001, 10101); - port = 10001; + port = SocketUtil.findUnusedLocalPort("localhost", 10001, 10101); +// port = 10001; if (port == -1) { PHPDebugCorePlugin.log(5, "Cannot find free port!!!!"); return; @@ -143,6 +150,40 @@ public class PHPDBGProxy { } } + private String MapPath(PHPLineBreakpoint phpLBP) + { + IPath filename; + if (remote) + { + filename = phpLBP.getMarker().getResource().getProjectRelativePath(); + filename = remoteSourcePath.append(filename); + } + else + filename = phpLBP.getMarker().getResource().getLocation(); + String path=filename.toOSString(); + if(pathmap!=null&&remote) + { + java.util.Iterator i=pathmap.keySet().iterator(); + while(i.hasNext()) + { + String k=(String)i.next(); + if(path.substring(0,k.length()).equals(k)) + { + path=pathmap.get(k)+path.substring(k.length()); + break; + } + } + } + if(pathtranslation&&remote) + { + if(path.substring(0,1).equals("/")) + path=path.replace('\\','/'); + else + path=path.replace('/','\\'); + } + return path; + } + public void addBreakpoint(IBreakpoint breakpoint) { if (DBGInt == null) return; @@ -150,14 +191,10 @@ public class PHPDBGProxy { try { PHPLineBreakpoint phpLBP; if (breakpoint.getModelIdentifier() == PHPDebugCorePlugin.getUniqueIdentifier()) { - IPath filename; phpLBP = (PHPLineBreakpoint) breakpoint; // bpNo= DBGInt.addBreakpoint(phpLBP.getMarker().getResource().getLocation().toOSString(), phpLBP.getLineNumber()); - if (remote) - filename = remoteSourcePath.append(phpLBP.getMarker().getResource().getProjectRelativePath()); - else - filename = phpLBP.getMarker().getResource().getLocation(); - bpNo = DBGInt.addBreakpoint(filename.toOSString(), phpLBP.getLineNumber()); + + bpNo = DBGInt.addBreakpoint(MapPath(phpLBP), phpLBP.getLineNumber()); phpLBP.setDBGBpNo(bpNo); } } catch (IOException e) { @@ -176,13 +213,9 @@ public class PHPDBGProxy { PHPLineBreakpoint phpLBP; if (breakpoint.getModelIdentifier() == PHPDebugCorePlugin.getUniqueIdentifier()) { phpLBP = (PHPLineBreakpoint) breakpoint; - IPath filename; - if (remote) - filename = remoteSourcePath.append(phpLBP.getMarker().getResource().getProjectRelativePath()); - else - filename = phpLBP.getMarker().getResource().getLocation(); + // bpNo= DBGInt.addBreakpoint(filename.toOSString(), phpLBP.getLineNumber()); - DBGInt.removeBreakpoint(filename.toOSString(), phpLBP.getLineNumber(), phpLBP.getDBGBpNo()); + DBGInt.removeBreakpoint(MapPath(phpLBP), phpLBP.getLineNumber(), phpLBP.getDBGBpNo()); } } catch (IOException e) { PHPDebugCorePlugin.log(e);