+++ /dev/null
-/**
- *
- */
-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
+++ /dev/null
-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
public interface IProxyEventListener {
- public void handleProxyEvent(String ideKey, String initString, /*AbstractDebugConnection*/ XDebugConnection connectin);
+ public void handleProxyEvent(/*String ideKey,*/ /*String initString,*/ XDebugConnection connectin);
}
throw new IllegalArgumentException();
}
// check for duplicates using identity
- if (fListeners.get(ideKey) != null)
+ if (fListeners.get(ideKey) == null)
fSize++;
fListeners.put(ideKey,listener);
}
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;
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) {
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");
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();
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;
}
* @see org.eclipse.core.runtime.ISafeRunnable#run()
*/
public void run() throws Exception {
- fListener.handleProxyEvent(fIdeKey, fInitString, fConnection);
+ fListener.handleProxyEvent(/*fIdeKey,*/ fConnection);
}
/**
*
* @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() {
*
* @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();
+ }
}
}
* @see IDebugEventSetListener
* @since 2.0
*/
- public void fireProxyEvent() {
+ public void fireProxyEvent(String id) {
EventNotifier fNotifier = new EventNotifier();
- fNotifier.dispatch();
+ fNotifier.dispatch(id);
}
/**
public int getProxyPort() {
return fProxyPort;
}
-
- public boolean isRunning() {
- return fIsRunning;
- }
}
\ No newline at end of file
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;
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();
}
}
if (fList.containsKey(new Integer(id)))
- return (DebugResponse) fList.remove(new Integer(id));
+ return (XDebugResponse) fList.remove(new Integer(id));
else
return null;
}
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;
*/
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();
fValue = parentNode.getFirstChild().getNodeValue();
}
} catch (Exception e) {
- // TODO: handle exception
}
}
+
+ }
+
+ private void parseStream() {
+
}
+
public String getAttributeValue (String AttributeName) {
String strValue = "";
if (parentNode.hasAttributes()) {
return parentNode;
}
+ public synchronized String getIdeKey(){
+ return fIdeKey;
+ }
+
public synchronized String getCommand() {
return fCommand;
}
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;
}
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();
}
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")) {
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
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;
/**
*
*/
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;
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);
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;
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) {
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 {*/
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
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;
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)
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);
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);
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;
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);
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
IDebugTarget target = new XDebugTarget(launch, null, ideID);
+ proxy.addProxyEventListener((IProxyEventListener) target, ideID);
launch.addDebugTarget(target);
}
}
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;
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 {
}
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]);
fhasChanged = true;
}
} catch (Exception e) {
- int b = 1;
+ //int b = 1;
}
}
if (fhasChanged) {
try {
fVariables[i].setValue(newVariable[i].getValue());
} catch (Exception e) {
- int b = 1;
+ //int b = 1;
}
}
}
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;
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;
*/
protected void fireTerminateEvent() {
fireEvent(new DebugEvent(this, DebugEvent.TERMINATE));
- }
-
-
+ }
}
\ No newline at end of file
-
/*
* 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;
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;
/**
* 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,
* @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
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
*/
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
private int fId;
- //private IPath fName;
-
private URL fName;
private int fLineNumber;
private IVariable[] fVariables;
private int fStepCount = 0;
- //private int fCurrentStepCount = 0;
/**
* Constructs a stack frame in the given thread with the given
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()
*/
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;
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;
private XDebugConnection fDebugConnection;
+ private ResponseListener fResponseListener;
+
private String fIdeKey;
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);
* @see org.eclipse.debug.core.model.IDebugTarget#hasThreads()
*/
public boolean hasThreads() throws DebugException {
- return (fThreads.length>0);
+ return (fThreads.length > 0);
}
/* (non-Javadoc)
* @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)
*/
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 {
e2.printStackTrace();
}
+ if (fDebugConnection != null)
if (!fDebugConnection.isClosed()) {
if (fProcess == null) {
PathMapItem pmi = null;
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))
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))
* @see org.eclipse.debug.core.model.IDisconnect#isDisconnected()
*/
public boolean isDisconnected() {
- return (fDebugConnection==null);
+ return (false);
+// return (fDebugConnection==null);
}
/* (non-Javadoc)
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)");
}
}
/**
- * 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;
}
/**
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);
private void setDebugConnection(XDebugConnection connection) {
if (connection != null) {
fDebugConnection = connection;
- fDebugConnection.startListener();
+ fResponseListener = new ResponseListener(connection);
+ startListener();
}
}
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");
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);
+ }
}
}
}
}
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
*/
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;
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
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();
}
}
}
+ 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()
*/
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;
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
* @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") )
else
fValue= new XDebugValue(this,property,typeName);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getValue()
*/
}
public void setStackFrame(XDebugStackFrame frame) {
- fFrame=frame;
- super.setDebugTarget((XDebugTarget)frame.getDebugTarget());
+ fFrame = frame;
+ super.setDebugTarget((XDebugTarget) frame.getDebugTarget());
}
// public int getType() {
return fEncoding;
}
+ public String getVisibility() {
+ return fFacet;
+ }
+
public void setEncoding(String encoding) {
fEncoding = encoding;
}
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
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) {
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) {
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