Change visibility to private for net.sourceforge.phpeclipse.xdebug.php.model.XDebugEl...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / model / XDebugTarget.java
index 9f31828..ee034ec 100644 (file)
@@ -5,10 +5,10 @@ package net.sourceforge.phpeclipse.xdebug.php.model;
 
 import java.util.List;
 
-import net.sourceforge.phpeclipse.xdebug.core.AbstractDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.IDebugConnection;
 import net.sourceforge.phpeclipse.xdebug.core.IPHPDebugEvent;
 import net.sourceforge.phpeclipse.xdebug.core.IProxyEventListener;
+import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants;
+import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 import net.sourceforge.phpeclipse.xdebug.core.PathMapItem;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugProxy;
@@ -24,66 +24,43 @@ import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.IDebugEventSetListener;
 import org.eclipse.debug.core.ILaunch;
 
-import org.eclipse.debug.core.ILaunchListener;
-
 import org.eclipse.debug.core.model.IBreakpoint;
 import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.ILineBreakpoint;
 import org.eclipse.debug.core.model.IMemoryBlock;
 import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
 
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
 
 /**
  * @author Christian
  *
  */
-public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunchListener, IDebugEventSetListener, IProxyEventListener{
-       // associated system process (VM)
+public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugEventSetListener, IProxyEventListener {
        private IProcess fProcess;
        
-       // containing launch object
        private ILaunch fLaunch;
        
-       // debugPort
        private int fDebugPort;
        
-       // suspend state
        private boolean fSuspended = false;
        
-       // terminated state
        private boolean fTerminated = false;
        
-       // threads
        private XDebugThread fThread;
        private IThread[] fThreads;
        
-       private AbstractDebugConnection fDebugConnection;
+       private XDebugConnection fDebugConnection;
 
-       private String fIdeKey;
+       private ResponseListener fResponseListener;
 
+       private String fIdeKey;
 
-       public XDebugTarget() {
-               super(null);
-       }
-
-       /**
-        * Constructs a new debug target in the given launch and waits until
-        * someone with the ideKey connects to the Debugproxy
-        *  
-        * 
-        * @param launch containing launch
-        * @param process process of the interpreter
-        * @param ideKey 
-        * @exception CoreException if unable to connect to host
-        */
-       
-       public XDebugTarget(ILaunch launch, IProcess process, String ideKey) throws CoreException {
-               init(launch, process, ideKey);
-       }
 
        /**
         * Constructs a new debug target in the given launch and waits until
@@ -95,30 +72,19 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         * @param ideKey 
         * @param pathMap Pathmap for the debug session
         * @exception CoreException if unable to connect to host
-        */
-       
-       /*public XDebugTarget(ILaunch launch, IProcess process, String ideKey, List<String> pathMap) throws CoreException {
-               super(null);
-               init(launch, process, ideKey,pathMap);
-       }*/
-       
-       private void init(ILaunch launch, IProcess process, String ideKey/*,List<String> pathMap*/) {
+        */     
+       public XDebugTarget(ILaunch launch, IProcess process, String ideKey) throws CoreException {
                fLaunch = launch;
                fProcess = process;
-               fTarget = this;
                fDebugConnection = null;
                fThread = null;
                fThreads = new IThread[0];
                fIdeKey = ideKey;
                
-               XDebugProxy proxy = XDebugCorePlugin.getDefault().getXDebugProxy();
-               proxy.addProxyEventListener(this,ideKey);
-               if (!proxy.isRunning())
-                       proxy.start();
-               
-               proxy.setTarget(this);
-
-               fDebugPort = proxy.getProxyPort();
+               fDebugPort = XDebugCorePlugin.getDefault().getPreferenceStore().getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE);                
+               if (fDebugPort == 0) {
+                       fDebugPort = IXDebugPreferenceConstants.DEFAULT_DEBUGPORT;
+               }
                
                DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
                DebugPlugin.getDefault().addDebugEventListener(this);
@@ -142,7 +108,7 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         * @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
         */
        public boolean hasThreads() throws DebugException {
-               return (fThreads.length>0);
+               return (fThreads.length > 0);
        }
 
        /* (non-Javadoc)
@@ -197,27 +163,31 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         * @see org.eclipse.debug.core.model.ITerminate#terminate()
         */
        public void terminate() throws DebugException {
-               //IThread  t = fThreads.length();
-               //fTerminated=true;
-               XDebugProxy proxy=XDebugCorePlugin.getDefault().getXDebugProxy();
-               proxy.stop();
-               proxy.removeProxyEventListener(this,fIdeKey);
-               System.out.println("XDebug.Target: ProxyEventlistener removed");
-               fTerminated = true;
-               //fDisconnected = true;
-               fSuspended = false;
-               XDebugCorePlugin.getBreakpointManager().removeBreakpointListener(this);
-               fireTerminateEvent();
-               DebugPlugin.getDefault().removeDebugEventListener(this);
-               if (fThread!=null)
-                       fThread.removeEventListeners();
+               if(fTerminated) {
+                       return;
+               }
+               
+               if (XDebugCorePlugin.getDefault() != null) {
+                       XDebugProxy proxy = XDebugCorePlugin.getDefault().getXDebugProxy();
+                       proxy.removeProxyEventListener(this, fIdeKey);
+                       
+                       System.out.println("XDebug.Target: ProxyEventlistener removed");
+                       
+                       fTerminated = true;
+                       fSuspended = false;
+                       
+                       XDebugCorePlugin.getBreakpointManager().removeBreakpointListener(this);
+                       fThread.fireTerminateEvent();
+                       DebugPlugin.getDefault().removeDebugEventListener(this);
+                       /*if (fThread!=null)
+                               fThread.removeEventListeners();*/
+               }
        }
 
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.ISuspendResume#canResume()
         */
        public boolean canResume() {
-//             return !isTerminated() && isSuspended();
                return false;
        }
 
@@ -225,7 +195,6 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         * @see org.eclipse.debug.core.model.ISuspendResume#canSuspend()
         */
        public boolean canSuspend() {
-//             return !isTerminated() && !isSuspended();
                return false;
        }
 
@@ -242,8 +211,9 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
        public void resume() throws DebugException {
                if (fDebugConnection != null) {
                        fThread.setBreakpoints(null);
+                       resumed(DebugEvent.RESUME);
                        fDebugConnection.run();
-               }                       
+               }               
        }
        
        /**
@@ -287,24 +257,38 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                        e2.printStackTrace();
                }
 
+               if (fDebugConnection != null)
                if (!fDebugConnection.isClosed()) {
                        if (fProcess == null) {
                                PathMapItem pmi = null;
                                for (int i = 0; i < pathMap.size(); i++) {
                                        pmi = new PathMapItem((String) pathMap.get(i));
                                        IPath local = (IPath)pmi.getLocalPath().clone();
-                                       local = local./*removeFirstSegments(1).*/makeAbsolute();
+                                       local = local.makeAbsolute();
                                        int matchedSegments = local.segmentCount();
                                        if (local.matchingFirstSegments(cp) == matchedSegments) {
                                                IPath newPath = pmi.getRemotePath();
-                                               //newPath = newPath.removeFirstSegments(1);                                             
                                                newPath = newPath.append(path.removeFirstSegments(matchedSegments));
                                                newPath = newPath.makeAbsolute();
                                                if (supportsBreakpoint(breakpoint)) {
                                                        try {
-                                                               fDebugConnection.addBreakpoint(breakpoint, newPath);
+                                                               if (breakpoint.isEnabled()) {
+                                                                       if (marker != null) {
+                                                                               //XDebugResponse dr = fDebugConnection.breakpointSet(newPath.toString(), ((ILineBreakpoint)breakpoint).getLineNumber());
+
+                                                                               int id = fDebugConnection.breakpointSet(newPath.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();
                                                        }
                                                }
                                        }
@@ -312,9 +296,20 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                        } else {
                                if (supportsBreakpoint(breakpoint)) {
                                        try {
-                                               fDebugConnection.addBreakpoint(breakpoint, path);
+                                               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();
                                        }
                                }
                        }
@@ -327,7 +322,9 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
        public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
                if (supportsBreakpoint(breakpoint)) {
                        try {
-                               fDebugConnection.removeBreakpoint(breakpoint);
+                               int id =((XDebugLineBreakpoint)breakpoint).getID();
+                               if (id >0)
+                                       fDebugConnection.breakpointRemove(id);
                        } catch (CoreException e) {
                        }
                }
@@ -366,7 +363,8 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         * @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
         */
        public boolean isDisconnected() {
-               return (fDebugConnection==null);
+               return (false);
+//             return (fDebugConnection==null);
        }
 
        /* (non-Javadoc)
@@ -391,26 +389,34 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                fThread.setBreakpoints(null);
                fThread.setStepping(false);
 
-               /*boolean CanDisconnect =*/ Integer.parseInt(fDebugConnection.featureGet("detach").getValue()) /*!= 0*/;
+               int id = fDebugConnection.featureGet("detach");
 
+               XDebugResponse response = getResponse(id);
+
+               Integer.parseInt(response.getValue());
                System.out.println("in Target.started()");
-               DebugResponse response = fDebugConnection.featureGet("max_children");
+               /*XDebugResponse response = fDebugConnection.featureGet("max_children");
                String a1 = response.getValue();
                System.out.println("max children:"+a1);
-               DebugResponse response1 = fDebugConnection.featureGet("max_children");
+               XDebugResponse response1 = fDebugConnection.featureGet("max_children");
                String a2 = response1.getValue();
-               System.out.println("max depth:"+a2);
+               System.out.println("max depth:"+a2);*/
                
                
-               boolean res = fDebugConnection.featureSet("max_depth", "100" );
-               if( res == true ) {
-                       System.out.println("Set depth to 100 (hack)");
+               int id1 = fDebugConnection.featureSet("max_depth", "1024" );
+               XDebugResponse response1 = getResponse(id1);
+               if (response1.getAttributeValue("success").equals("1") ) {
+                       System.out.println("Set depth to 1024 (hack)");
+               }
+               int id2 = fDebugConnection.featureSet("max_children", "1024" );
+               XDebugResponse response2 = getResponse(id2);
+               if (response2.getAttributeValue("success").equals("1") ) {
+                       System.out.println("Set children to 1024 (hack)");
                }
                
                installDeferredBreakpoints();
                try {
                        resume();
-//                     step();
                } catch (DebugException e) {
                        e.printStackTrace();
                }
@@ -428,25 +434,15 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
        }
        
        /**
-        * Called when this debug target terminates.
-        */
-       public void terminated() {
-               fTerminated = true;
-               fSuspended = false;
-               XDebugCorePlugin.getBreakpointManager().removeBreakpointListener(this);
-               fireTerminateEvent();
-               DebugPlugin.getDefault().removeDebugEventListener(this);
-               fThread.removeEventListeners(); 
-       }
-       
-       /**
         * Returns the current stack frames in the target.
         * 
         * @return the current stack frames in the target
         * @throws DebugException if unable to perform the request
         */
-       protected IStackFrame[] getStackFrames() throws DebugException {
-               return fDebugConnection.getStackFrames(fThread);
+       public XDebugResponse getStackFrames() throws DebugException {
+               int id = fDebugConnection.stackGet();
+               XDebugResponse lastResponse = getResponse(id);
+               return lastResponse;
        }
        
        /**
@@ -482,84 +478,120 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                fDebugConnection.stepOut();
        }
        
-       /**
-        * Returns the current value of the given variable.
-        * 
-        * @param variable
-        * @return variable value
-        * @throws DebugException if the request fails
-        */
-       protected IValue getVariableValue(XDebugVariable variable) throws DebugException {
-               return null;
-       }
-       
-       /**
-        * Returns the values on the data stack (top down)
-        * 
-        * @return the values on the data stack (top down)
-        */
-       public IValue[] getDataStack() throws DebugException {
-               return new IValue[0];           
+       public boolean setVarValue(String name, String value) {
+               int id = fDebugConnection.setVarValue(name,value);
+               XDebugResponse response = getResponse(id);
+               
+               if ((response.getAttributeValue("success")).equals("1")) {
+                       return true;
+               } else {
+                       return false;
+               }
        }
        
-       public boolean setVarValue(String name, String value) {
-               return fDebugConnection.setVarValue(name,value);
+       public Node eval(String expression) {
+               int id = fDebugConnection.eval(expression);
+               XDebugResponse response = getResponse(id);
+
+               Node evalResponse = response.getParentNode();
+               Node evalProperty = evalResponse.getFirstChild();
+               
+               return evalProperty;
        }
        
        public void handleDebugEvents(DebugEvent[] events) {
-               for (int i=0;i<events.length;i++) {
-                       DebugEvent event=events[i];
-                       if(event.getKind()==DebugEvent.MODEL_SPECIFIC) {
-                               if (event.getDetail()==IPHPDebugEvent.BREAKPOINT_HIT) {
-                                       IBreakpoint breakpoint = (IBreakpoint) event.getData();
-                                       fThread.setBreakpoints(new IBreakpoint[]{breakpoint});
-                                       fThread.incrementStepCounter();
-                                       suspended(DebugEvent.BREAKPOINT);
-                               } else if (event.getDetail()==IPHPDebugEvent.STEP_END) {
-                                       fThread.incrementStepCounter();
-                                       suspended(DebugEvent.STEP_END);
-                               } else if (event.getDetail()==IPHPDebugEvent.STOPPED) {
-                                       //fDebugConnection.removeBreakpoint(breakpoint);
-                                       fThread.removeEventListeners();
-                                       fThread=null;
-                                       fThreads= new IThread[0];
-                                       fSuspended=false;
-                                       // TODO Dirty hack to check debugging mode (remote or local)
-                                       if (fProcess!=null) {
-                                               try {
-                                                       terminate();
-                                               } catch (DebugException e) {
-                                                       e.printStackTrace();
-                                               }
-                                       } else {
-                                               fDebugConnection = null;
-                                               fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
+               for (int i = 0; i < events.length; i++) {
+                       DebugEvent event = events[i];
+                       
+                       if (fResponseListener != null) {
+                               Object s = null;
+                               s = event.getSource();
+                               if (s instanceof ResponseListener) {
+                                       if (!fResponseListener.equals((ResponseListener) s)) {
+                                               return;
                                        }
-                               } else {
-                                       int a = 20;
-                                       a *= 10;
                                }
                        } else {
-                               int b = 10;
-                               b *= 1;
+                               return;
+                       }
+                       
+                       if (event.getKind() == DebugEvent.MODEL_SPECIFIC) {
+                               switch (event.getDetail()) {
+                                       case IPHPDebugEvent.BREAKPOINT_HIT:
+                                               int id = fDebugConnection.stackGet();
+                                               XDebugResponse lastResponse = getResponse(id);
+
+                                               IBreakpoint breakpoint = breakpointHit(lastResponse.getParentNode());
+                                               
+                                               if (breakpoint != null) {
+                                                       fThread.setBreakpoints(new IBreakpoint[]{breakpoint});
+                                                       fThread.incrementStepCounter();
+                                                       suspended(DebugEvent.BREAKPOINT);
+                                               } else {
+                                                       try {
+                                                               resume();
+                                                       } catch (DebugException e ) {
+                                                               ; //nothing to do
+                                                       }
+                                               }
+                                               break;
+                                       case IPHPDebugEvent.STEP_END:
+                                               fThread.incrementStepCounter();
+                                               suspended(DebugEvent.STEP_END);
+                                               break;
+                                       case IPHPDebugEvent.STOPPED:
+                                               stopped();
+                                               break;
+                               }
                        }
                }
+       }
+       
+       public void stopped() {
+               if(fDebugConnection == null) {
+                       return;
+               }
+
+               resumed(DebugEvent.TERMINATE);
+
+               stopListener();
+               fDebugConnection.close();
+
+/*             fThread.removeEventListeners();
+               fThread = null;
+               fThreads = new IThread[0];*/
                
+/*             stopListener();
+               fDebugConnection.close();*/
+
+               fSuspended = false;
+
+               // Dirty hack to check debugging mode (remote or local)
+               if (fProcess!=null) {
+                       try {
+                               terminate();
+                       } catch (DebugException e) {
+                               e.printStackTrace();
+                       }
+               } else {
+                       fDebugConnection = null;
+                       fThread.fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
+               }
+               
+               fThread.removeEventListeners();
+               fThread = null;
+               fThreads = new IThread[0];
        }
        
-       public void handleProxyEvent(String ideKey, String initString, AbstractDebugConnection connection) {
-               System.out.println("* New Connection - XDebug.Target: "+ideKey);
+       public void handleProxyEvent(/*String ideKey,*/ XDebugConnection connection) {
                setDebugConnection(connection);
+               System.out.println("* New Connection - XDebug.Target: " + fDebugConnection.getSessionID());
                
-               XDebugProxy proxy=XDebugCorePlugin.getDefault().getXDebugProxy();
-               fDebugPort=proxy.getProxyPort();
-               fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
-
+//             fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
                
-//             proxy.removeProxyEventListener(this,ideKey);
-//             System.out.println("XDebug.Target: ProxyEventlistener removed");
                fThread = new XDebugThread(this);
                fThreads = new IThread[] {fThread};
+               fThread.fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CHANGE));
                try {
                        started();
                } catch( DebugException e ){
@@ -567,17 +599,18 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                }               
        }
 
-       private void setDebugConnection(AbstractDebugConnection connection) {
+       private void setDebugConnection(XDebugConnection connection) {
                if (connection != null) {
                        fDebugConnection = connection;
-                       fDebugConnection.startListener();
+                       fResponseListener = new ResponseListener(connection);
+                       startListener();
                }
        }
        
        /**
         * @return Returns the fDebugConnection.
         */
-       public IDebugConnection getDebugConnection() {
+       public XDebugConnection getDebugConnection() {
                return fDebugConnection;
        }       
        
@@ -585,32 +618,97 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                fProcess = p;
 
        }
-
-       public void launchRemoved(ILaunch launch) {
+       public Node getLocalVariables(int level) throws DebugException {
+//             XDebugResponse response = fDebugConnection.contextGet(level, 0);
+               int id = fDebugConnection.contextGet(level, 0);
+               XDebugResponse response = getResponse(id);
+               
+               return response.getParentNode();
        }
+       
+       public Node getGlobalVariables(int level) throws DebugException {
+               //XDebugResponse response = fDebugConnection.contextGet(level, 1);
 
-       /**
-        * Notifies this listener that the specified launch
-        * has been added.
-        * 
-        * @param launch the newly added launch
-        * @since 2.0
-        */
-       public void launchAdded(ILaunch launch){
+               int id = fDebugConnection.contextGet(level, 1);
+               XDebugResponse response = getResponse(id);
+               
+               return response.getParentNode();
        }
-
-       /**
-        * Notifies this listener that the specified launch
-        * has changed. For example, a process or debug target
-        * has been added to the launch.
-        * 
-        * @param launch the changed launch
-        * @since 2.0
-        */
-       public void launchChanged(ILaunch launch) {
+       
+       public void stop() {
+               fDebugConnection.stop();
        }
        
-       public IVariable[] getVariables(XDebugStackFrame StackFrame, int Level) {
-               return fDebugConnection.getVariables(StackFrame, Level);
+       protected IBreakpoint breakpointHit(Node node) {
+               Node child = node.getFirstChild();
+               if (child.getNodeName().equals("stack")) {
+                       int lineNumber = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "lineno"));
+                       String filename = PHPDebugUtils.getAttributeValue(child, "filename");  
+                       IBreakpoint[] breakpoints = XDebugCorePlugin.getBreakpoints();
+                       for (int i = 0; i < breakpoints.length; i++) {
+                               IBreakpoint breakpoint = breakpoints[i];
+                               if (supportsBreakpoint(breakpoint)) {
+                                       if (breakpoint instanceof ILineBreakpoint) {
+                                               ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
+                                               try {                                           
+                                                       if (breakpoint.isEnabled()) {
+                                                               IMarker marker = breakpoint.getMarker();
+                                                               if (marker != null) {
+                                                                       String endfilename;
+                                                                       
+                                                                       if (getProcess() == null) {
+                                                                               endfilename = marker.getResource().getLocation().lastSegment(); 
+                                                                       } else {
+                                                                               endfilename = marker.getResource().getLocation().toOSString();
+                                                                       }
+                                                                       
+                                                                       int id = fDebugConnection.breakpointGet(marker.getAttribute(XDebugLineBreakpoint.BREAKPOINT_ID,-1));
+                                                                       XDebugResponse dr = getResponse(id);
+                                                                       
+                                                                       //String bpid = dr.getAttributeValue("command");                                                                        
+                                                                       Node hitCo = dr.getParentNode().getFirstChild();
+                                                                       int hitCount = 0;
+                                                                       if (hitCo.hasAttributes()) {
+                                                                               NamedNodeMap listAttribute = hitCo.getAttributes();
+                                                                               Node attribute = listAttribute.getNamedItem("hit_count");
+                                                                               if (attribute !=null) {
+                                                                                       hitCount = Integer.parseInt(attribute.getNodeValue());
+                                                                               }
+                                                                       }
+
+                                                                       //String hitCount = hitCo.getAttributeValue("hit_count");                                                                       
+                                                                       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) {
+                                                                                               return (breakpoint);                                                                                            
+                                                                                       }
+                                                                               } else {
+                                                                                       return (breakpoint);
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               } catch (CoreException e) {
+                                               }
+                                       }
+                               }
+                       }
+               }
+               
+               return null;
+       }
+       
+       public void startListener() {
+               fResponseListener.schedule();
+       }
+       
+       public /*boolean*/ void stopListener() {
+               /*return*/ fResponseListener.cancel(); //done(null); //.cancel();
+       }
+       public XDebugResponse getResponse(int id) {
+               XDebugResponse response = fResponseListener.getResponse(id);
+
+               return response;
        }
 }
\ No newline at end of file