1) Fixed breakpoint with skip count (or hit count).
authorrobekras <robekras>
Tue, 29 Mar 2011 00:46:32 +0000 (00:46 +0000)
committerrobekras <robekras>
Tue, 29 Mar 2011 00:46:32 +0000 (00:46 +0000)
2) Fixed conditional breakpoints.
3) Fixed breakpoint changing within a debugging session.

net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/XDebugConnection.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugBreakpoint.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugLineBreakpoint.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java

index 8fa7006..c5d0dcc 100644 (file)
@@ -150,15 +150,25 @@ public class XDebugConnection {
        }
 
        public /*XDebugResponse*/ int  breakpointSetOld(String file, int lineNumber) {
-               String arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
+               String arg = "-t line -f file://" + PHPDebugUtils.escapeString (file) + " -n " + lineNumber;
                return sendRequest("breakpoint_set", arg);              
        }
        
-       public /*XDebugResponse*/ int  breakpointSet(String file, int lineNumber, int hitCount) {
-               String arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
-               if (hitCount > 0) {
-                       arg += " -h " + hitCount;       
-               }
+       public /*XDebugResponse*/ int  breakpointSet(String file, int lineNumber, int hitCount, boolean bConditional, String condition) {
+           String arg;
+           
+           if (bConditional) {
+               arg  = "-t conditional -f file://" + PHPDebugUtils.escapeString (file) + " -n " + lineNumber;
+            arg += " -- " + Base64.encodeBytes (condition.getBytes ());
+           }
+           else {
+               arg = "-t line -f file://" + PHPDebugUtils.escapeString (file) + " -n " + lineNumber;
+               
+                   if (hitCount > 0) {
+                       arg += " -h " + hitCount;       
+                   }
+           }
+           
                return sendRequest("breakpoint_set", arg);              
        }
        
@@ -169,7 +179,7 @@ public class XDebugConnection {
        }
        
        public /*XDebugResponse*/ int  breakpointRemove(int id) {
-               return sendRequest("breakpoint_set", "-d " + id);
+               return sendRequest("breakpoint_remove", "-d " + id);
        }
 
        public /*XDebugResponse*/ int  stackGet(/*int Level*/) {
index 23aecf7..65e6ede 100644 (file)
@@ -10,7 +10,7 @@
  *******************************************************************************/
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
+
 import java.util.ArrayList;
 //import java.util.Collection;
 import java.util.HashMap;
@@ -72,21 +72,50 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         * (value <code>"org.eclipse.jdt.debug.core.hitCount"</code>). This attribute is stored as an
         * <code>int</code>.
         */
-       protected static final String HIT_COUNT = "net.sourceforge.phpeclipse.xdebug.php.model.hitCount"; //$NON-NLS-1$
+//     protected static final String HIT_COUNT = "net.sourceforge.phpeclipse.xdebug.php.model.hitCount"; //$NON-NLS-1$
+       protected static final String HIT_COUNT = "net.sourceforge.phpeclipse.debug.hitCount";            //$NON-NLS-1$
+
+       /**
+        * Breakpoint attribute storing a breakpoint's changeID. This is used for
+        * checking whether the breakpoint properties menu was finished with a
+        * OK-button. Which means a possible change of breakpoint condition or skip
+        * count. This is necessary because in method breakpointChanged in class
+        * PHPDebugTarget we need to know, whether the breakpoint has changed or not
+        * (breakpointChanged is called also when a PHP source file is modified and
+        * saved).
+        */
+       protected static final String CHANGE_ID = "net.sourceforge.phpeclipse.debug.changeID"; //$NON-NLS-1$
+
+                                                                                                                                                                                                         //
+       /**
+        * Breakpoint attribute storing a breakpoint's condition (value
+        * <code>"net.sourceforge.phpeclipse.debug.condition"</code>). This
+        * attribute is stored as an <code>string</code>.
+        */
+       protected static final String CONDITION = "net.sourceforge.phpeclipse.debug.condition";           //$NON-NLS-1$
+
+       /**
+        * Breakpoint attribute storing whether a breakpoint's condition is enabled
+        * or not (value
+        * <code>"net.sourceforge.phpeclipse.debug.conditionEnabled"</code>).
+        * This attribute is stored as an <code>boolean</code>.
+        */
+       protected static final String CONDITION_ENABLED = "net.sourceforge.phpeclipse.debug.conditionEnabled"; //$NON-NLS-1$
+
        /**
         * Breakpoint attribute storing the number of debug targets a
         * breakpoint is installed in (value <code>"org.eclipse.jdt.debug.core.installCount"</code>).
         * This attribute is a <code>int</code>.
         */
-       protected static final String INSTALL_COUNT = "org.eclipse.jdt.debug.core.installCount"; //$NON-NLS-1$  
-       
+       protected static final String INSTALL_COUNT = "org.eclipse.jdt.debug.core.installCount"; //$NON-NLS-1$
+
        /**
         * Breakpoint attribute storing the fully qualified name of the type
         * this breakpoint is located in.
         * (value <code>"org.eclipse.jdt.debug.core.typeName"</code>). This attribute is a <code>String</code>.
         */
-       protected static final String TYPE_NAME = "org.eclipse.jdt.debug.core.typeName"; //$NON-NLS-1$          
-       
+       protected static final String TYPE_NAME = "org.eclipse.jdt.debug.core.typeName"; //$NON-NLS-1$
+
        /**
         * Stores the collection of requests that this breakpoint has installed in
         * debug targets.
@@ -94,7 +123,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         * value: the requests this breakpoint has installed in that target
         */
        protected HashMap fRequestsByTarget;
-       
+
        /**
         * The list of threads (ThreadReference objects) in which this breakpoint will suspend,
         * associated with the target in which each thread exists (JDIDebugTarget).
@@ -102,49 +131,49 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         * value: thread the filtered thread (IJavaThread) in the given target
         */
        //protected Map fFilteredThreadsByTarget;
-       
+
        /**
         * Stores the type name that this breakpoint was last installed
         * in. When a breakpoint is created, the TYPE_NAME attribute assigned to it
         * is that of its top level enclosing type. When installed, the type
-        * may actually be an inner type. We need to keep track of the type 
+        * may actually be an inner type. We need to keep track of the type
         * type the breakpoint was installed in, in case we need to re-install
         * the breakpoint for HCR (i.e. in case an inner type is HCR'd).
         */
        protected String fInstalledTypeName = null;
-       
+
        /**
         * List of targets in which this breakpoint is installed.
         * Used to prevent firing of more than one install notification
         * when a breakpoint's requests are re-created.
         */
        protected Set fInstalledTargets = null;
-       
+
        /**
         * List of active instance filters for this breakpoint
         * (list of <code>IJavaObject</code>).
         */
        protected List fInstanceFilters = null;
-       
+
        /**
         * Empty instance filters array.
         */
        protected static final /*IJava*/Object[] fgEmptyInstanceFilters = new /*IJava*/Object[0];
-       
+
        /**
         * Property identifier for a breakpoint object on an event request
         */
        public static final String JAVA_BREAKPOINT_PROPERTY = "org.eclipse.jdt.debug.breakpoint"; //$NON-NLS-1$
-       
+
        /**
         * JavaBreakpoint attributes
-        */     
+        */
        protected static final String[] fgExpiredEnabledAttributes= new String[]{EXPIRED, ENABLED};
-       
+
        public XDebugBreakpoint() {
                fRequestsByTarget = new HashMap(1);
                //fFilteredThreadsByTarget= new HashMap(1);
-       }       
+       }
 
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
@@ -172,11 +201,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                } else {
                        setRegistered(false);
                }
