1) Introduced a warning log message for breakpoints that do not match the local path...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugTarget.java
index 79e6366..396b317 100644 (file)
@@ -3,7 +3,6 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
-//import java.io.ByteArrayInputStream;
 //import java.io.IOException;
 import java.util.List;
 
@@ -25,6 +24,8 @@ import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IMarkerDelta;
 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.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
@@ -328,7 +329,11 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                                                try {
                                                        if (breakpoint.isEnabled()) {
                                                                if (marker != null) {
-                                                                       int id = fDebugConnection.breakpointSet(newPath.toString(), ((ILineBreakpoint)breakpoint).getLineNumber(), marker.getAttribute(XDebugBreakpoint.HIT_COUNT,-1));
+                                                                       int id = fDebugConnection.breakpointSet (newPath.toString(),
+                                                                                                                ((ILineBreakpoint)breakpoint).getLineNumber(),
+                                                                                                                marker.getAttribute (XDebugBreakpoint.HIT_COUNT, -1),
+                                                                             marker.getAttribute (XDebugBreakpoint.CONDITION_ENABLED, false),
+                                                                                                                marker.getAttribute (XDebugBreakpoint.CONDITION, ""));
                                                                        XDebugResponse dr = getResponse(id);
 
                                                                        String bpid = dr.getAttributeValue("id");
@@ -344,27 +349,8 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                                                }
                                        }
                                }
-                       }
-               } else {
-                       if (supportsBreakpoint(breakpoint)) {
-                               try {
-                                       if (breakpoint.isEnabled()) {
-                                               if (marker != null) {
-                                                       int            id   = fDebugConnection.breakpointSet (path.toString(),
-                                                                                                             ((ILineBreakpoint) breakpoint).getLineNumber(),
-                                                                                                                                                                 marker.getAttribute (XDebugBreakpoint.HIT_COUNT, -1));
-                                                       XDebugResponse dr   = getResponse(id);
-                                                       String         bpid = dr.getAttributeValue("id");
-
-                                                       if (!"".equals(bpid)) {
-                                                               marker.setAttribute(XDebugLineBreakpoint.BREAKPOINT_ID,Integer.parseInt(bpid));
-                                                       }
-                                               }
-                                       }
-                               } catch (DebugException e) {
-                                       e.printStackTrace();
-                               } catch (CoreException e) {
-                                       e.printStackTrace();
+                               else {
+                                   XDebugCorePlugin.log (IStatus.WARNING, "path do not match: local path: " + local.toString () + "   breakpoint file: " + path.toString ());
                                }
                        }
                }
@@ -374,13 +360,14 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
         * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
         */
        public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
+               IMarker marker   = breakpoint.getMarker();                  // Get the breakpoints marker info (It's the local workspace path)
+
                if (supportsBreakpoint(breakpoint)) {
-                       try {
-                               int id =((XDebugLineBreakpoint)breakpoint).getID();
-                               if (id >0)
-                                       fDebugConnection.breakpointRemove(id);
-                       } catch (CoreException e) {
-                       }
+                       int id = marker.getAttribute (XDebugLineBreakpoint.BREAKPOINT_ID, -1);
+
+            if (id > 0) {
+               fDebugConnection.breakpointRemove(id);
+            }
                }
        }
 
@@ -388,16 +375,32 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
         * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta)
         */
        public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {
-//             if (supportsBreakpoint(breakpoint)) {
-//                     try {
-//                             if (breakpoint.isEnabled()) {
-//                                     breakpointAdded(breakpoint);
-//                             } else {
-//                                     breakpointRemoved(breakpoint, null);
-//                             }
-//                     } catch (CoreException e) {
-//                     }
-//             }
+       IMarker oldmarker = breakpoint.getMarker ();
+
+       if (supportsBreakpoint(breakpoint)) {
+                       try {
+                               if (breakpoint.isEnabled ()     &&                                                                      // Check if breakpoint state changed from disabled to enabled
+                                       !delta.getAttribute ("org.eclipse.debug.core.enabled", false)) {
+                                       breakpointAdded (breakpoint);
+                               }
+                               else if (!breakpoint.isEnabled () &&                                                    // Check if breakpoint state changed from enabled to disabled
+                                   delta.getAttribute ("org.eclipse.debug.core.enabled", true)) {
+                                       breakpointRemoved (breakpoint, null);
+                               }
+                               else if (oldmarker.getAttribute (XDebugLineBreakpoint.CHANGE_ID, 1) !=
+                                        delta.getAttribute (XDebugLineBreakpoint.CHANGE_ID, 0)) {
+                                       if (breakpoint.isEnabled ()) {                                                          // If the breakpoint is already enabled
+                                               breakpointRemoved (breakpoint, null);                                   // we remove this breakpoint first
+                                               breakpointAdded (breakpoint);                                                   // and then we add again (else XDebug would have two breakpoints!).
+                                       }
+                                       else {
+                                               breakpointRemoved (breakpoint, null);
+                                       }
+                               }
+                       } catch (CoreException e) {
+                               // Do nothing
+                       }
+               }
        }
 
        /* (non-Javadoc)
@@ -744,7 +747,12 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                                                                                }
                                                                        }
 
-                                                                       if(PHPDebugUtils.unescapeString(filename).endsWith(endfilename)
+                                                                       Path path1 = new Path (PHPDebugUtils.unescapeString (filename));
+                                                                       Path path2 = new Path (endfilename);
+
+                                                                       if (path1.toString ().endsWith (path2.toString ())
+//                                                                     if (strPath1.endsWith (strPath2)
+                                                                       //if(PHPDebugUtils.unescapeString(filename).endsWith(endfilename)
                                                                                        && (lineBreakpoint.getLineNumber() == lineNumber) ) {
                                                                                if (marker.getAttribute(XDebugLineBreakpoint.HIT_COUNT, 0) > 0) {
                                                                                        if (marker.getAttribute(XDebugLineBreakpoint.HIT_COUNT, 0) == hitCount) {