Merge xdebug from 1.3.x.
authorincastrix <incastrix>
Wed, 23 Jan 2008 22:44:38 +0000 (22:44 +0000)
committerincastrix <incastrix>
Wed, 23 Jan 2008 22:44:38 +0000 (22:44 +0000)
21 files changed:
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/AbstractDebugConnection.java [deleted file]
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/IDebugConnection.java [deleted file]
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/IProxyEventListener.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/ListenerMap.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/PHPDebugUtils.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugProxy.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/ResponseList.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/xdebug/ResponseListener.java
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/launching/PHPLaunchConfigurationDelegate.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/launching/PHPRemoteLaunchConfigurationDelegate.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/launching/PHPSourceLookupParticipant.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugAbstractValue.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugElement.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/XDebugStackFrame.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugTarget.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugThread.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugVariable.java
net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/php/model/XDebugWatchExpressionDelegate.java

diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/AbstractDebugConnection.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/AbstractDebugConnection.java
deleted file mode 100644 (file)
index e3efc17..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 
- */
-package net.sourceforge.phpeclipse.xdebug.core;
-
-/**
- * @author Christian Perkonig
- *
- */
-public abstract class AbstractDebugConnection implements IDebugConnection {
-       protected boolean fInitialized = false;
-       protected boolean fIsClosed = true;
-       
-       protected String fSessionID = "";
-       
-       public String getSessionID() {
-               return fSessionID;
-       }
-       
-       public boolean isInitialized() {
-               return fInitialized;
-       }
-       
-       public boolean isClosed() {
-               return fIsClosed;
-       }
-}
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/IDebugConnection.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/IDebugConnection.java
deleted file mode 100644 (file)
index 0dfd129..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-package net.sourceforge.phpeclipse.xdebug.core;
-
-import net.sourceforge.phpeclipse.xdebug.php.model.XDebugStackFrame;
-import net.sourceforge.phpeclipse.xdebug.php.model.XDebugThread;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.IStackFrame;
-import org.eclipse.debug.core.model.IVariable;
-
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
-
-public interface IDebugConnection {
-       /**
-        * 
-        * @param featureName 
-        * @return true if debugger supports feature
-        */
-       DebugResponse featureGet(String featureName);
-
-       boolean featureSet(String featureName, String value);
-
-       DebugResponse sendRequestA(String command, String parameter);
-       
-       /**
-        * 
-        * @param breakpoint breakpoint to set
-        * @throws DebugException
-        */
-       void addBreakpoint(IBreakpoint breakpoint, IPath filePath) throws DebugException;
-       
-       /**
-        * 
-        * @param breakpoint breakpoint to remove
-        * @throws DebugException
-        */
-       void removeBreakpoint(IBreakpoint breakpoint) throws DebugException;
-       
-       /**
-        * 
-        * @param thread
-        * @return stackframes
-        * @throws DebugException
-        */
-       IStackFrame[] getStackFrames(XDebugThread thread) throws DebugException;
-       
-       /**
-        * Single stepOver the interpreter.
-        * 
-        * @throws DebugException if the request fails
-        */
-       void stepOver() throws DebugException;
-       
-       /**
-        * Single Stepinto the interpreter.
-        * 
-        * @throws DebugException if the request fails
-        * @throws  
-        */
-       void stepInto() throws DebugException;
-       
-       /**
-        * Single stepOut the interpreter.
-        * 
-        * @throws DebugException if the request fails
-        */
-       void stepOut() throws DebugException;
-       
-       /**
-        * Resume the debug process.
-        * 
-        * @throws DebugException if the request fails
-        */
-       void run() throws DebugException;
-       
-       /**
-        * Stops the debug process.
-        * 
-        * @throws DebugException if the request fails
-        */
-       void stop() throws DebugException;
-       
-       
-       boolean isClosed();
-       
-       /**
-        * 
-        * @param name variable name
-        * @param value value of the variable
-        * @return true if successfull
-        */
-       
-       public boolean setVarValue(String name, String value);
-       
-       boolean isInitialized();
-
-       /**
-        * Get the SessionID of the current Connection.
-        * 
-        * @throws DebugException if the request fails
-        */
-       String getSessionID();
-       
-       void setResponseListerner(Job listener);
-       
-       void startListener();
-       /**
-        * 
-        * @param frame 
-        * @param level context-level
-        * @return the variables for the context
-        */
-       public IVariable[] getVariables(XDebugStackFrame frame ,int level);     
-}
\ No newline at end of file
index c0ca73e..0309767 100644 (file)
@@ -4,6 +4,6 @@ import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
 
 
 public interface IProxyEventListener {
-       public void handleProxyEvent(String ideKey, String initString, /*AbstractDebugConnection*/ XDebugConnection connectin);
+       public void handleProxyEvent(/*String ideKey,*/ /*String initString,*/ XDebugConnection connectin);
 
 }
index 9b51572..6d87cda 100644 (file)
@@ -57,7 +57,7 @@ public class ListenerMap {
                        throw new IllegalArgumentException();
                }
                // check for duplicates using identity
-               if (fListeners.get(ideKey) != null)
+               if (fListeners.get(ideKey) == null)
                        fSize++;
                fListeners.put(ideKey,listener);
        }