-       }       
-       
+       }
+
        /**
-        * Add the given event request to the given debug target. If 
-        * the request is the breakpoint request associated with this 
+        * Add the given event request to the given debug target. If
+        * the request is the breakpoint request associated with this
         * breakpoint, increment the install count.
         */
        /*protected void registerRequest(EventRequest request, XDebugTarget target) throws CoreException {
@@ -192,11 +221,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                // update the install attribute on the breakpoint
                if (!(request instanceof ClassPrepareRequest)) {
                        incrementInstallCount();
-                       // notification 
+                       // notification
                        fireInstalled(target);
                }
        }*/
-       
+
        /**
         * Returns a String corresponding to the reference type
         * name to the top enclosing type in which this breakpoint
@@ -210,8 +239,8 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        return name;
                }
                return name.substring(0, index);
-       }*/     
-               
+       }*/
+
        /**
         * Returns the requests that this breakpoint has installed
         * in the given target.
@@ -223,7 +252,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                }
                return list;
        }
-       
+
        /**
         * Remove the given request from the given target. If the request
         * is the breakpoint request associated with this breakpoint,
@@ -248,13 +277,13 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        return handleClassPrepareEvent((ClassPrepareEvent)event, target);
                }
                ThreadReference threadRef= ((LocatableEvent)event).thread();
-               XDebugThread thread= target.findThread(threadRef);      
+               XDebugThread thread= target.findThread(threadRef);
                if (thread == null || thread.isIgnoringBreakpoints()) {
                        return true;
                }
-               return handleBreakpointEvent(event, target, thread);            
+               return handleBreakpointEvent(event, target, thread);
        }*/
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jdt.internal.debug.core.IJDIEventListener#wonSuspendVote(com.sun.jdi.event.Event, org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget)
         */
