Patches from Martin K�r:
authoraxelcl <axelcl>
Thu, 10 Mar 2005 17:53:30 +0000 (17:53 +0000)
committeraxelcl <axelcl>
Thu, 10 Mar 2005 17:53:30 +0000 (17:53 +0000)
http://phpeclipse.de/tiki-view_forum_thread.php?forumId=3&comments_parentId=1432

net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/PHPDebugUiMessages.properties
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEnvironmentTab.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java

index 47262d7..caec4dd 100644 (file)
@@ -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() {
@@ -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)
+    {
+    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)
+       {
+               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);
index 4aa4f7b..09420f2 100644 (file)
@@ -29,6 +29,7 @@ LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message=No
 
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.label=Remote &Debug
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteCheckBox.label=Remote &Debug
+LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label=Cross Plattform debugging
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteSourcePath.label=Remote &Sourcepath:
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label=Open with DBGSession URL in internal Browser
 LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.PathMap.label=Mapped Path:
index e404e63..a705d70 100644 (file)
@@ -52,6 +52,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
   //   protected Button loadPathDefaultButton;
   protected Button fRemoteDebugCheckBox;
+  protected Button fRemoteDebugTranslate;
 
   protected Button fOpenDBGSessionInBrowserCheckBox;
 
@@ -95,6 +96,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
         handlePathMapRemoveButtonSelected();
       } else if (source == fRemoteDebugCheckBox) {
         setRemoteTabEnableState();
+      } else if (source == fRemoteDebugTranslate) {
+        setRemoteTabEnableState();
       } else {
         updateLaunchConfigurationDialog();
         ;
@@ -110,6 +113,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
   private static final boolean DEFAULT_REMOTE_DEBUG = false;
 
+  private static final boolean DEFAULT_REMOTE_DEBUG_TRANSLATE = false;
+
   private static final boolean DEFAULT_OPEN_DBGSESSION_IN_BROWSER = true;
 
   static String[] columnTitles = {
@@ -149,6 +154,12 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
     fRemoteDebugCheckBox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
     fRemoteDebugCheckBox.addSelectionListener(fListener);
 
+    fRemoteDebugTranslate = new Button(comp, SWT.CHECK);
+    fRemoteDebugTranslate.setText(PHPDebugUiMessages
+        .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.RemoteTranslate.label"));
+    fRemoteDebugTranslate.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+    fRemoteDebugTranslate.addSelectionListener(fListener);
+
     fOpenDBGSessionInBrowserCheckBox = new Button(comp, SWT.CHECK);
     fOpenDBGSessionInBrowserCheckBox.setText(PHPDebugUiMessages
         .getString("LaunchConfigurationTab.PHPEnvironment.remoteDebugTab.OpenDBGSessionInBrowserCheckBox.label"));
@@ -266,7 +277,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
   private void setRemoteTabEnableState() {
     boolean state = fRemoteDebugCheckBox.getSelection();
     fRemoteSourcePath.setEnabled(state);
-
+    fRemoteDebugTranslate.setEnabled(state);
+    
     fRemoteDebugPathMapTable.setEnabled(state);
     if (!state) {
       fPathMapEditButton.setEnabled(false);
@@ -288,6 +300,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
     //
     if (fRemoteDebugCheckBox.getSelection()) {
       fOpenDBGSessionInBrowserCheckBox.setEnabled(true);
+      fRemoteDebugTranslate.setEnabled(true);
       int selectCount = this.fRemoteDebugPathMapTable.getSelectionIndices().length;
       if (selectCount < 1) {
         fPathMapEditButton.setEnabled(false);
@@ -452,6 +465,12 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
       fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
     }
     try {
+        fRemoteDebugTranslate.setSelection(configuration.getAttribute(
+            PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, DEFAULT_REMOTE_DEBUG_TRANSLATE));
+      } catch (CoreException ce) {
+        fRemoteDebugTranslate.setSelection(DEFAULT_REMOTE_DEBUG_TRANSLATE);
+      }
+    try {
       fOpenDBGSessionInBrowserCheckBox.setSelection(configuration.getAttribute(
           PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, DEFAULT_OPEN_DBGSESSION_IN_BROWSER));
     } catch (CoreException ce) {
@@ -567,6 +586,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
     //         }
 
     configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, fRemoteDebugCheckBox.getSelection());
+    configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, fRemoteDebugTranslate.getSelection());
     configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, getMapFromPathMapTable());
     configuration.setAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, fRemoteSourcePath.getText());
     configuration.setAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, fOpenDBGSessionInBrowserCheckBox
index ac75a7c..9a2f1af 100644 (file)
@@ -27,7 +27,8 @@ public class DebuggerRunner extends InterpreterRunner {
   public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
     String[] env;
     String name, value;
-    PHPDBGProxy newPHPDBGProxy = new PHPDBGProxy(configuration.useRemoteDebugger(), configuration.getRemoteSourcePath());
+    PHPDBGProxy newPHPDBGProxy = new PHPDBGProxy(configuration.useRemoteDebugger(), configuration.getRemoteSourcePath(),
+                       configuration.usePathTranslation(),configuration.getPathMap());
     int pos;
 
     IProcess process = null;
index b2950d7..cd25d13 100644 (file)
@@ -103,6 +103,24 @@ public class InterpreterRunnerConfiguration {
                return false;
        }
        
+       public boolean usePathTranslation() {
+               try {
+                       return configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE, false);
+               } catch(CoreException e) {
+                       PHPLaunchingPlugin.log(e);
+               }
+               return false;
+       }
+       
+       public Map getPathMap() {
+               try {
+                       return configuration.getAttribute(PHPLaunchConfigurationAttribute.FILE_MAP, (Map) null);
+               } catch(CoreException e) {
+               PHPLaunchingPlugin.log(e);
+               }
+               return (Map) null;
+       }
+       
        public boolean useDBGSessionInBrowser() {
                try {
                        return configuration.getAttribute(PHPLaunchConfigurationAttribute.OPEN_DBGSESSION_IN_BROWSER, true);
@@ -156,7 +174,7 @@ public class InterpreterRunnerConfiguration {
        public String getRemoteSourcePath() {
                
                IProject project = getProject().getProject();
-               if (useRemoteDebugger())
+               if (!useRemoteDebugger())
                        return project.getLocation().toOSString();
                else
                {               
index 098a059..cd05cf3 100644 (file)
@@ -16,6 +16,7 @@ public interface PHPLaunchConfigurationAttribute {
 //     static final String USE_DEFAULT_LOAD_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_LOAD_PATH";
        static final String USE_DEFAULT_WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_WORKING_DIRECTORY";
        static final String REMOTE_DEBUG = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_DEBUG";
+       static final String REMOTE_DEBUG_TRANSLATE = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_DEBUG_TRANSLATE";
        static final String REMOTE_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_PATH";
        static final String OPEN_DBGSESSION_IN_BROWSER = PHPLaunchingPlugin.PLUGIN_ID + ".OPEN_DBGSESSION_IN_BROWSER";
        static final String FILE_MAP = PHPLaunchingPlugin.PLUGIN_ID + ".FILE_MAP";