index 8b377a7..70093d8 100644 (file)
@@ -7,12 +7,12 @@ import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
 
 public class PHPDebugUtils {
-       public static String getAttributeValue (Node CurrentNode, String AttributeName) {
+       public static String getAttributeValue(Node CurrentNode, String AttributeName) {
                String strValue = "";
                if (CurrentNode.hasAttributes()) {
                        NamedNodeMap listAttribute = CurrentNode.getAttributes();
                        Node attribute = listAttribute.getNamedItem(AttributeName);
-                       if (attribute !=null)
+                       if (attribute != null)
                                strValue = attribute.getNodeValue();
                }
                return strValue;
index f7ca94b..4acc25f 100644 (file)
@@ -79,14 +79,14 @@ public class XDebugCorePlugin extends Plugin {
                return PLUGIN_ID;
        }
        
-       public void setProxyPort(int port) {
+       /*public void setProxyPort(int port) {
                if(fXDebugProxy!=null) {
                        if (fXDebugProxy.isRunning()) {
                                fXDebugProxy.stop();
                        }
                        fXDebugProxy=null;
                }
-       }
+       }*/
 
        public XDebugProxy getXDebugProxy() {
                if (fXDebugProxy == null) {
index 93294b2..26183fb 100644 (file)
@@ -1,35 +1,31 @@
 package net.sourceforge.phpeclipse.xdebug.core;
 
-import java.io.DataInputStream;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.UnknownHostException;
-
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.ISafeRunnable;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
+//import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
-//import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.IDebugEventFilter;
 import org.eclipse.debug.core.IDebugEventSetListener;
+import org.eclipse.jface.util.SafeRunnable;
 
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
 
 public class XDebugProxy {
-       private XDebugTarget fTarget;
-
-       protected String fInitString;
-       protected String fIdeKey;
-
-       /*protected*/ private /*AbstractDebugConnection*/ XDebugConnection fConnection;
-
+       private XDebugConnection fConnection;
+       private ServerSocket fProxyServerSocket;
+       private ProxyListenerJob fProxyListener;
+       private boolean fTerminate;
+       private int fProxyPort;
+       private ListenerMap fEventListeners;
+       private boolean fIsRunning;
+       
        class ProxyListenerJob extends Job {
                public ProxyListenerJob() {
                        super("XDebug Proxy Connection Dispatch");
@@ -42,14 +38,10 @@ public class XDebugProxy {
                protected IStatus run(IProgressMonitor monitor) {
                        boolean error;
                        Socket socket = null;
-                       DataInputStream reader = null;
-                       OutputStreamWriter writer = null;
                        
                        while (!fTerminate) {
                                error = false;
                                socket = null;
-                               reader = null;
-                               writer = null;
                                if (monitor.isCanceled()) return Status.CANCEL_STATUS;
                                try {
                                        socket = fProxyServerSocket.accept();
@@ -59,25 +51,22 @@ public class XDebugProxy {
                                if (!error) {
                                        XDebugCorePlugin.log(IStatus.INFO,"Proxy: someone tries to connect");
                                        
-                                       try {
-                                               writer = new OutputStreamWriter(socket.getOutputStream(), "UTF8");
-                                               reader = new DataInputStream(socket.getInputStream()); 
-                                       } catch (UnsupportedEncodingException e) {
-                                               // TODO Auto-generated catch block
-                                               e.printStackTrace();
-                                       } catch (IOException e) {
-                                               // TODO Auto-generated catch block
-                                               e.printStackTrace();
-                                       }
-                                       fConnection=/*(AbstractDebugConnection)*/ new XDebugConnection(socket,reader,writer);   
+                                       fConnection = new XDebugConnection(socket);     
                                        if (fConnection.isInitialized()) {
-                                               fIdeKey=fConnection.getSessionID();
-                                               XDebugCorePlugin.log(IStatus.INFO,"<init idekey \""+fIdeKey+"\">");
-                                       
-                                               fireProxyEvent();
+                                               String IdeKey = fConnection.getSessionID();
+                                               
+                                               Object a = getEventListener(IdeKey);
+                                               
+                                               if (a instanceof XDebugTarget) {
+                                                       XDebugCorePlugin.log(IStatus.INFO, "<init idekey \"" + IdeKey + "\">");
+                                               
+                                                       fireProxyEvent(IdeKey);
+                                               } else {
+                                                       fConnection.close();
+                                                       fConnection = null;
+                                               }
                                        }
-                               }
-                               
+                               }       
                        }
                        return Status.OK_STATUS;
                }
@@ -103,7 +92,7 @@ public class XDebugProxy {
                 * @see org.eclipse.core.runtime.ISafeRunnable#run()
                 */
                public void run() throws Exception {
-                       fListener.handleProxyEvent(fIdeKey, fInitString, fConnection);
+                       fListener.handleProxyEvent(/*fIdeKey,*/ fConnection);
                }
                
                /**
@@ -112,58 +101,34 @@ public class XDebugProxy {
                 * 
                 * @param events debug events
                 */
-               public void dispatch() {
-                       fListener = (IProxyEventListener) getEventListener(fIdeKey);
-                       if (fListener == null) {     // no listener is found so start the script
-                               //try {
-                                       fConnection.run();
-                               /*} catch (DebugException e) {
-                                       // TODO Auto-generated catch block
-                                       e.printStackTrace();
-                               }*/
-                       } else
-                               Platform.run(this);
+               public void dispatch(String id) {
+                       fListener = (IProxyEventListener) getEventListener(id/*fIdeKey*/);
+                       SafeRunnable.run(this);
+                       //Platform.run(this);
                        fListener = null;
                }
 
        }
 
-
-       private ServerSocket fProxyServerSocket;
-       private ProxyListenerJob fProxyListener;
-       private boolean fTerminate;
-       private int fProxyPort;
-       private ListenerMap fEventListeners;
-       private boolean fIsRunning;
-       
-       
-       public XDebugProxy (int port) {
-               fProxyPort=port;
-       }
-       
-       public void setTarget( XDebugTarget Target ) {
-               fTarget = Target;
-       }
-       
-       public XDebugTarget getTarget() {
-               return fTarget;
+       public XDebugProxy(int port) {
+               fProxyPort = port;
        }
        
        public void start() {
-               if (fIsRunning)
-                       return;
-               try {
-                       fProxyServerSocket = new ServerSocket(fProxyPort);
-                       XDebugCorePlugin.log(IStatus.INFO,"Proxy listens on port "+fProxyPort);
-               } catch (UnknownHostException e) {
-                       e.printStackTrace();
-               } catch (IOException e) {
-                       e.printStackTrace();
+               if (!fIsRunning) {
+                       try {
+                               fProxyServerSocket = new ServerSocket(fProxyPort);
+                               XDebugCorePlugin.log(IStatus.INFO,"Proxy listens on port "+fProxyPort);
+                       } catch (UnknownHostException e) {
+                               e.printStackTrace();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+                       fTerminate = false;
+                       fProxyListener = new ProxyListenerJob();
+                       fProxyListener.schedule();
+                       fIsRunning = true;
                }
-               fTerminate = false;
-               fProxyListener = new ProxyListenerJob();
-               fProxyListener.schedule();
-               fIsRunning = true;
        }
        
        public void stop() {
@@ -202,9 +167,13 @@ public class XDebugProxy {
         *
         * @param listener the listener to remove
         */
-       public void removeProxyEventListener(IProxyEventListener listener,String key) {
+       public void removeProxyEventListener(IProxyEventListener listener, String key) {
                if (fEventListeners != null) {
-                       fEventListeners.remove(listener,key);
+                       //((XDebugTarget)listener).stopped();
+                       fEventListeners.remove(listener, key);
+                       if (fEventListeners.size() == 0) {
+                               stop();
+                       }
                }
        }       
        
@@ -218,9 +187,9 @@ public class XDebugProxy {
         * @see IDebugEventSetListener
         * @since 2.0
         */
-       public void fireProxyEvent() {
+       public void fireProxyEvent(String id) {
                EventNotifier fNotifier = new EventNotifier();
-               fNotifier.dispatch();
+               fNotifier.dispatch(id);
        }
        
        /**
@@ -243,8 +212,4 @@ public class XDebugProxy {
        public int getProxyPort() {
                return fProxyPort;
        }
-
-       public boolean isRunning() {
-               return fIsRunning;
-       }
 }
\ No newline at end of file
index af980d4..ec6def1 100644 (file)
@@ -1,7 +1,8 @@
 package net.sourceforge.phpeclipse.xdebug.core.xdebug;
 
 import java.util.HashMap;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
 
 public class ResponseList {
        int fLastId;
@@ -12,13 +13,13 @@ public class ResponseList {
                fList = new HashMap();
        }
 
-       public synchronized void add(DebugResponse response, int id) {
+       public synchronized void add(XDebugResponse response, int id) {
                fList.put(new Integer(id), response);
                fLastId = id;
                notifyAll();
        }
 
-       public synchronized DebugResponse get(int id) {
+       public synchronized XDebugResponse get(int id) {
                while (id > fLastId) {
                        try {
                                wait();
@@ -27,7 +28,7 @@ public class ResponseList {
                        }
                }
                if (fList.containsKey(new Integer(id)))
-                       return (DebugResponse) fList.remove(new Integer(id));
+                       return (XDebugResponse) fList.remove(new Integer(id));
                else
                        return null;
        }
index 32e9e90..60d0c8b 100644 (file)
@@ -3,32 +3,20 @@ package net.sourceforge.phpeclipse.xdebug.core.xdebug;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+//import javax.print.attribute.standard.Fidelity;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 
 import net.sourceforge.phpeclipse.xdebug.core.IPHPDebugEvent;
 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.php.launching.IXDebugConstants;
-//import net.sourceforge.phpeclipse.xdebug.php.model.XDebugLineBreakpoint;
-//import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
-
-//import org.eclipse.core.runtime.IPath;
-//import org.eclipse.core.runtime.Path;
-
-//import org.eclipse.core.resources.IMarker;
-//import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.debug.core.DebugEvent;
-//import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
-//import org.eclipse.debug.core.model.IBreakpoint;
-//import org.eclipse.debug.core.model.ILineBreakpoint;
 import org.w3c.dom.Document;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
@@ -41,62 +29,105 @@ import org.w3c.dom.CDATASection;
  */
 
 public class ResponseListener extends Job {
-       public class DebugResponse {
+       public class XDebugResponse {
+               final public static String TYPE_INIT = "init";
+               
+               final public static String TYPE_RESPONSE = "response";
+               
+               final public static String TYPE_STREAM = "stream";
+
                private Node parentNode;
-               private int fTransactionID=-1;
-               private String fCommand="";
+               private int fTransactionID = -1;
+               private String fCommand = "";
                private String fStatus;
                private String fReason;
                private String fName;
                private boolean  fError;
-
+       
                private String fValue;
                private String fType;
                private String fAddress;
-               
-               public synchronized void setParentNode (String xmlInput){
+               private String fIdeKey;
+                       
+               public synchronized void setParentNode(String xmlInput) {
                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                       DocumentBuilder builder=null;
-                       Document doc=null;
+                       DocumentBuilder builder = null;
+                       Document doc = null;
+                       
                        try {
                                builder = factory.newDocumentBuilder();
                        } catch (ParserConfigurationException e) {
-                               // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
                        ByteArrayInputStream InputXMLStream = new ByteArrayInputStream(xmlInput.getBytes());
-                       
                        try {
                                doc = builder.parse(InputXMLStream);
                        } catch (SAXException e) {
-                               // TODO Auto-generated catch block
                                e.printStackTrace();
                        } catch (IOException e) {
-                               // TODO Auto-generated catch block
                                e.printStackTrace();
                        }
+       
+                       parentNode = doc.getFirstChild();
                        
-
-                       parentNode=doc.getFirstChild();
+                       String responseType = parentNode.getNodeName();
+                       if (responseType == TYPE_INIT) {
+                               fName = TYPE_INIT;
+                               parseInit(parentNode);
+                       } else if (responseType == TYPE_RESPONSE) {
+                               fName = TYPE_RESPONSE;
+                               parseResponse(parentNode);
+                       } else if (responseType == TYPE_STREAM) {
+                               fName = TYPE_STREAM;
+                               parseStream();
+                       } else {
+                               fName = null;
+                       }
+               }
+               
+               private void parseInit(Node parentNode) {
+                       fIdeKey = getAttributeValue("idekey");
                        
-                       fName=parentNode.getNodeName();
+                       /*int startIdx = initString.indexOf("idekey=\"");
+                       if (startIdx == -1)
+                               return;
+                       startIdx += 8;
+                       int endIdx=initString.indexOf('"',startIdx);
+                       if (endIdx==-1)
+                               return;
+                       fSessionID = initString.substring(startIdx,endIdx);*/
+               }
+               
+               private void parseResponse(Node parentNode) {
                        String idStr = getAttributeValue("transaction_id");
                        if (!"".equals(idStr))
                                fTransactionID = Integer.parseInt(idStr);
                        fCommand = getAttributeValue("command");
+                       if (parentNode.hasChildNodes()) {
+                               Node child = parentNode.getFirstChild();
+                               if (child.getNodeName().equals("error")) {
+                                       int code = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "code"));
+                                       String text = (child.getFirstChild()).getNodeValue();
+                                       XDebugCorePlugin.log(IStatus.ERROR," ERROR "+code+": "+text);
+                                       setError(true);
+                                       return;
+                               }
+                       }
+                       setError(false);
+                       
                        fStatus = getAttributeValue("status");
                        fReason = getAttributeValue("reason");
-
+       
                        if( fCommand.compareTo("eval") == 0 ) {
                                try {
                                        Node property = parentNode.getFirstChild();
-
+       
                                        NamedNodeMap listAttribute = property.getAttributes();
                                        Node attribute = listAttribute.getNamedItem("type");
                                        if (attribute !=null) {
                                                fType = attribute.getNodeValue();
                                        }
-
+       
                                        Node attribute1 = listAttribute.getNamedItem("address");
                                        if (attribute1 !=null) {
                                                fAddress = attribute1.getNodeValue();
@@ -118,11 +149,16 @@ public class ResponseListener extends Job {
                                                fValue = parentNode.getFirstChild().getNodeValue();
                                        }
                                } catch (Exception e) {
-                                       // TODO: handle exception
                                }
                        }
+                       
+               }
+               
+               private void parseStream() {
+                       
                }
                
+               
                public String getAttributeValue (String AttributeName) {
                        String strValue = "";
                        if (parentNode.hasAttributes()) {
@@ -138,6 +174,10 @@ public class ResponseListener extends Job {
                        return parentNode;
                }
                
+               public synchronized String getIdeKey(){
+                       return fIdeKey;
+               }
+               
                public synchronized String getCommand() {
                        return fCommand;
                }
@@ -148,35 +188,27 @@ public class ResponseListener extends Job {
                public synchronized String getValue() {
                        return fValue;
                }
-
+       
                public synchronized String getType() {
                        return fType;
                }
-
+       
                public synchronized String getAddress() {
                        return fAddress;
                }
-
-               DebugResponse() {
-                       fTransactionID = -1;
-                       fCommand = "";
-                       fStatus = "";
-                       fReason = "";                   
-                       fName= "";
-               }
-               
-               DebugResponse(String XMLInput) {
+       
+               public XDebugResponse(String XMLInput) {
                        setParentNode(XMLInput);
                }
-
+       
                public synchronized String getReason() {
                        return fReason;
                }
-
+       
                public synchronized String getStatus() {
                        return fStatus;
                }
-
+       
                public synchronized int getTransactionID() {
                        return fTransactionID;
                }
@@ -184,26 +216,35 @@ public class ResponseListener extends Job {
                public boolean  isError() {
                        return fError;
                }
-
+       
                public void setError(boolean error) {
                        fError = error;
-               }       
+               }
+               
+               XDebugResponse() {
+                       fTransactionID = -1;
+                       fCommand = "";
+                       fStatus = "";
+                       fReason = "";                   
+                       fName= "";
+               }
        }
-
+       
        private XDebugConnection fConnection;
-       private DebugResponse lastResponse; 
+       private XDebugResponse lastResponse; 
 
        public ResponseListener(XDebugConnection connection) {
                super("XDebug Event Dispatch");
                setSystem(true);
-               fConnection=connection;
-               lastResponse= new DebugResponse();
+               fConnection = connection;
+               lastResponse = new XDebugResponse();
+               fResponseList = new ResponseList();
        }
                
-       private void checkResponse(DebugResponse response) {
-               Node node=response.getParentNode();
+       private void checkResponse(XDebugResponse response) {
+               Node node = response.getParentNode();
                if (node.hasChildNodes()) {
-                       Node child=node.getFirstChild();
+                       Node child = node.getFirstChild();
                        if (child.getNodeName().equals("error")) {
                                int code = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "code"));
                                String text=(child.getFirstChild()).getNodeValue();
@@ -214,7 +255,7 @@ public class ResponseListener extends Job {
                }
                lastResponse.setError(false);
                if (response.getStatus().equals("stopping")) {
-                       //this.cancel();
+                       this.cancel();
                        fireEvent(IPHPDebugEvent.STOPPED);
                } else if (response.getStatus().equals("break") && response.getReason().equals("ok")){ 
                        if (response.getCommand().equals("run")) {
@@ -246,16 +287,33 @@ public class ResponseListener extends Job {
        protected IStatus run(IProgressMonitor monitor) {
                String InputXML = "";
                while (!fConnection.isClosed() && (InputXML != null)) {
-                       InputXML = fConnection.readData();
-                       if (InputXML != null) {
-                               XDebugCorePlugin.log(IStatus.INFO, InputXML);
-                               lastResponse.setParentNode(InputXML);
-                               if (lastResponse.getName() == "response") {
-                                       fConnection.addResponse(lastResponse,lastResponse.getTransactionID());
-                                       checkResponse(lastResponse);
+                       if (!monitor.isCanceled()) {
+                               try {
+                               if(!fConnection.isClosed()) {
+                                       InputXML = fConnection.readData();
+                               }
+                               } catch (Exception e) {
+                                       ; //
+                               }
+                               if (InputXML != null) {
+                                       XDebugCorePlugin.log(IStatus.INFO, InputXML);
+                                       lastResponse.setParentNode(InputXML);
+                                       if (lastResponse.getName() == "response") {
+                                               addResponse(lastResponse, lastResponse.getTransactionID());
+                                               checkResponse(lastResponse);
+                                       }
                                }
                        }
                }
                return Status.OK_STATUS;
        }
+       private ResponseList fResponseList;
+       
+       protected void addResponse(XDebugResponse response, int id) {
+               fResponseList.add(response, id);
+       }
+       
+       public XDebugResponse getResponse(int id) {
+               return fResponseList.get(id);
+       }
 }
\ No newline at end of file
index 415a808..24fedd1 100644 (file)
@@ -7,12 +7,14 @@ import java.io.DataInputStream;
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
 import java.net.Socket;
 
 import net.sourceforge.phpeclipse.xdebug.core.Base64;
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+
 import org.eclipse.core.runtime.IStatus;
 
 /**
@@ -20,12 +22,10 @@ import org.eclipse.core.runtime.IStatus;
  *
  */
 public class XDebugConnection {
-       int fTransactionID = 0;
+       private int fTransactionID = 0;
        private Socket fDebugSocket;
        private OutputStreamWriter fDebugWriter;
        private DataInputStream fDebugReader;
-       private ResponseList fResponseList;
-       private ResponseListener fResponseListener;
 
        protected boolean fInitialized = false;
        protected boolean fIsClosed = true;
@@ -44,13 +44,21 @@ public class XDebugConnection {
                return fIsClosed;
        }
 
-       public XDebugConnection(Socket debugSocket, DataInputStream reader, OutputStreamWriter writer) {
-               fResponseList = new ResponseList();
-               fDebugWriter = writer;
-               fDebugReader = reader;
+       public XDebugConnection(Socket debugSocket) {
                fDebugSocket = debugSocket;
                fTransactionID = 0;
                fInitialized = false;
+               try {
+                       fDebugWriter = new OutputStreamWriter(debugSocket.getOutputStream(), "UTF8");
+                       fDebugReader = new DataInputStream(debugSocket.getInputStream()); 
+               } catch (UnsupportedEncodingException e) {
+                       e.printStackTrace();
+               } catch (IOException e) {
+                       e.printStackTrace();
+               }
+
+               fIsClosed = false;
+
                String initString = readData();
                XDebugCorePlugin.log(IStatus.INFO,initString);
 
@@ -62,20 +70,19 @@ public class XDebugConnection {
                if (endIdx==-1)
                        return;
                fSessionID = initString.substring(startIdx,endIdx);
-               
                fInitialized = true;
-               fIsClosed = false;
-               fResponseListener = new ResponseListener(this);
        }
        
        protected String readData()     {
+               if (fIsClosed)
+                       return null;
+               
         byte byteBuffer[]=null,b;
                int count=0;
                
                try {
                        while ((b =fDebugReader.readByte()) != 0) {
                                count = count * 10 + b - '0';
-//                             count=count*10+Integer.parseInt(b);
                        }
                        byteBuffer = new byte[count];
                        int readCount=0;
@@ -95,22 +102,24 @@ public class XDebugConnection {
                        if((b= fDebugReader.readByte())!=0) // reads the NULL Byte at the end;
                                System.out.println("NULL-Byte missing!!"); 
                } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       if (e instanceof EOFException==false)
-                               e.printStackTrace();
+                       if (e instanceof EOFException == false) {
+                               if (!fIsClosed) {
+                                       e.printStackTrace();
+                               }
+                       }
                        return null;
                }
                return new String(byteBuffer);
        }
        
-       public DebugResponse sendRequest(String command, String arguments) {
+       private /*XDebugResponse*/ int sendRequest(String command, String arguments) {
                int id = -1;
                
                id = _sendRequest(command, arguments);
 
-               DebugResponse response = getResponse(id);
+               //XDebugResponse response = getResponse(id);
 
-               return response;
+               return /*response*/ id;
        }
 
        private synchronized int _sendRequest(String command, String arguments) {
@@ -131,46 +140,67 @@ public class XDebugConnection {
                return fTransactionID++;
        }
 
-       public DebugResponse eval(String Expression) {
+       public /*XDebugResponse*/ int eval(String Expression) {
                String encoded = Base64.encodeBytes(Expression.getBytes());
                
                return sendRequest("eval", "-- "+encoded);
        }
 
-       public DebugResponse featureGet(String featureName) {
+       public /*XDebugResponse*/ int featureGet(String featureName) {
                return sendRequest("feature_get","-n "+featureName);
        }
 
-       public boolean featureSet(String featureName, String value) {
-               DebugResponse id = sendRequest("feature_set","-n "+featureName + " -v " + value);
+       public /*boolean*/ int  featureSet(String featureName, String value) {
+               //XDebugResponse id = sendRequest("feature_set","-n "+featureName + " -v " + value);
+
+               int id = sendRequest("feature_set","-n "+featureName + " -v " + value);
+               
+               return id;
+               /*XDebugResponse response = getResponse(id);
 
-               if (id.getAttributeValue("success").equals("1") )
+               if (response.getAttributeValue("success").equals("1") )
                        return true;
                else
-                       return false;
+                       return false;*/
        }
 
-       protected DebugResponse getResponse(int id) {
+       /*protected XDebugResponse getResponse(int id) {
                return fResponseList.get(id);
        }
 
-       protected void addResponse(DebugResponse response, int id) {
+       protected void addResponse(XDebugResponse response, int id) {
                fResponseList.add(response, id);
-       }
+       }*/
        
+       public /*XDebugResponse*/ int  breakpointSetOld(String file, int lineNumber) {
+               String arg;
+               
+               arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
+               return sendRequest("breakpoint_set", arg);              
+       }
        
-       public DebugResponse breakpointSet(String file, int lineNumber) {
+       public /*XDebugResponse*/ int  breakpointSet(String file, int lineNumber, int hitCount) {
                String arg;
                
                arg = "-t line -f file://"+PHPDebugUtils.escapeString(file)+" -n " + lineNumber;
+               if (hitCount > 0) {
+                       arg += " -h " + hitCount;       
+               }
                return sendRequest("breakpoint_set", arg);              
        }
        
-       public DebugResponse breakpointRemove(int id) {
+       public int  breakpointGet(int id) {
+               String arg;
+               
+               arg = "-d " + id;
+               return sendRequest("breakpoint_get", arg);              
+       }
+       
+       public /*XDebugResponse*/ int  breakpointRemove(int id) {
                return sendRequest("breakpoint_set", "-d " + id);
        }
 
-       public DebugResponse stackGet(int Level) {
+       public /*XDebugResponse*/ int  stackGet(/*int Level*/) {
                /*if (Level > -1) {
                        return sendRequest("stack_get", "-d " + Level);
                } else {*/
@@ -198,42 +228,53 @@ public class XDebugConnection {
                sendRequest("stop", "");
        }
 
-       public void startListener() {
-               fResponseListener.schedule();
-       }
-       
-       public DebugResponse propertySet(String Name, String Value) {
+       public /*XDebugResponse*/ int  propertySet(String Name, String Value) {
                String str = Base64.encodeBytes(Value.getBytes());
                int len = str.length();
 
                return sendRequest("property_set", "-n " + Name + " -l " + len + " -- " + str);
        }
 
-       public boolean setVarValue(String Name, String Value) {
-               DebugResponse dr = propertySet(Name, Value);
+       public /*XDebugResponse*/ int  contextGet(int Level, int Type) {
+               return sendRequest("context_get", "-d " + Level + " -c " + Type);
+       }
 
-               if ((dr.getAttributeValue("success")).equals("1"))
+       public /*boolean*/int setVarValue(String Name, String Value) {
+               //XDebugResponse dr = propertySet(Name, Value);
+
+               int id = propertySet(Name, Value);
+               //XDebugResponse response = getResponse(id);
+               return id;
+               
+               /*if ((response.getAttributeValue("success")).equals("1"))
                        return true;
                
-               return false;
+               return false;*/
        }
        
-       public void close() {
-               fIsClosed = true;
-               //fResponseListener.cancel();
-               //fResponseListener = null;
-               try {
-                       fDebugReader.close();           
-                       fDebugWriter.close();
-                       fDebugSocket.close();
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
-               fResponseListener.cancel();
-               fIsClosed=true;
+       /*public void startListener() {
+               fResponseListener.schedule();
        }
        
-       public DebugResponse contextGet(int Level, int Type) {
-               return sendRequest("context_get", "-d " + Level + " -c " + Type);
-       }
+       public boolean stopListener() {
+               return fResponseListener.cancel();
+       }*/
+       
+       public void close() {
+               if (!fIsClosed) {
+                       fIsClosed = true;
+                       //fResponseListener.cancel();
+                       //fResponseListener = null;
+                       try {
+                               fDebugSocket.close();
+                               fDebugReader.close();
+                               fDebugReader = null;
+                               fDebugWriter.close();
+                       } catch (IOException e) {
+                               e.printStackTrace();
+                       }
+               }
+               //fResponseListener.cancel();
+               //fIsClosed=true;
+       }       
 }
\ No newline at end of file
index 23f538e..a47326f 100644 (file)
@@ -19,8 +19,10 @@ import java.util.List;
 import java.util.Map;
 
 import net.sourceforge.phpeclipse.externaltools.ExternalToolsPlugin;
+import net.sourceforge.phpeclipse.xdebug.core.IProxyEventListener;
 import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
+import net.sourceforge.phpeclipse.xdebug.core.XDebugProxy;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
 
 import org.eclipse.core.resources.IFile;
@@ -34,13 +36,13 @@ import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.debug.core.model.IDebugTarget;
+//import org.eclipse.debug.core.model.IDebugTarget;
 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
 import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
 
 
-public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate implements ILaunchConfigurationDelegate{
+public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
        
        /**
         * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor)
@@ -79,7 +81,7 @@ public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate
                        abort(MessageFormat.format("PHP-Script {0} does not exist.", new String[] {file.getFullPath().toString()}), null);
                }
                
-               commandList.add(file.getFullPath().toOSString());
+               commandList.add(file.getLocation().toOSString());
 
                // Get the Debugport  from the preferences
                int debugPort=XDebugCorePlugin.getDefault().getPreferenceStore().getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE);
@@ -112,10 +114,15 @@ public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate
                
                String[] commandLine = (String[]) commandList.toArray(new String[commandList.size()]);
 
-               XDebugTarget target=null;
+               XDebugProxy proxy = XDebugCorePlugin.getDefault().getXDebugProxy();
+               proxy.start();
+               
+               XDebugTarget target = null;
                if (mode.equals(ILaunchManager.DEBUG_MODE)) {
                        target = new XDebugTarget(launch, null, idekey);
+                       proxy.addProxyEventListener((IProxyEventListener) target, idekey);
                }
+
                Process process = DebugPlugin.exec(commandLine, null,envp);
                IProcess p = DebugPlugin.newProcess(launch, process, phpInterpreter);
        
index e0173f6..c003bcc 100644 (file)
@@ -1,5 +1,6 @@
 package net.sourceforge.phpeclipse.xdebug.php.launching;
 
+import net.sourceforge.phpeclipse.xdebug.core.IProxyEventListener;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
 import net.sourceforge.phpeclipse.xdebug.core.XDebugProxy;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
@@ -14,10 +15,10 @@ import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+//import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
 
-public class PHPRemoteLaunchConfigurationDelegate extends LaunchConfigurationDelegate  {
+public class PHPRemoteLaunchConfigurationDelegate extends LaunchConfigurationDelegate /*implements ILaunchConfigurationDelegate*/ {
        public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
                String projectName = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null);
                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
@@ -32,6 +33,7 @@ public class PHPRemoteLaunchConfigurationDelegate extends LaunchConfigurationDel
 
                if (mode.equals(ILaunchManager.DEBUG_MODE)) {
                        IDebugTarget target = new XDebugTarget(launch, null, ideID);
+                       proxy.addProxyEventListener((IProxyEventListener) target, ideID);
                        launch.addDebugTarget(target);
                }
        }
index 5e8b521..aa6bed2 100644 (file)
@@ -68,8 +68,8 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                        for (int k = 0; k < pathMap.size(); k++) {
                                pmi = new PathMapItem((String) pathMap.get(k));
        
-                               IPath local = new Path(pmi.getLocalPath().toString())/* .removeFirstSegments(1) */;
-                               IPath remote = new Path(pmi.getRemotePath().toString())/* .removeFirstSegments(1) */;
+                               IPath local = new Path(pmi.getLocalPath().toString());
+                               IPath remote = new Path(pmi.getRemotePath().toString());
        
                                if (remote.matchingFirstSegments(sPath) == remote.segmentCount()) {
                                        sLocalPath = local;
@@ -116,7 +116,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                                        multiStatus = new MultiStatus(DebugPlugin
                                                        .getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR,
                                                        new IStatus[] { single.getStatus() },
-                                                       SourceLookupMessages.DefaultSourceContainer_0,
+                                                       SourceLookupMessages.DefaultSourceContainer_0/*CompositeSourceContainer_0*/,
                                                        null);
                                        multiStatus.add(e.getStatus());
                                } else {
@@ -145,7 +145,7 @@ public class PHPSourceLookupParticipant extends AbstractSourceLookupParticipant
                        }
                        IFile file = (IFile) objects[j];
 
-                       IPath path = new Path(file.getFullPath().toString());
+                       IPath path = new Path(file.getLocation().toString());
                        if (localPath.matchingFirstSegments(path) == localPath
                                        .segmentCount()) {
                                results.add(objects[j]);
index 37494f7..f60537c 100644 (file)
@@ -243,7 +243,7 @@ public abstract class XDebugAbstractValue  extends XDebugElement implements IVal
                                                                        fhasChanged = true;
                                                                }
                                                        } catch (Exception e) {
-                                                               int b = 1;
+                                                               //int b = 1;
                                                        }
                                                }
                                                if (fhasChanged) {
@@ -252,7 +252,7 @@ public abstract class XDebugAbstractValue  extends XDebugElement implements IVal
                                                                try {
                                                                        fVariables[i].setValue(newVariable[i].getValue());
                                                                } catch (Exception e) {
-                                                                       int b = 1;
+                                                                       //int b = 1;
                                                                }
                                                        }
                                                }
index b103f17..61ba588 100644 (file)
@@ -7,6 +7,7 @@ package net.sourceforge.phpeclipse.xdebug.php.model;
 
 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
 
+//import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.PlatformObject;
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
@@ -14,13 +15,14 @@ import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IDebugElement;
 import org.eclipse.debug.core.model.IDebugTarget;
+//import org.eclipse.debug.core.model.IVariable;
 
 /**
  * @author Christian
  *
  */
 public class XDebugElement extends PlatformObject implements IDebugElement {
-       
+               
        // containing target 
        protected XDebugTarget fTarget;
        
@@ -119,7 +121,5 @@ public class XDebugElement extends PlatformObject implements IDebugElement {
         */
        protected void fireTerminateEvent() {
                fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
-       }
-       
-
+       }       
 }
\ No newline at end of file
index a626e8c..2ee792b 100644 (file)
@@ -1,9 +1,5 @@
-
 /*
  * Created on 25.11.2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Style - Code Templates
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
@@ -19,8 +15,10 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.debug.core.DebugPlugin;
+//import org.eclipse.debug.core.model.Breakpoint;
 import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.core.model.LineBreakpoint;
+import org.eclipse.debug.core.model.ILineBreakpoint;
+//import org.eclipse.debug.core.model.LineBreakpoint;
 
 
 /**
@@ -29,8 +27,8 @@ import org.eclipse.debug.core.model.LineBreakpoint;
  * TODO To change the template for this generated type comment go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
-public class XDebugLineBreakpoint  extends LineBreakpoint {
-       
+public class XDebugLineBreakpoint  extends XDebugBreakpoint implements ILineBreakpoint /*extends LineBreakpoint*/ {
+
        /**
         * Default constructor is required for the breakpoint manager
         * to re-create persisted breakpoints. After instantiating a breakpoint,
@@ -73,14 +71,7 @@ public class XDebugLineBreakpoint  extends LineBreakpoint {
         * @throws CoreException if unable to create the breakpoint
         */
        public XDebugLineBreakpoint(final IResource resource, final int lineNumber) throws CoreException {
-//             IMarker marker = resource.createMarker("net.sourceforge.phpeclipse.xdebug.core.XDebugLineBreakpoint");
-//             setMarker(marker);
-//             setEnabled(true);
-//             XDebugCorePlugin.log(IStatus.INFO,"Markertype: "+ marker.getType());
-//             ensureMarker().setAttribute(IMarker.LINE_NUMBER, lineNumber);
-//             ensureMarker().setAttribute(IBreakpoint.ID, IXDebugConstants.ID_PHP_DEBUG_MODEL);
-//             ensureMarker().setAttribute(BREAKPOINT_ID,-1);
-               IWorkspaceRunnable wr= new IWorkspaceRunnable() {
+               IWorkspaceRunnable wr = new IWorkspaceRunnable() {
                        public void run(IProgressMonitor monitor) throws CoreException {
        
                                // create the marker
@@ -130,12 +121,53 @@ public class XDebugLineBreakpoint  extends LineBreakpoint {
                return IXDebugConstants.ID_PHP_DEBUG_MODEL;
        }
        
-       public void setID(int id) throws CoreException
-       {
+       public void setID(int id) throws CoreException {
                ensureMarker().setAttribute(BREAKPOINT_ID,id);
        }
-       public int getID() throws CoreException
-       {
+       
+       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 void setHitCount(int newHitCount) throws CoreException {
+               ensureMarker().setAttribute(HIT_COUNT,newHitCount);
+               //fHitCount = newHitCount;
+       }
+       /**
+        * @see ILineBreakpoint#getLineNumber()
+        */
+       public int getLineNumber() throws CoreException {
+               IMarker m = getMarker();
+               if (m != null) {
+                       return m.getAttribute(IMarker.LINE_NUMBER, -1);
+               }
+               return -1;
+       }
+
+       /**
+        * @see ILineBreakpoint#getCharStart()
+        */
+       public int getCharStart() throws CoreException {
+               IMarker m = getMarker();
+               if (m != null) {
+                       return m.getAttribute(IMarker.CHAR_START, -1);
+               }
+               return -1;
+       }
+
+       /**
+        * @see ILineBreakpoint#getCharEnd()
+        */
+       public int getCharEnd() throws CoreException {
+               IMarker m = getMarker();
+               if (m != null) {
+                       return m.getAttribute(IMarker.CHAR_END, -1);
+               }
+               return -1;
+       }
+}
\ No newline at end of file
index 1bc38bb..5fbece5 100644 (file)
@@ -6,17 +6,22 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
-//import java.net.MalformedURLException;
 import java.net.URL;
 
+//import net.sourceforge.phpeclipse.xdebug.core.Base64;
+//import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
+//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IRegisterGroup;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
 import org.eclipse.debug.core.model.IVariable;
-//import net.sourceforge.phpeclipse.xdebug.core.IDebugConnection;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * @author PHPeclipse team
@@ -28,8 +33,6 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
 
        private int fId;
        
-       //private IPath fName;
-       
        private URL fName;
        
        private int fLineNumber;
@@ -40,7 +43,6 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
        private IVariable[] fVariables;
 
        private int fStepCount = 0;
-       //private int fCurrentStepCount = 0;
        
        /**
         * Constructs a stack frame in the given thread with the given
@@ -69,18 +71,40 @@ public class XDebugStackFrame  extends XDebugElement implements IStackFrame {
        
        public IVariable[] getVariables() throws DebugException {
                if (fVariables == null) {
-                       fVariables = fTarget.getVariables(this, fLevel);
+                       Node dfl = fTarget.getLocalVariables(fLevel);
+                       Node dfg = fTarget.getGlobalVariables(fLevel);
+                       parseVariable(dfl, dfg);
                }
 
                return fVariables;
        }
        
-       public void evaluateChange(IStackFrame OldStackFrame) throws DebugException {
+       private void parseVariable(Node localVariables, Node globalVariables) {
+               NodeList property = localVariables.getChildNodes();
+               
+               NodeList propertyGlobal = globalVariables.getChildNodes();
+               
+               fVariables = new IVariable[property.getLength() + propertyGlobal.getLength()];
+               
+               int length = property.getLength();
+               for (int i = 0; i < length; i++) {
+                       XDebugVariable var = new XDebugVariable(this, property.item(i));
+                       fVariables[i] = var;
+               }
+
+               int globalLength = propertyGlobal.getLength();
+               for (int k = 0; k < globalLength; k++) {
+                       XDebugVariable var = new XDebugVariable(this, propertyGlobal.item(k));
+                       fVariables[k + length] = var;
+               }
+       }
+       
+       /*public void evaluateChange(IStackFrame OldStackFrame) throws DebugException {
                IVariable[] OldVariable = ((XDebugStackFrame) OldStackFrame).getVariables();
                for (int i = 0; i < fVariables.length; i++) {
                        ((XDebugVariable) fVariables[i]).setChange(OldVariable[i]);
                }
-       }
+       }*/
        
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IStackFrame#hasVariables()
index 339cf1b..ec0ca16 100644 (file)
@@ -3,13 +3,11 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.List;
 
-import net.sourceforge.phpeclipse.xdebug.core.Base64;
 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;
@@ -26,28 +24,24 @@ 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 org.w3c.dom.NodeList;
 
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener;
 import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
 
 /**
  * @author Christian
  *
  */
-public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunchListener, IDebugEventSetListener, IProxyEventListener {
+public class XDebugTarget extends XDebugElement implements IDebugTarget, IDebugEventSetListener, IProxyEventListener {
        private IProcess fProcess;
        
        private ILaunch fLaunch;
@@ -63,6 +57,8 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
        
        private XDebugConnection fDebugConnection;
 
+       private ResponseListener fResponseListener;
+
        private String fIdeKey;
 
 
@@ -80,20 +76,15 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
        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);
@@ -117,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)
@@ -172,18 +163,25 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         * @see org.eclipse.debug.core.model.ITerminate#terminate()
         */
        public void terminate() throws DebugException {
-               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);
+                       fireTerminateEvent();
+                       DebugPlugin.getDefault().removeDebugEventListener(this);
+                       /*if (fThread!=null)
+                               fThread.removeEventListeners();*/
+               }
        }
 
        /* (non-Javadoc)
@@ -248,7 +246,7 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
         */
        public void breakpointAdded(IBreakpoint breakpoint) {
                IMarker marker = breakpoint.getMarker();
-               IPath path = marker.getResource().getFullPath();
+               IPath path = marker.getResource().getLocation();
                IPath cp = path.removeLastSegments(1);
                List pathMap = null;
                try {
@@ -258,6 +256,7 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                        e2.printStackTrace();
                }
 
+               if (fDebugConnection != null)
                if (!fDebugConnection.isClosed()) {
                        if (fProcess == null) {
                                PathMapItem pmi = null;
@@ -274,8 +273,11 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                                                        try {
                                                                if (breakpoint.isEnabled()) {
                                                                        if (marker != null) {
-                                                                               //fDebugConnection.addBreakpoint(breakpoint, newPath);
-                                                                               DebugResponse dr = fDebugConnection.breakpointSet(newPath.toString(), ((ILineBreakpoint)breakpoint).getLineNumber());
+                                                                               //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))
@@ -295,7 +297,8 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                                        try {
                                                if (breakpoint.isEnabled()) {
                                                        if (marker != null) {
-                                                               DebugResponse dr = fDebugConnection.breakpointSet(path.toString(), ((ILineBreakpoint)breakpoint).getLineNumber());
+                                                               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))
@@ -359,7 +362,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)
@@ -384,19 +388,23 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                fThread.setBreakpoints(null);
                fThread.setStepping(false);
 
-               Integer.parseInt(fDebugConnection.featureGet("detach").getValue());
+               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 ) {
+               int id1 = fDebugConnection.featureSet("max_depth", "100" );
+               XDebugResponse response1 = getResponse(id1);
+               if (response1.getAttributeValue("success").equals("1") ) {
                        System.out.println("Set depth to 100 (hack)");
                }
                
@@ -420,59 +428,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
         */
-       public IStackFrame[] getStackFrames() throws DebugException {
-               DebugResponse lastResponse = fDebugConnection.stackGet(0);
-
-               if (lastResponse.isError())
-                       return new IStackFrame[0];
-               Node response = lastResponse.getParentNode();
-               NodeList frames = response.getChildNodes();
-               IStackFrame[] theFrames = new IStackFrame[frames.getLength()];
-               for (int i = 0; i < frames.getLength(); i++) {
-                       Node stackNode = frames.item(i);
-                       XDebugStackFrame frame = new XDebugStackFrame(fThread, i);
-                       String level =PHPDebugUtils.getAttributeValue(stackNode,"level");
-                       if (!"".equals(level))
-                               frame.setLevel(Integer.parseInt(level));
-
-                       frame.setType(PHPDebugUtils.getAttributeValue(stackNode,"type"));
-                       String fileName=PHPDebugUtils.unescapeString(PHPDebugUtils.getAttributeValue(stackNode,"filename"));
-                       String lineNo=PHPDebugUtils.getAttributeValue(stackNode,"lineno");
-
-                       if (!"".equals(lineNo))
-                               frame.setLineNumber(Integer.parseInt(lineNo));
-                       
-                       frame.setWhere(PHPDebugUtils.getAttributeValue(stackNode,"where"));
-                       
-                       try {
-                               frame.setFullName(new URL(fileName));
-                       } catch (MalformedURLException e) {
-                               e.printStackTrace();
-                       }
-
-                       frame.incrementStepCounter();
-                       
-                       theFrames[i] = frame;
-               }
-               
-               return theFrames;
+       public XDebugResponse getStackFrames() throws DebugException {
+               int id = fDebugConnection.stackGet();
+               XDebugResponse lastResponse = getResponse(id);
+               return lastResponse;
        }
        
        /**
@@ -508,80 +472,99 @@ 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) {
-               return fDebugConnection.setVarValue(name,value);
+               int id = fDebugConnection.setVarValue(name,value);
+               XDebugResponse response = getResponse(id);
+               
+               if ((response.getAttributeValue("success")).equals("1")) {
+                       return true;
+               } else {
+                       return false;
+               }
        }
        
        public void handleDebugEvents(DebugEvent[] events) {
                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 {
+                               return;
+                       }
+                       
                        if (event.getKind() == DebugEvent.MODEL_SPECIFIC) {
                                switch (event.getDetail()) {
                                        case IPHPDebugEvent.BREAKPOINT_HIT:
-                                               DebugResponse lastResponse = ((XDebugConnection) fDebugConnection).stackGet(0);
+                                               int id = fDebugConnection.stackGet();
+                                               XDebugResponse lastResponse = getResponse(id);
 
                                                IBreakpoint breakpoint = breakpointHit(lastResponse.getParentNode());
-       
-                                               fThread.setBreakpoints(new IBreakpoint[]{breakpoint});
-                                               fThread.incrementStepCounter();
-                                               suspended(DebugEvent.BREAKPOINT);
+                                               
+                                               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:
-                                               fThread.removeEventListeners();
-                                               fThread = null;
-                                               fThreads = new IThread[0];
-
-                                               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;
-                                                       fireEvent(new DebugEvent(this, DebugEvent.CHANGE, DebugEvent.CONTENT));
-                                               }
+                                               stopped();
                                                break;
                                }
                        }
                }
        }
+       
+       public void stopped() {
+               if(fDebugConnection == null) {
+                       return;
+               }
+
+               stopListener();
+               fDebugConnection.close();
+
+               fThread.removeEventListeners();
+               fThread = null;
+               fThreads = new IThread[0];
+               
+/*             stopListener();
+               fDebugConnection.close();*/
+
+               fSuspended = false;
 
-       public void handleProxyEvent(String ideKey, String initString, /*AbstractDebugConnection*/ XDebugConnection connection) {
-               System.out.println("* New Connection - XDebug.Target: "+ideKey);
+               // 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));
+               }               
+       }
+       
+       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));
                
                fThread = new XDebugThread(this);
@@ -596,7 +579,8 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
        private void setDebugConnection(XDebugConnection connection) {
                if (connection != null) {
                        fDebugConnection = connection;
-                       fDebugConnection.startListener();
+                       fResponseListener = new ResponseListener(connection);
+                       startListener();
                }
        }
        
@@ -611,122 +595,25 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                fProcess = p;
 
        }
-
-       public void launchRemoved(ILaunch launch) {
-       }
-
-       /**
-        * Notifies this listener that the specified launch
-        * has been added.
-        * 
-        * @param launch the newly added launch
-        * @since 2.0
-        */
-       public void launchAdded(ILaunch launch){
-       }
-
-       /**
-        * 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 IVariable[] getVariables(XDebugStackFrame frame, int level)  throws DebugException {
-               IVariable[] variables = null;
-               
-               DebugResponse response = fDebugConnection.contextGet(level, 0);
-               Node responseNode = response.getParentNode();
-               NodeList property = responseNode.getChildNodes();
-               
-               DebugResponse responseGlobal = fDebugConnection.contextGet(level, 1);
-               Node responseGlobalNode = responseGlobal.getParentNode();
-               NodeList propertyGlobal = responseGlobalNode.getChildNodes();
-               
-               variables = new IVariable[property.getLength() + propertyGlobal.getLength()];
-//             variables = new IVariable[property.getLength()]; // + propertyGlobal.getLength()];
+       public Node getLocalVariables(int level) throws DebugException {
+//             XDebugResponse response = fDebugConnection.contextGet(level, 0);
+               int id = fDebugConnection.contextGet(level, 0);
+               XDebugResponse response = getResponse(id);
                
-               int length = property.getLength();
-               for (int i = 0; i < length; i++) {
-                       Node propertyNode = property.item(i);
-                       XDebugVariable var=/*fDebugConnection.*/getVariableFromNode(frame,propertyNode);
-                       variables[i]=var;
-               }
-
-               int globalLength = propertyGlobal.getLength();
-               for (int k = 0; k < globalLength; k++) {
-                       Node propertyGlobalNode = propertyGlobal.item(k);
-                       XDebugVariable var=/*fDebugConnection.*/getVariableFromNode(frame,propertyGlobalNode);
-                       variables[k + length]=var;
-               }
+               return response.getParentNode();
+       }
        
-               return variables;
-       }       
-
-       public XDebugVariable getVariableFromNode(XDebugStackFrame frame, Node property) {
-               String varFullName = PHPDebugUtils.getAttributeValue(property, "fullname");
-               String varName = PHPDebugUtils.getAttributeValue(property, "name");
-               String varEncoding = PHPDebugUtils.getAttributeValue(property, "encoding");
-               
-               int varNumChildren = 0;
-               if (PHPDebugUtils.getAttributeValue(property, "numchildren").equals("")) {
-                       varNumChildren = 0;
-               } else {
-                       varNumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(property, "numchildren"));
-               }
-
-               String typeName = PHPDebugUtils.getAttributeValue(property,"type");
+       public Node getGlobalVariables(int level) throws DebugException {
+               //XDebugResponse response = fDebugConnection.contextGet(level, 1);
 
-               XDebugVariable variable = new XDebugVariable(frame,varFullName,varName,typeName);
-               variable.setEncoding(varEncoding);
-               variable.setNumChildren(varNumChildren);
-               XDebugAbstractValue val=null;
-               try {
-                       val = (XDebugAbstractValue) variable.getValue();
-               } catch (DebugException e1) {
-                       // TODO Auto-generated catch block
-                       e1.printStackTrace();
-               }
-               if (val.getType()!= XDebugAbstractValue.VALUETYPE_UNINITIALIZED) {
-                       if (variable.hasChildren()) {
-                               NodeList varNodes = property.getChildNodes();
-                               val.renderValueString(""+varNodes.getLength());
-                               IVariable[] variables = new IVariable[varNodes.getLength()];
-                               for (int i = 0; i<varNodes.getLength(); i++) {
-                                       Node propertyNode = varNodes.item(i);
-                                       variables[i] = getVariableFromNode(frame, propertyNode);
-                               }
-                               val.setChildVariables(variables);
-                       }else {
-                               String str="";
-                               try {
-                                       str=property.getFirstChild().getNodeValue();
-                               } catch (NullPointerException e) {
-                                       str="";
-                               }
-                               if (variable.getEncoding().equals("base64")) {
-                                       if (str.length()!=0)
-                                               str=new String(Base64.decode(str));
-                                       else
-                                               str="";
-                               }
-                               val.renderValueString(str);
-                       }
-                       
-                       String className=PHPDebugUtils.getAttributeValue(property,"classname");
-                       if(!"".equals(className))
-                               val.renderValueString(className);
-               }
-               return variable;
+               int id = fDebugConnection.contextGet(level, 1);
+               XDebugResponse response = getResponse(id);
                
+               return response.getParentNode();
        }
-
+       
        protected IBreakpoint breakpointHit(Node node) {
-               Node child=node.getFirstChild();
+               Node child = node.getFirstChild();
                if (child.getNodeName().equals("stack")) {
                        int lineNumber = Integer.parseInt(PHPDebugUtils.getAttributeValue(child, "lineno"));
                        String filename=PHPDebugUtils.getAttributeValue(child, "filename");  
@@ -743,13 +630,35 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                                                                        String endfilename;
                                                                        
                                                                        if (getProcess() == null) {
-                                                                               endfilename = marker.getResource().getFullPath().lastSegment(); 
+                                                                               endfilename = marker.getResource().getLocation().lastSegment(); 
                                                                        } else {
-                                                                               endfilename = marker.getResource().getFullPath().toOSString();
+                                                                               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());
+                                                                               }
                                                                        }
 
-                                                                       if(PHPDebugUtils.unescapeString(filename).endsWith(endfilename) && (lineBreakpoint.getLineNumber() == lineNumber) ) {
-                                                                               return (breakpoint);
+                                                                       //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);
+                                                                               }
                                                                        }
                                                                }
                                                        }
@@ -761,5 +670,18 @@ public class XDebugTarget extends XDebugElement implements IDebugTarget, ILaunch
                }
                
                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
index 366badf..505b5a6 100644 (file)
@@ -6,6 +6,13 @@
  */
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
+//import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
+
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugPlugin;
@@ -13,6 +20,8 @@ import org.eclipse.debug.core.IDebugEventSetListener;
 import org.eclipse.debug.core.model.IBreakpoint;
 import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.model.IThread;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * @author Axel
@@ -52,8 +61,11 @@ public class XDebugThread extends XDebugElement implements IThread, IDebugEventS
                
                if (isSuspended()) {    
                        if (fStepCount > fCurrentStepCount) {
-                               newStackFrames = ((XDebugTarget) getDebugTarget()).getStackFrames();
+                               //newStackFrames = ((XDebugTarget) getDebugTarget()).getStackFrames();
                                
+                               XDebugResponse dr = ((XDebugTarget) getDebugTarget()).getStackFrames();
+                               newStackFrames = _getStackFrames(dr);
+
                                for (int i = 0; i < newStackFrames.length; i++) {
                                        ((XDebugStackFrame)newStackFrames[i]).getVariables();
                                }
@@ -86,6 +98,43 @@ public class XDebugThread extends XDebugElement implements IThread, IDebugEventS
                }
        }
        
+       private IStackFrame[] _getStackFrames(XDebugResponse lastResponse) {
+               //IStackFrame[] newStackFrames = null;
+
+       if (lastResponse.isError())
+               return new IStackFrame[0];
+       Node response = lastResponse.getParentNode();
+       NodeList frames = response.getChildNodes();
+       IStackFrame[] theFrames = new IStackFrame[frames.getLength()];
+       for (int i = 0; i < frames.getLength(); i++) {
+               Node stackNode = frames.item(i);
+               XDebugStackFrame frame = new XDebugStackFrame(this/*fThread*/, i);
+               String level =PHPDebugUtils.getAttributeValue(stackNode,"level");
+               if (!"".equals(level))
+                       frame.setLevel(Integer.parseInt(level));
+
+               frame.setType(PHPDebugUtils.getAttributeValue(stackNode,"type"));
+               String fileName=PHPDebugUtils.unescapeString(PHPDebugUtils.getAttributeValue(stackNode,"filename"));
+               String lineNo=PHPDebugUtils.getAttributeValue(stackNode,"lineno");
+
+               if (!"".equals(lineNo))
+                       frame.setLineNumber(Integer.parseInt(lineNo));
+               
+               frame.setWhere(PHPDebugUtils.getAttributeValue(stackNode,"where"));
+               
+               try {
+                       frame.setFullName(new URL(fileName));
+               } catch (MalformedURLException e) {
+                       e.printStackTrace();
+               }
+       
+               frame.incrementStepCounter();
+               
+               theFrames[i] = frame;
+       }
+               return /*newStackFrames*/theFrames;
+       }
+                       
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IThread#hasStackFrames()
         */
index 969c718..8a563cf 100644 (file)
@@ -7,19 +7,21 @@
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
 import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
+
+//import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.model.IValue;
 import org.eclipse.debug.core.model.IVariable;
 import org.w3c.dom.Node;
-
+import org.eclipse.debug.core.model.IWatchExpressionDelegate;
 /**
  * @author Axel
  *
  * TODO To change the template for this generated type comment go to
  * Window - Preferences - Java - Code Style - Code Templates
  */
-public class XDebugVariable  extends XDebugElement implements IVariable {
+public class XDebugVariable  extends XDebugElement implements IVariable/*, IWatchExpressionFactoryAdapter*/ {
        public static final int VARTYPE_UNKNOWN = -1;
        public static final int VARTYPE_UNINITIALIZED = 0;
        public static final int VARTYPE_STRING = 1;
@@ -30,13 +32,13 @@ public class XDebugVariable  extends XDebugElement implements IVariable {
        public static final int VARTYPE_OBJECT = 10;
        public static final int VARTYPE_RESOURCE = 11;
        
-       // name & stack frmae
+       private int fNumChildren;
        private String fName;
-       private XDebugStackFrame fFrame;
        private String fFullName;
-       private XDebugAbstractValue fValue;
        private String fEncoding;
-       private int fNumChildren;
+       private XDebugStackFrame fFrame;
+       private XDebugAbstractValue fValue;
+       private String fFacet;
        
        /**
         * Constructs a variable contained in the given stack frame
@@ -45,73 +47,33 @@ public class XDebugVariable  extends XDebugElement implements IVariable {
         * @param frame owning stack frame
         * @param name variable name
         */
-       public XDebugVariable( String typeName, String fullname ) {
-               fFullName = fullname;
-               fName = fullname;
-               if (typeName.equals("int") ) 
-                       fValue= new XDebugIntValue(this,typeName);
-               else if (typeName.equals("float") ) 
-                       fValue= new XDebugFloatValue(this,typeName);
-               else if (typeName.equals("bool") ) 
-                       fValue= new XDebugBooleanValue(this,typeName);
-               else if (typeName.equals("string") )
-                       fValue= new XDebugStringValue(this,typeName);
-               else if (typeName.equals("array") )
-                       fValue= new XDebugArrayValue(this,typeName);
-               else if (typeName.equals("hash") )
-                       fValue= new XDebugArrayValue(this,typeName);
-               else if (typeName.equals("object") )
-                       fValue= new XDebugArrayValue(this,typeName);
-               else if (typeName.equals("resource") )
-                       fValue= new XDebugResourceValue(this,typeName);
-               else
-                       fValue= new XDebugValue(this,typeName);
-       }
-       
        public XDebugVariable(XDebugStackFrame frame, Node property) {
-               super((XDebugTarget) frame.getDebugTarget());
-               fFrame = frame;
-               init(property);
-       }
-       
-       public XDebugVariable(XDebugStackFrame frame, String fullname, String name, String typeName) {
-               super((XDebugTarget) frame.getDebugTarget());
-               fFrame = frame;
-               fFullName = fullname;
-               fName = name;
-               if (typeName.equals("int") ) 
-                       fValue= new XDebugIntValue(this,typeName);
-               else if (typeName.equals("float") ) 
-                       fValue= new XDebugFloatValue(this,typeName);
-               else if (typeName.equals("bool") ) 
-                       fValue= new XDebugBooleanValue(this,typeName);
-               else if (typeName.equals("string") )
-                       fValue= new XDebugStringValue(this,typeName);
-               else if (typeName.equals("array") )
-                       fValue= new XDebugArrayValue(this,typeName);
-               else if (typeName.equals("hash") )
-                       fValue= new XDebugArrayValue(this,typeName);
-               else if (typeName.equals("object") )
-                       fValue= new XDebugArrayValue(this,typeName);
-               else if (typeName.equals("resource") )
-                       fValue= new XDebugResourceValue(this,typeName);
-               else
-                       fValue= new XDebugValue(this,typeName);
-       }
-       
-       private void  init(Node property) {
-               fFullName=PHPDebugUtils.getAttributeValue(property,"fullname");
-               fName=PHPDebugUtils.getAttributeValue(property,"name");
-               fEncoding=PHPDebugUtils.getAttributeValue(property,"encoding");
-               if (PHPDebugUtils.getAttributeValue(property,"numchildren").equals(""))
+               if (frame != null ) {
+                       //super((XDebugTarget) frame.getDebugTarget());
+                       fFrame = frame;
+               }
+
+               String address = PHPDebugUtils.getAttributeValue(property,"address");
+
+               fName = PHPDebugUtils.getAttributeValue(property,"name");
+               if ("".equals(fName)) {
+                       fName = address;
+               } /*else {
+                       varName = Name;
+               }*/
+               
+               fFullName = PHPDebugUtils.getAttributeValue(property,"fullname");
+               fEncoding = PHPDebugUtils.getAttributeValue(property,"encoding");
+               if (PHPDebugUtils.getAttributeValue(property,"numchildren").equals("")) {
                        fNumChildren = 0;
-               else
-                       fNumChildren=Integer.parseInt(PHPDebugUtils.getAttributeValue(property,"numchildren"));
+               } else {
+                       fNumChildren = Integer.parseInt(PHPDebugUtils.getAttributeValue(property, "numchildren"));
+               }
+
+               String typeName = PHPDebugUtils.getAttributeValue(property, "type");
 
-               String typeName=PHPDebugUtils.getAttributeValue(property,"type");
+               fFacet = PHPDebugUtils.getAttributeValue(property, "facet");
 
-//             if (typeName.equals("uninitialized") )
-//                     fValue= new XDebugValue(this,property,typeName);
                if (typeName.equals("int") ) 
                        fValue= new XDebugIntValue(this,property,typeName);
                else if (typeName.equals("float") ) 
@@ -129,7 +91,7 @@ public class XDebugVariable  extends XDebugElement implements IVariable {
                else
                        fValue= new XDebugValue(this,property,typeName);
        }
-       
+               
        /* (non-Javadoc)
         * @see org.eclipse.debug.core.model.IVariable#getValue()
         */
@@ -209,8 +171,8 @@ public class XDebugVariable  extends XDebugElement implements IVariable {
        }
        
        public void setStackFrame(XDebugStackFrame frame) {
-               fFrame=frame;
-               super.setDebugTarget((XDebugTarget)frame.getDebugTarget());
+               fFrame = frame;
+               super.setDebugTarget((XDebugTarget) frame.getDebugTarget());
        }
 
 //     public int getType() {
@@ -237,6 +199,10 @@ public class XDebugVariable  extends XDebugElement implements IVariable {
                return fEncoding;
        }
 
+       public String getVisibility() {
+               return fFacet;
+       }
+
        public void setEncoding(String encoding) {
                fEncoding = encoding;
        }
@@ -299,14 +265,25 @@ public class XDebugVariable  extends XDebugElement implements IVariable {
                                        fValue.sethasChanged(false);                                    
                                }
                        } else {
-                               IVariable dummy = new XDebugVariable("UNKNOWN", "");
-                               dummy.setValue("uninitialized");
+                               //IVariable dummy = new XDebugVariable("UNKNOWN", "");
+                               /*dummy.setValue("uninitialized");
                                for(int i = 0; i < newVariable.length; i++) {
                                        ((XDebugVariable)newVariable[i]).setChange(dummy);
                                }
-                               fValue.sethasChanged(true);                             
+                               fValue.sethasChanged(true);*/                           
                        }
                }
        }
-       
+       /**
+        * Creates and returns an expression for the specified variable
+        * which is used to created an {@link org.eclipse.debug.core.model.IWatchExpression}.
+        * 
+        * @param variable variable a watch expression is required for
+        * @return text used to create a watch expression
+        * @exception org.eclipse.core.runtime.CoreException if unable to create a watch
+        *  expression
+        */
+       /*public String createWatchExpression(IVariable variable) throws CoreException {
+               
+       }*/     
 }
\ No newline at end of file
index 2974ceb..313bef5 100644 (file)
@@ -1,21 +1,16 @@
 package net.sourceforge.phpeclipse.xdebug.php.model;
 
 
-import net.sourceforge.phpeclipse.xdebug.core.Base64;
-import net.sourceforge.phpeclipse.xdebug.core.PHPDebugUtils;
 import net.sourceforge.phpeclipse.xdebug.core.xdebug.XDebugConnection;
-import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.DebugResponse;
+import net.sourceforge.phpeclipse.xdebug.core.xdebug.ResponseListener.XDebugResponse;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugVariable;
 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
 
-import org.eclipse.debug.core.DebugException;
 import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IVariable;
 import org.eclipse.debug.core.model.IWatchExpressionDelegate;
 import org.eclipse.debug.core.model.IWatchExpressionListener;
 import org.eclipse.debug.core.model.IWatchExpressionResult;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
        public void evaluateExpression(String expression, IDebugElement context, IWatchExpressionListener listener) {
@@ -31,10 +26,13 @@ public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
                if( connection != null ) {
                        try {
                                if( ! connection.isClosed() ) {
-                                       DebugResponse evalCommand = connection.eval(expression);
+                                       /*XDebugResponse*/ int evalCommand = connection.eval(expression);
                                        
-                                       Node evalNode = evalCommand.getParentNode();
-                                       XDebugVariable var= /*connection.*/getVariableFromNodeA( null, evalNode.getFirstChild());
+                                       XDebugResponse response = s.getResponse(evalCommand);
+
+                                       
+                                       Node evalNode = response.getParentNode();
+                                       XDebugVariable var = new XDebugVariable(null, evalNode);
                                        XDebugVariable result[] = {var};
                                        
                                        if (result.length == 0) {
@@ -54,66 +52,4 @@ public class XDebugWatchExpressionDelegate implements IWatchExpressionDelegate {
 
                listener.watchEvaluationFinished(x);
        }
-       
-       private XDebugVariable getVariableFromNodeA(XDebugStackFrame frame, Node property) {
-               String address = PHPDebugUtils.getAttributeValue(property, "address");
-               String varName;
-               String Name = PHPDebugUtils.getAttributeValue(property,"name");
-               if ("".equals(Name)) {
-                       varName = address;              
-               } else {
-                       varName = Name;
-               }
-
-               String varEncoding=PHPDebugUtils.getAttributeValue(property,"encoding");
-               int varNumChildren = 0;
-               if (PHPDebugUtils.getAttributeValue(property,"numchildren").equals(""))
-                       varNumChildren = 0;
-               else
-                       varNumChildren=Integer.parseInt(PHPDebugUtils.getAttributeValue(property,"numchildren"));
-
-               String typeName=PHPDebugUtils.getAttributeValue(property,"type");
-
-               XDebugVariable variable = new XDebugVariable(typeName, varName);
-               variable.setEncoding(varEncoding);
-               variable.setNumChildren(varNumChildren);
-               XDebugAbstractValue val=null;
-               try {
-                       val = (XDebugAbstractValue) variable.getValue();
-               } catch (DebugException e1) {
-                       e1.printStackTrace();
-               }
-               if (val.getType()!= XDebugAbstractValue.VALUETYPE_UNINITIALIZED) {
-                       if (variable.hasChildren()) {
-                               NodeList varNodes = property.getChildNodes();
-                               val.renderValueString(""+varNodes.getLength());
-                               IVariable[] variables = new IVariable[varNodes.getLength()];
-                               for (int i = 0; i<varNodes.getLength(); i++) {
-                                       Node propertyNode = varNodes.item(i);
-                                       variables[i] = getVariableFromNodeA(frame, propertyNode);
-                               }
-                               val.setChildVariables(variables);
-                       }else {
-                               String str="";
-                               try {
-                                       str=property.getFirstChild().getNodeValue();
-                               } catch (NullPointerException e) {
-                                       str="";
-                               }
-                               if (variable.getEncoding().equals("base64")) {
-                                       if (str.length()!=0)
-                                               str=new String(Base64.decode(str));
-                                       else
-                                               str="";
-                               }
-                               val.renderValueString(str);
-                       }
-                       
-                       String className=PHPDebugUtils.getAttributeValue(property,"classname");
-                       if(!"".equals(className))
-                               val.renderValueString(className);
-               }
-               return variable;
-               
-       }
 }
\ No newline at end of file