@@ -268,7 +297,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                if (threadRef == null) {
                        return;
                }
-               XDebugThread thread= target.findThread(threadRef);      
+               XDebugThread thread= target.findThread(threadRef);
                if (thread == null || thread.isIgnoringBreakpoints()) {
                        return;
                }
@@ -278,27 +307,27 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
        /**
         * Handle the given class prepare event, which was generated by the
         * class prepare event installed in the given target by this breakpoint.
-        * 
+        *
         * If the class which has been loaded is a class in which this breakpoint
         * should install, create a breakpoint request for that class.
-        */     
+        */
        /*public boolean handleClassPrepareEvent(ClassPrepareEvent event, XDebugTarget target) {
                try {
                        if (!installableReferenceType(event.referenceType(), target)) {
                                // Don't install this breakpoint in an
                                // inappropriate type
                                return true;
-                       }                       
+                       }
                        createRequest(target, event.referenceType());
                } catch (CoreException e) {
                        XDebugCorePlugin.log(e);
                }
                return true;
        }*/
-       
+
        /**
         * @see IJDIEventListener#handleEvent(Event, JDIDebugTarget)
-        * 
+        *
         * Handle the given event, which was generated by the breakpoint request
         * installed in the given target by this breakpoint.
         */
@@ -306,19 +335,19 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                expireHitCount(event);
                return !suspend(thread); // Resume if suspend fails
        }*/
-       
+
        /**
         * Delegates to the given thread to suspend, and
         * returns whether the thread suspended
         * It is possible that the thread will not suspend
         * as directed by a Java breakpoint listener.
-        * 
+        *
         * @see IJavaBreakpointListener#breakpointHit(IJavaThread, IJavaBreakpoint)
         */
        /*protected boolean suspend(XDebugThread thread) {
                return thread.handleSuspendForBreakpoint(this, true);
        }*/
-       
+
        /**
         * Returns whether the given reference type is appropriate for this
         * breakpoint to be installed in the given target. Query registered
@@ -346,7 +375,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                }
                return false;
        }*/
-       
+
        /**
         * Called when a breakpoint event is encountered. Expires the
         * hit count in the event's request and updates the marker.
@@ -372,12 +401,12 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        }
                }
        }*/
-       
+
        /**
         * Returns whether this breakpoint should be "skipped". Breakpoints
         * are skipped if the breakpoint manager is disabled and the breakpoint
         * is registered with the manager
-        * 
+        *
         * @return whether this breakpoint should be skipped
         */
        public boolean shouldSkipBreakpoint() throws CoreException {
@@ -388,7 +417,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
        /**
         * Attempts to create a breakpoint request for this breakpoint in the given
         * reference type in the given target.
-        * 
+        *
         * @return Whether a request was created
         */
        /*protected boolean createRequest(XDebugTarget target, ReferenceType type) throws CoreException {
@@ -402,11 +431,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                fInstalledTypeName = type.name();
                for (int i = 0; i < requests.length; i++) {
             EventRequest request = requests[i];
-            registerRequest(request, target);    
+            registerRequest(request, target);
         }
                return true;
        }*/
-       
+
        /**
         * Configure a breakpoint request with common properties:
         * <ul>
@@ -414,7 +443,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         * <li><code>HIT_COUNT</code></li>
         * <li><code>EXPIRED</code></li>
         * </ul>
-        * and sets the suspend policy of the request to suspend 
+        * and sets the suspend policy of the request to suspend
         * the event thread.
         */
        /*protected void configureRequest(EventRequest request, XDebugTarget target) throws CoreException {
@@ -426,16 +455,16 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                // Important: only enable a request after it has been configured
                updateEnabledState(request, target);
        }*/
-       
+
        /**
         * Adds an instance filter to the given request. Since the implementation is
         * request specific, subclasses must override.
-        * 
+        *
         * @param request
         * @param object instance filter
         */
        //protected abstract void addInstanceFilter(EventRequest request, ObjectReference object);
-       
+
        /**
         * Configure the thread filter property of the given request.
         */
@@ -446,7 +475,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                }
                setRequestThreadFilter(request, ((JDIThread)thread).getUnderlyingThread());
        }*/
-       
+
        /**
         * Configure the given request's hit count
         */
@@ -457,7 +486,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        request.putProperty(HIT_COUNT, new Integer(hitCount));
                }
        }*/
-       
+
        /*protected void configureInstanceFilters(EventRequest request, XDebugTarget target) {
                if (fInstanceFilters != null && !fInstanceFilters.isEmpty()) {
                        Iterator iter = fInstanceFilters.iterator();
@@ -468,16 +497,16 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                                }
                        }
                }
-       }*/     
-       
+       }*/
+
        /**
         * Creates, installs, and returns all event requests for this breakpoint
         * in the given reference type and and target.
-        * 
+        *
         * @return the event requests created or <code>null</code> if creation failed
         */
        //protected abstract EventRequest[] newRequests(XDebugTarget target, ReferenceType type) throws CoreException;
-       
+
        /**
         * Add this breakpoint to the given target. After it has been
         * added to the given target, this breakpoint will suspend
@@ -487,7 +516,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                fireAdding(target);
                createRequests(target);
        }*/
-       
+
        /**
         * Creates event requests for the given target
         */
@@ -528,14 +557,14 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
 
                if (!success) {
                        addToTargetForLocalType(target, enclosingTypeName);
-               }               
+               }
        }*/
-       
+
        /**
         * Local types (types defined in methods) are handled specially due to the
-        * different types that the local type is associated with as well as the 
-        * performance problems of using ReferenceType#nestedTypes.  From the Java 
-        * model perspective a local type is defined within a method of a type.  
+        * different types that the local type is associated with as well as the
+        * performance problems of using ReferenceType#nestedTypes.  From the Java
+        * model perspective a local type is defined within a method of a type.
         * Therefore the type of a breakpoint placed in a local type is the type
         * that encloses the method where the local type was defined.
         * The local type is enclosed within the top level type according
@@ -555,16 +584,16 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                                        ReferenceType nestedType= (ReferenceType) nestedTypes.next();
                                        if (createRequest(target, nestedType)) {
                                                break;
-                                       }                               
+                                       }
                                }
                        }
                }
        }*/
-                       
+
        /**
         * Returns the JDI suspend policy that corresponds to this
         * breakpoint's suspend policy
-        * 
+        *
         * @return the JDI suspend policy that corresponds to this
         *  breakpoint's suspend policy
         * @exception CoreException if unable to access this breakpoint's
@@ -579,7 +608,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
        }*/
 
        /**
-        * returns the default suspend policy based on the pref setting on the 
+        * returns the default suspend policy based on the pref setting on the
         * Java-Debug pref page
         * @return the default suspend policy
         * @since 3.2
@@ -588,8 +617,8 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                Preferences store = JDIDebugModel.getPreferences();
                return store.getInt(JDIDebugPlugin.PREF_DEFAULT_BREAKPOINT_SUSPEND_POLICY);
        }*/
-       
-       
+
+
        /**
         * Returns whether the hitCount of this breakpoint is equal to the hitCount of
         * the associated request.
@@ -600,10 +629,10 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                int oldCount = -1;
                if (requestCount != null)  {
                        oldCount = requestCount.intValue();
-               } 
+               }
                return hitCount != oldCount;
        }*/
-       
+
        /**
         * Removes this breakpoint from the given target.
         */
@@ -615,8 +644,8 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                if (!markerExists || (markerExists && getInstallCount() == 0)) {
                        fInstalledTypeName = null;
                }
-               
-               // remove instance filters 
+
+               // remove instance filters
                if (fInstanceFilters != null && !fInstanceFilters.isEmpty()) {
                        for (int i = 0; i < fInstanceFilters.size(); i++) {
                                IJavaObject object = (IJavaObject)fInstanceFilters.get(i);
@@ -626,16 +655,16 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                                }
                        }
                }
-               
+
                // fire change notification if required
                if (changed) {
                        fireChanged();
                }
-               
+
                // notification
                fireRemoved(target);
-       }       */      
-       
+       }       */
+
        /**
         * Remove all requests that this breakpoint has installed in the given
         * debug target.
@@ -655,8 +684,8 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                                if (target.isAvailable() && !isExpired(req)) { // cannot delete an expired request
                                        EventRequestManager manager = target.getEventRequestManager();
                                        if (manager != null) {
-                                               manager.deleteEventRequest(req); // disable & remove 
-                                       }                                       
+                                               manager.deleteEventRequest(req); // disable & remove
+                                       }
                                }
                        } catch (VMDisconnectedException e) {
                                if (target.isAvailable()) {
@@ -670,7 +699,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                }
                fRequestsByTarget.remove(target);
        }*/
-               
+
        /**
         * Update the enabled state of the given request in the given target, which is associated
         * with this breakpoint. Set the enabled state of the request
@@ -679,7 +708,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
        /*protected void updateEnabledState(EventRequest request, XDebugTarget target) throws CoreException  {
                internalUpdateEnabledState(request, isEnabled(), target);
        }*/
-       
+
        /**
         * Set the enabled state of the given request to the given
         * value, also taking into account instance filters.
@@ -699,14 +728,14 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        }
                }
        }*/
-               
+
        /**
         * Returns whether this breakpoint has expired.
         */
        public boolean isExpired() throws CoreException {
                return ensureMarker().getAttribute(EXPIRED, false);
-       }       
-       
+       }
+
        /**
         * Returns whether the given request is expired
         */
@@ -723,23 +752,23 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         */
        public boolean isInstalled() throws CoreException {
                return ensureMarker().getAttribute(INSTALL_COUNT, 0) > 0;
-       }       
-       
+       }
+
        /**
         * Increments the install count of this breakpoint
         */
-       protected void incrementInstallCount() throws CoreException {   
+       protected void incrementInstallCount() throws CoreException {
                int count = getInstallCount();
                setAttribute(INSTALL_COUNT, count + 1);
-       }       
-       
+       }
+
        /**
         * Returns the <code>INSTALL_COUNT</code> attribute of this breakpoint
         * or 0 if the attribute is not set.
         */
        public int getInstallCount() throws CoreException {
                return ensureMarker().getAttribute(INSTALL_COUNT, 0);
-       }       
+       }
 
        /**
         * Decrements the install count of this breakpoint.
@@ -747,7 +776,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
        protected void decrementInstallCount() throws CoreException {
                int count= getInstallCount();
                if (count > 0) {
-                       setAttribute(INSTALL_COUNT, count - 1); 
+                       setAttribute(INSTALL_COUNT, count - 1);
                }
                if (count == 1) {
                        if (isExpired()) {
@@ -757,13 +786,13 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        }
                }
        }
-       
+
        /**
         * Sets the type name in which to install this breakpoint.
         */
        protected void setTypeName(String typeName) throws CoreException {
                setAttribute(TYPE_NAME, typeName);
-       }       
+       }
 
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#getTypeName()
@@ -774,7 +803,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                }
                return fInstalledTypeName;
        }
-       
+
        /**
         * Resets the install count attribute on this breakpoint's marker
         * to "0".  Resets the expired attribute on all breakpoint markers to <code>false</code>.
@@ -806,7 +835,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        String[] strAttributes= new String[attributes.size()];
                        setAttributes((String[])attributes.toArray(strAttributes), values.toArray());
                }
-       }       
+       }
 
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#getHitCount()
@@ -814,11 +843,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
        public int getHitCount() throws CoreException {
                return ensureMarker().getAttribute(HIT_COUNT, -1);
        }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#setHitCount(int)
         */
-       public void setHitCount(int count) throws CoreException {       
+       public void setHitCount(int count) throws CoreException {
                if (getHitCount() != count) {
                        if (!isEnabled() && count > -1) {
                                setAttributes(new String []{ENABLED, HIT_COUNT, EXPIRED},
@@ -830,30 +859,30 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        ///recreate();
                }
        }
-       
+
        protected String getMarkerMessage(int hitCount, int suspendPolicy) {
                StringBuffer buff= new StringBuffer();
                /*if (hitCount > 0){
-                       buff.append(MessageFormat.format(JDIDebugBreakpointMessages.JavaBreakpoint___Hit_Count___0___1, new Object[]{Integer.toString(hitCount)})); 
+                       buff.append(MessageFormat.format(JDIDebugBreakpointMessages.JavaBreakpoint___Hit_Count___0___1, new Object[]{Integer.toString(hitCount)}));
                        buff.append(' ');
                }
                String suspendPolicyString;
                if (suspendPolicy == IJavaBreakpoint.SUSPEND_THREAD) {
-                       suspendPolicyString= JDIDebugBreakpointMessages.JavaBreakpoint__suspend_policy__thread__1; 
+                       suspendPolicyString= JDIDebugBreakpointMessages.JavaBreakpoint__suspend_policy__thread__1;
                } else {
-                       suspendPolicyString= JDIDebugBreakpointMessages.JavaBreakpoint__suspend_policy__VM__2; 
+                       suspendPolicyString= JDIDebugBreakpointMessages.JavaBreakpoint__suspend_policy__VM__2;
                }
-               
+
                buff.append(suspendPolicyString);*/
                return buff.toString();
-       }       
-       
+       }
+
        /**
         * Sets whether this breakpoint's hit count has expired.
         */
        public void setExpired(boolean expired) throws CoreException {
-               setAttribute(EXPIRED, expired); 
-       }       
+               setAttribute(EXPIRED, expired);
+       }
 
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#getSuspendPolicy()
@@ -871,11 +900,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        recreate();
                }
        }*/
-       
+
        /**
         * Notifies listeners this breakpoint is to be added to the
         * given target.
-        * 
+        *
         * @param target debug target
         */
        /*protected void fireAdding(XDebugTarget target) {
@@ -883,11 +912,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         if (plugin != null)
             plugin.fireBreakpointAdding(target, this);
        }*/
-       
+
        /**
         * Notifies listeners this breakpoint has been removed from the
         * given target.
-        * 
+        *
         * @param target debug target
         */
        /*protected void fireRemoved(XDebugTarget target) {
@@ -896,12 +925,12 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
             plugin.fireBreakpointRemoved(target, this);
             setInstalledIn(target, false);
         }
-       }*/     
-       
+       }*/
+
        /**
         * Notifies listeners this breakpoint has been installed in the
         * given target.
-        * 
+        *
         * @param target debug target
         */
        /*protected void fireInstalled(XDebugTarget target) {
@@ -911,20 +940,20 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        setInstalledIn(target, true);
                }
        }       */
-       
+
        /**
         * Returns whether this breakpoint is installed in the given target.
-        * 
+        *
         * @param target
         * @return whether this breakpoint is installed in the given target
         */
        protected boolean isInstalledIn(XDebugTarget target) {
                return fInstalledTargets != null && fInstalledTargets.contains(target);
        }
-       
+
        /**
         * Sets this breakpoint as installed in the given target
-        * 
+        *
         * @param target
         * @param installed whether installed
         */
@@ -940,7 +969,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        }
                }
        }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#setThreadFilter(org.eclipse.jdt.debug.core.IJavaThread)
         */
@@ -951,7 +980,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                JDIDebugTarget target= (JDIDebugTarget)thread.getDebugTarget();
                if (thread != fFilteredThreadsByTarget.put(target, thread) ) {
                        // recreate the breakpoint only if it is not the same thread
-                       
+
                        // Other breakpoints set attributes on the underlying
                        // marker and the marker changes are eventually
                        // propagated to the target. The target then asks the
@@ -963,7 +992,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        fireChanged();
                }
        }*/
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.IDebugEventSetListener#handleDebugEvents(org.eclipse.debug.core.DebugEvent[])
         */
@@ -979,20 +1008,20 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                                        cleanupForThreadTermination((JDIThread)source);
                                } catch (VMDisconnectedException exception) {
                                        // Thread death often occurs at shutdown.
-                                       // A VMDisconnectedException trying to 
+                                       // A VMDisconnectedException trying to
                                        // update the breakpoint request is
                                        // acceptable.
                                }
                        }
                }
        }*/
-       
+
        /**
         * Removes cached information relevant to this thread which has
         * terminated.
-        * 
+        *
         * Remove thread filters for terminated threads
-        * 
+        *
         * Subclasses may override but need to call super.
         */
        /*protected void cleanupForThreadTermination(JDIThread thread) {
@@ -1005,8 +1034,8 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        JDIDebugPlugin.log(exception);
                }
        }*/
-       
-       /** 
+
+       /**
         * EventRequest does not support thread filters, so they
         * can't be set generically here. However, each of the breakpoint
         * subclasses of EventRequest do support thread filters. So
@@ -1014,14 +1043,14 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         * request type.
         */
        //protected abstract void setRequestThreadFilter(EventRequest request, ThreadReference thread);
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#getThreadFilter(org.eclipse.jdt.debug.core.IJavaDebugTarget)
         */
        /*public IJavaThread getThreadFilter(IJavaDebugTarget target) {
                return (IJavaThread)fFilteredThreadsByTarget.get(target);
        }*/
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#getThreadFilters()
         */
@@ -1046,11 +1075,11 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        fireChanged();
                }
        }*/
-       
+
        /**
         * Returns whether this breakpoint should be installed in the given reference
         * type in the given target according to registered breakpoint listeners.
-        * 
+        *
         * @param target debug target
         * @param type reference type or <code>null</code> if this breakpoint is
         *  not installed in a specific type
@@ -1066,7 +1095,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         }
         return false;
        }*/
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.jdt.debug.core.IJavaBreakpoint#addInstanceFilter(org.eclipse.jdt.debug.core.IJavaObject)
         */
@@ -1080,7 +1109,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        fireChanged();
                }
        }
-       
+
        /**
         * Change notification when there are no marker changes. If the marker
         * does not exist, do not fire a change notification (the marker may not
@@ -1088,9 +1117,9 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
         */
        protected void fireChanged() {
         DebugPlugin plugin = DebugPlugin.getDefault();
-               if (plugin != null && markerExists()) { 
+               if (plugin != null && markerExists()) {
             plugin.getBreakpointManager().fireBreakpointChanged(this);
-               }                                       
+               }
        }
 
        /* (non-Javadoc)
@@ -1115,7 +1144,7 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
                        fireChanged();
                }
        }
-       
+
        /**
         * An attribute of this breakpoint has changed - recreate event requests in
         * all targets.
@@ -1141,12 +1170,12 @@ public abstract class XDebugBreakpoint extends Breakpoint implements IXDebugBrea
             }
         }
     }*/
-       
+
        /**
         * Recreate this breakpoint in the given target, as long as the
         * target already contains this breakpoint.
-        * 
-        * @param target the target in which to re-create the breakpoint 
+        *
+        * @param target the target in which to re-create the breakpoint
         */
        /*protected void recreate(XDebugTarget target) throws CoreException {
                if (target.isAvailable() && target.getBreakpoints().contains(this)) {
index 2ee792b..c50b626 100644 (file)
@@ -42,7 +42,7 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
         * this breakpoint is located in.
         * (value <code>"net.sourceforge.phpeclipse.debug.typeName"</code>). This attribute is a <code>String</code>.
         */
-       protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$            
+       protected static final String TYPE_NAME = "net.sourceforge.phpeclipse.debug.typeName"; //$NON-NLS-1$
 
 //     public PHPLineBreakpoint() {
 //     }
@@ -50,22 +50,22 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
 //     public PHPLineBreakpoint(IResource resource, int lineNumber, int charStart, int charEnd, int hitCount, boolean add, Map attributes) throws DebugException {
 //             this(resource, lineNumber, charStart, charEnd, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
 //     }
-//     
+//
 //     public PHPLineBreakpoint(IResource resource, int lineNumber, int hitCount, boolean add, Map attributes) throws DebugException {
 //             this(resource, lineNumber, -1, -1, hitCount, add, attributes, PHP_LINE_BREAKPOINT);
 //     }
 
-       
+
        public static final String BREAKPOINT_ID ="XDebugLineBreakpointID";
-       
+
        public XDebugLineBreakpoint() {
        }
-       
+
        /**
         * Constructs a line breakpoint on the given resource at the given
         * line number. The line number is 1-based (i.e. the first line of a
         * file is line number 1).
-        * 
+        *
         * @param resource file on which to set the breakpoint
         * @param lineNumber 1-based line number of the breakpoint
         * @throws CoreException if unable to create the breakpoint
@@ -73,7 +73,7 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
        public XDebugLineBreakpoint(final IResource resource, final int lineNumber) throws CoreException {
                IWorkspaceRunnable wr = new IWorkspaceRunnable() {
                        public void run(IProgressMonitor monitor) throws CoreException {
-       
+
                                // create the marker
                                setMarker(resource.createMarker(XDEBUG_LINE_BREAKPOINT));
 
@@ -83,15 +83,15 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
 
                                // set attributes
                                ensureMarker().setAttributes(attributes);
-                               
+
                                // add to breakpoint manager if requested
-                               register(true);         
+                               register(true);
                        }
                };
                run(getMarkerRule(resource), wr);
 
        }
-       
+
        protected void register(boolean register) throws CoreException {
                if (register) {
                        DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(this);
@@ -99,7 +99,7 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
                        setRegistered(false);
                }
        }
-       
+
        public void addLineBreakpointAttributes(Map attributes, String modelIdentifier, boolean enabled, int lineNumber, int charStart, int charEnd) {
                attributes.put(IBreakpoint.ID, modelIdentifier);
                attributes.put(IBreakpoint.ENABLED, new Boolean(enabled));
@@ -111,29 +111,33 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
                }
                attributes.put(TYPE_NAME, "typeName");
                attributes.put(BREAKPOINT_ID,new Integer(-1));
-       }               
+       }
+
 
-       
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IBreakpoint#getModelIdentifier()
         */
        public String getModelIdentifier() {
                return IXDebugConstants.ID_PHP_DEBUG_MODEL;
        }
-       
+
        public void setID(int id) throws CoreException {
                ensureMarker().setAttribute(BREAKPOINT_ID,id);
        }
-       
+
        public int getID() throws CoreException {
                return ensureMarker().getAttribute(BREAKPOINT_ID,-1);
        }
-       
+
        public int getHitCount() throws CoreException {
                return ensureMarker().getAttribute(HIT_COUNT,-1);
                //return fHitCount;
        }
 
+       public int getChangeID() throws CoreException {
+               return ensureMarker().getAttribute(CHANGE_ID, 1);
+       }
+
        public void setHitCount(int newHitCount) throws CoreException {
                ensureMarker().setAttribute(HIT_COUNT,newHitCount);
                //fHitCount = newHitCount;
@@ -170,4 +174,4 @@ public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBrea
                }
                return -1;
        }
-}
\ No newline at end of file
+}
index 11bb134..ad0d7a6 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;
 
@@ -329,7 +328,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");
@@ -346,28 +349,6 @@ 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();
-                               }
-                       }
                }
        }
 
@@ -375,13 +356,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);
+            }
                }
        }
 
@@ -389,16 +371,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,12 +742,12 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugE
                                                                                        hitCount = Integer.parseInt(attribute.getNodeValue());
                                                                                }
                                                                        }
-                                                                       
-                                                                       Path path1 = new Path (PHPDebugUtils.unescapeString (filename)); 
+
+                                                                       Path path1 = new Path (PHPDebugUtils.unescapeString (filename));
                                                                        Path path2 = new Path (endfilename);
-       
+
                                                                        if (path1.toString ().endsWith (path2.toString ())
-//                                                                     if (strPath1.endsWith (strPath2)                                                                        
+//                                                                     if (strPath1.endsWith (strPath2)
                                                                        //if(PHPDebugUtils.unescapeString(filename).endsWith(endfilename)
                                                                                        && (lineBreakpoint.getLineNumber() == lineNumber) ) {
                                                                                if (marker.getAttribute(XDebugLineBreakpoint.HIT_COUNT, 0) > 0) {