*
*/
public class PHPDBGInterface {
- public boolean sessionEnded = false;
- public int sessType = -1;
- public int BPUnderHit = 0;
- public String sessID = new String();
-
- private int[] LastBPRead = new int[10];
- private Vector DBGBPList = new Vector();
- private Vector DBGVarList = new Vector();
+ public boolean sessionEnded = false;
+ public int sessType = -1;
+ public int BPUnderHit = 0;
+ public String sessID = new String();
+
+ private int[] LastBPRead = new int[10];
+ private Vector DBGBPList = new Vector();
+ private Vector DBGVarList = new Vector();
private PHPStackFrame[] DBGStackList = new PHPStackFrame[0];
- private Vector DBGMods = new Vector(); // The module names and their numbers
- private Vector stackListOld = new Vector();
- private BufferedReader in;
- private OutputStream os; // The stream which goes to DBG
- private boolean shouldStop = false;
- private String evalRet = new String("");
- private int rawCounter = 1000; // An rawData frame ID counter
- private PHPDBGProxy proxy = null;
- //private int lastCmd = -1;
- private int sid = 0;
- private boolean stopOnError = false;
- private char[] lastCommand = new char[4];
+ private Vector DBGMods = new Vector(); // The module names and their numbers
+ private Vector stackListOld = new Vector();
+ private BufferedReader dbgInput;
+ private OutputStream dbgOutput; // The stream which goes to DBG
+ private boolean shouldStop = false;
+ private String evalRet = new String("");
+ private int rawCounter = 1000; // An rawData frame ID counter
+ private PHPDBGProxy proxy = null;
+// private int lastCmd = -1;
+ private int sid = 0;
+ private boolean stopOnError = false; // If we the debugger should be relaunched after script termination
+ private boolean bRelaunch = true;
+ private char[] lastCommand = new char[4];
+ private boolean bBusy = false;
+ private boolean bDebug = true; // Prints text to console for debugging purposes
private static final String GlobalVariablesTitle = PHPDebugCorePlugin
.getResourceString("VariablesView.GlobalVariables.title");
/**
- * @param in The input stream (communication from DBG).
- * @param os The output stream (communication to DBG).
- * @param proxy The proxy to which this interface belongs.
+ * @param in The input stream (communication from DBG).
+ * @param os The output stream (communication to DBG).
+ * @param proxy The proxy to which this interface belongs.
+ * @param bRelaunch The debugger should be relaunched after PHP script termination
*/
- public PHPDBGInterface (BufferedReader in, OutputStream os, PHPDBGProxy proxy) {
+ public PHPDBGInterface (BufferedReader in, OutputStream os, PHPDBGProxy proxy, boolean bRelaunch) {
DBGBPList.clear ();
- this.in = in;
- this.os = os;
- this.proxy = proxy;
+ this.dbgInput = in;
+ this.dbgOutput = os;
+ this.proxy = proxy;
+ this.bRelaunch = bRelaunch;
}
/**
PHPDBGPacket DBGPacket; // A DBG message packet
PHPDBGFrame DBGFrame; // A frame within a DBG packet
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: getSourceTree");
+ }
+
DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_REQUEST); // A request for DBG
DBGFrame = new PHPDBGFrame (PHPDBGBase.FRAME_SRC_TREE); // We want a source tree from DBG
DBGPacket.addFrame (DBGFrame); // Add the 'what we want' to the DBG packet
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
+ bBusy = false;
return; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
waitResponse (1000); // Wait for the DBG response (1 second)
flushAllPackets (); // Read and process the response from DBG
PHPDBGFrame DBGFrame3;
int modNo;
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: setBreakpoint");
+ }
+
DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_REQUEST);
DBGFrame1 = new PHPDBGFrame (PHPDBGBase.FRAME_BPS);
DBGFrame2 = new PHPDBGFrame (PHPDBGBase.FRAME_RAWDATA);
DBGPacket.addFrame (DBGFrame1); // Second add command data
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
+ bBusy = false;
return 0; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
clearLastBP ();
public void continueExecution () throws IOException {
PHPDBGPacket DBGPacket;
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: continueExecution");
+ }
+
BPUnderHit = 0;
DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_CONTINUE);
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
return; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
lastCommand = PHPDBGBase.DBGA_CONTINUE; // Store the info about the command we sent
}
public void pauseExecution () throws IOException {
PHPDBGPacket DBGPacket;
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: pauseExecution");
+ }
+
DBGPacket = new PHPDBGPacket (PHPDBGBase.IntToChar4 (PHPDBGBase.DBGC_PAUSE));
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
return; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
}
/**
/**
*
*/
- public void stepInto () throws IOException {
+ public boolean stepInto () throws IOException {
PHPDBGPacket DBGPacket;
+ if (bBusy) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: stepOver vetoed");
+ }
+ }
+
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: stepInto");
+ }
+
BPUnderHit = 0;
DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_STEPINTO);
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
- return; // No
+ return false; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
lastCommand = PHPDBGBase.DBGA_STEPINTO; // Store the info about the command we sent
+
+ return true;
}
/**
*
*/
- public void stepOver () throws IOException {
+ public boolean stepOver () throws IOException {
PHPDBGPacket DBGPacket;
+ if (bBusy) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: stepOver vetoed");
+ }
+ }
+
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: stepOver");
+ }
+
BPUnderHit = 0;
DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_STEPOVER);
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
- return; // No
+ return false; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
lastCommand = PHPDBGBase.DBGA_STEPOVER; // Store the info about the command we sent
+
+ return true;
}
/**
*
*/
- public void stepOut () throws IOException {
+ public boolean stepOut () throws IOException {
PHPDBGPacket DBGPacket;
+ if (bBusy) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: stepOver vetoed");
+ }
+ }
+
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: stepOut");
+ }
+
BPUnderHit = 0;
DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_STEPOUT);
if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG?
- return; // No
+ return false; // No
}
- DBGPacket.sendPacket (os); // Send the request to DBG
+ DBGPacket.sendPacket (dbgOutput); // Send the request to DBG
lastCommand = PHPDBGBase.DBGA_STEPOUT; // Store the info about the command we sent
+
+ return true;
}
/**
public synchronized Vector getVariables(PHPStackFrame stack) throws IOException, DebugException {
if (DBGStackList.length == 0) {
DBGVarList.clear();
+
return DBGVarList;
}
// Also note that 2.13.1 doesn't return $this in class context.
// (You can inspect $this in Expressions View. And once it is shown, 2.13.1 comes to return $this.)
Vector globalList = getVariables(DBGStackList[DBGStackList.length - 1], global_scope_id);
+
if (!globalList.isEmpty()) {
// remove unresolved '$this=?' variable
removeUnresolvedThisVar(globalList);
}
int scopeID = stack.getScopeID();
- if (!globalList.isEmpty()
- && ((DBGStackList.length == 1)
- || (scopeID == PHPDBGBase.CURLOC_SCOPE_ID + 1))) {
+
+ if (!globalList.isEmpty () &&
+ ((DBGStackList.length == 1) || (scopeID == PHPDBGBase.CURLOC_SCOPE_ID + 1))) {
// 'main()' stackframe
PHPVariable var = (PHPVariable) globalList.get(0);
- PHPValue val = (PHPValue) var.getValue();
- DBGVarList = val.getChildVariables();
- return DBGVarList;
+ PHPValue val = (PHPValue) var.getValue();
+
+ DBGVarList = val.getChildVariables();
- } else if (scopeID == PHPDBGBase.CURLOC_SCOPE_ID) {
+ return DBGVarList;
+ }
+ else if (scopeID == PHPDBGBase.CURLOC_SCOPE_ID) {
// current stackframe
DBGVarList = getVariables(stack, PHPDBGBase.CURLOC_SCOPE_ID);
-
- } else {
+ }
+ else {
// back-trace stackframe
//DBGVarList = getVariables(stack, scopeID);
//removeUnresolvedThisVar(DBGVarList);
}
/**
- *
+ *
*/
private Vector getVariables(PHPStackFrame stack, int scope_id) throws IOException {
PHPDBGPacket DBGPacket = new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
PHPDBGFrame DBGFrame1 = new PHPDBGFrame(PHPDBGBase.FRAME_EVAL);
+ if (bBusy) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: getVariables vetoed");
+ }
+ }
+
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: getVariables");
+ }
+
DBGFrame1.addInt(0);
DBGFrame1.addInt(scope_id);
evalRet = "";
if (proxy.getSocket().isClosed()) {
+ bBusy = false;
return new Vector();
}
- DBGPacket.sendPacket(os);
+
+ DBGPacket.sendPacket(dbgOutput);
waitResponse(1000);
flushAllPackets();
+ bBusy = false; // Already done in flushAllPackets ()
+
PHPDBGEvalString evalStr = new PHPDBGEvalString(stack, evalRet);
return evalStr.getVariables();
}
/**
* Remove unresolved $this variable
- *
+ *
* DBG returns $this=? in function's or intermediate stackframes.
* (In current method's stackframe, DBG returns $this=classname)
- *
+ *
* @param varList
*/
private void removeUnresolvedThisVar(Vector varList) {
if (varList.size() > 0) {
- PHPVariable var = (PHPVariable) varList.get(0);
- PHPValue val = (PHPValue) var.getValue();
- Vector workList = val.getChildVariables();
+ PHPVariable var = (PHPVariable) varList.get(0);
+ PHPValue val = (PHPValue) var.getValue();
+ Vector workList = val.getChildVariables ();
+
for (int i = 0; i < workList.size(); i++) {
PHPVariable workvar = (PHPVariable) workList.get(i);
- if (workvar.getName().equals("$this")) {
- String workval = ((PHPValue) workvar.getValue()).getValueString();
- if (workval.equals("?") || workval.equals("NULL")) {
- workList.remove(i);
+
+ if (workvar.getName().equals ("$this")) {
+ String workval = ((PHPValue) workvar.getValue ()).getValueString ();
+
+ if (workval.equals ("?") ||
+ workval.equals ("NULL")) {
+ workList.remove (i);
}
break;
}
PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_LOG);
PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: log");
+ }
+
rawCounter++;
DBGFrame1.addInt(rawCounter); // ilog
DBGFrame1.addInt(1); // type
DBGPacket.addFrame(DBGFrame1);
if (proxy.getSocket ().isClosed ()) { // Do we have a socket for DBG communication?
+ bBusy = false;
return; // No, then leave here
}
- DBGPacket.sendPacket(os);
+ DBGPacket.sendPacket(dbgOutput);
waitResponse(1000);
flushAllPackets();
PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_EVAL);
PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
+ while (bBusy) {
+ }
+
+ bBusy = true;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: evalBlock");
+ }
+
rawCounter++;
DBGFrame1.addInt(rawCounter); // istr = raw data ID
//DBGFrame1.addInt(1); // scope_id = -1 means current location, 0 never used, +1 first depth
DBGPacket.addFrame(DBGFrame1);
if (proxy.getSocket().isClosed()) { // Do we have a socket for DBG communication?
+ bBusy = false;
return null; // No, then leave here
}
- DBGPacket.sendPacket(os);
+
+ DBGPacket.sendPacket(dbgOutput);
waitResponse(1000);
flushAllPackets();
stackFrameOld.setAvailable (true); // We found the new stackframe in the list of old stack frames
stackFrameOld.setIndex (stackFrameNew.getIndex ());
stackFrameOld.setScopeID(stackFrameNew.getScopeID());
+
return true; // The stackframe was found in the list
}
}
if (isStackFrameInList (stackFrameNew, oldList)) { // Is this stackframe in the list
stackFrameNew.setAvailable (true); //
//
- break;
+// break;
}
}
}
PHPStackFrame stackFrameOld;
PHPStackFrame[] newStackList;
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: updateStackFrameList Start");
+ }
+
markIdenticalStackFrames (stackListOld, stackList); // Check whether the newly send stack frames can be found in the list
// of old stack frames
newStackList = new PHPStackFrame[stackListOld.size ()];
newStackList = (PHPStackFrame[]) stackListOld.toArray (newStackList);
DBGStackList = newStackList;
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: updateStackFrameList End");
+ }
}
/**
Vector rawList = new Vector();
Vector stackList = new Vector(); // Intermediate stacklist which is build up in FRAME_STACK frame
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readResponse start");
+ }
+
rawList.clear ();
stackList.clear ();
dbg_header_struct[3] = PHPDBGBase.Char4ToInt (dbg_header_struct_read, 12); // Bytes within this block
if (dbg_header_struct[0] != 0x5953) { // Check DBG sync bytes
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readResponse. Wrong sync");
+ }
+
+ bBusy = false;
return 0; // Wrong header
}
if (bytesToRead > 0) { // If there is something within the frame
if (readInput (entirePack, bytesToRead) < bytesToRead) { // Read the frame into the buffer
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readResponse. Did not read enough");
+ }
+
+ bBusy = false;
return 0; // We did not read enough bytes, error
}
}
-
+
nextFrame = 0; // Start with the first frame
while (nextFrame < bytesToRead) { // As long as we have something within this block
nextFrame += 8; // The next read position
if (dbg_frame[1] == 0) { // Something within the frame?
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readResponse. Nothing within the frame");
+ }
+
+ bBusy = false;
return 0; // Nothing to read, error
}
break;
case PHPDBGBase.DBGC_END:
- sessionEnded = true;
- this.proxy.setTerminated();
+ if (bRelaunch) {
+ continueExecution (); // Inform dbg that we want to continue execution
+ proxy.updateView (); // Sent a change event and create thread event to eclipse core
+ updateStackFrameList (stackList); // ??? Just a try
+ }
+ else {
+ sessionEnded = true;
+ proxy.setTerminated ();
+ }
break;
case PHPDBGBase.DBGC_BREAKPOINT:
}
}
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readResponse finish, received: " + cmdReceived);
+ }
+
+ bBusy = false;
+
return cmdReceived; // Return the command we received with this block
}
*/
private int readInput (char[] buffer, int bytes) throws IOException {
int bytesRead = 0; // Reset the bytes read counter
+ int nRetry = 0; // Retry counter
+
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readInput " + bytes);
+ }
- for (int i = 0; i < bytes; i++) { // For the number of bytes we should read
- if (in.ready ()) { // If input stream is ready for reading
- buffer[i] = (char) (in.read () & 0x00FF); // Read a char and store only the least significant 8-bits
+ for (int i = 0; i < bytes;) { // For the number of bytes we should read
+ if (dbgInput.ready ()) { // If input stream is ready for reading
+ nRetry = 0; // Reset the retry counter
+ buffer[i] = (char) (dbgInput.read () & 0x00FF); // Read a char and store only the least significant 8-bits
bytesRead++; // Increment the bytes read counter
+ i++;
}
else { // Input stream is not ready
- break; // Break the loop
+ nRetry++; // Increment the retry counter
+
+ if (nRetry > 10) { // If nothing received within 100 retries
+ if (i > 0) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: Too many retries without receiving something");
+ }
+ }
+ break; // we break the loop
+ }
+
+ synchronized (dbgInput) {
+ if (i > 0) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: retry: " + nRetry + " Wait for something to receive, received: " + i + " need " + bytes);
+ }
+ }
+ try {
+ dbgInput.wait (10); // wait 5 ms maximum for something to receive
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ }
+
+ if (bytesRead > 0) {
+ if (bytes != bytesRead) {
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: readInput: Possible error: not enough bytes in buffer should read: " + bytes +
+ " actually read: " + bytesRead);
+ }
}
}
* @return - true if something was received from DBG
* - false if nothing was send from DBG within the given time
*
+ * This method has been a busy wait loop. It was changed to use
+ * a non busy wait to avoid a heavy load after automatic relaunch
+ * after script termination
+ *
*/
public boolean waitResponse (long milliseconds) throws IOException {
long timeout;
+ if (bDebug) {
+ System.out.println ("PHPDBGInterface: waitResponse " + milliseconds);
+ }
+
timeout = System.currentTimeMillis () + milliseconds; // Calculate the system time till we wait.
while (System.currentTimeMillis () < timeout) { // Is waiting time running out?
- if (in.ready () || shouldStop) { // No, so did we get something or should we stop now
- break; // Yes, break the waiting
+ synchronized (dbgInput) {
+ try {
+ dbgInput.wait (5); // wait 5 ms maximum for something to receive
+ } catch (InterruptedException e) {
+ }
+ }
+
+ if (dbgInput.ready () || shouldStop) { // If something is received of if we should stop now
+ break; // break the waiting loop
}
}
- return in.ready (); // true if we got something from DBG
+ return dbgInput.ready (); // true if we got something from DBG
}
}
int i;
PHPDBGFrame frame;
+// System.out.println ("PHPDBGPacket: sendPacket");
+
PHPDBGBase.copyCharsTo (packetHeader, PHPDBGBase.IntToChar4 (packetSize), 4, 12);
try {
private int port;
private boolean remote;
private boolean pathtranslation;
+ private boolean bRelaunch; // Relaunch the debugger after script termination
private Map pathmap;
private IPath remoteSourcePath;
public PHPDBGProxy () {
thisProxy = this;
}
-
+
/**
* updateView
* Clean up the view, but leave the Debug session running.
* added by ed_mann
*/
-// public void updateView(){
-// getDebugTarget().updateThreads(PHPMainThread);
-// }
-
+ public void updateView () {
+/*
+ try {
+ server.close ();
+ server = null;
+ start ();
+ }
+ catch (IOException e) {
+ }
+*/
+ getDebugTarget ().updateThreads (PHPMainThread);
+ }
+
/**
* @param remote
* @param remoteSourcePath
* @param pathTranslate
* @param paths
+ * @param
*/
- public PHPDBGProxy (boolean remote, String remoteSourcePath, boolean pathTranslate, Map paths) {
+ public PHPDBGProxy (boolean remote, String remoteSourcePath, boolean pathTranslate, Map paths, boolean bRelaunchOnScriptTermination) {
thisProxy = this;
this.remote = remote;
this.remoteSourcePath = new Path (remoteSourcePath);
this.pathmap = paths;
this.pathtranslation = pathTranslate;
+ this.bRelaunch = bRelaunchOnScriptTermination;
}
/**
phpLoop.notifyWait ();
}
-
+
public void setTerminated () {
try {
PHPMainThread.terminate ();
/**
* Find a free unused port between 10001 and 10101 if the current debug session
* is for remote debugging, and a unused port 7869 if it is used as non remote debugging.
- *
+ *
* For remote debugging the used port is submitted with the URL.
* E.g. http://localhost/index.php?DBGSESSID=1@localhost:10001
* For non remote debugging (if PHPeclipse used e.g. php cli directly) no port
* can be submitted by parameter, and only the default port (7869) can be used.
- *
- * @note: The free dbg version doesn't allow to set the appropriate port within php.ini!
- *
- *
+ *
+ * @note: The free dbg version doesn't allow to set the appropriate port within php.ini!
+ *
+ *
*/
protected void createServerSocket () {
if (this.remote) {
else {
port = SocketUtil.findUnusedLocalPort ("localhost", 7869, 7869); // Get the first free port in the range from 7869 to 7869
}
-
+
if (port == -1) { // Did we get a free port?
PHPDebugCorePlugin.log (5, "Cannot find free port!!!!"); // No, output a error message
public PHPDBGInterface getDBGInterface () {
return DBGInt;
}
-
+
/**
* Give back a buffered input stream for the socket which is
* linked with this proxy
localPath = new Path (local); // Get the remote/server side path of the mapping
if (localPath.isPrefixOf (filename)) { // Starts the remote/server side file path with the remote/server side mapping path
- // dann prefix abh�ngen und den remote path davorh�gen
+ // dann prefix abhängen und den remote path davorhägen
newpath = filename.removeFirstSegments (localPath.matchingFirstSegments (filename));
newpath = remotePath.append (newpath);
path = newpath.toString ();
// bpNo= DBGInt.addBreakpoint(phpLBP.getMarker().getResource().getLocation().toOSString(), phpLBP.getLineNumber());
if (phpLBP.isConditionEnabled ()) {
bpNo = DBGInt.addBreakpoint (MapPath(phpLBP),
- phpLBP.getLineNumber(),
+ phpLBP.getLineNumber(),
phpLBP.getHitCount(),
phpLBP.getCondition ());
}
else {
bpNo = DBGInt.addBreakpoint (MapPath(phpLBP),
- phpLBP.getLineNumber(),
+ phpLBP.getLineNumber(),
phpLBP.getHitCount(),
"");
}
-
+
phpLBP.setDBGBpNo(bpNo);
}
} catch (IOException e) {
/**
* Is called by the DebuggerRunner
- *
+ *
* @param debugTarget
*/
public void setDebugTarget (PHPDebugTarget debugTarget) {
this.debugTarget = debugTarget;
debugTarget.setPHPDBGProxy(this);
}
-
+
/**
* This method is called by a stackframe.
* It reads the variables from PHP via DBG
public void readStepOverEnd (PHPStackFrame stackFrame) {
try {
- DBGInt.stepOver();
- phpLoop.notifyWait();
+ if (DBGInt.stepOver ()) {
+ phpLoop.notifyWait();
+ }
} catch (Exception e) {
PHPDebugCorePlugin.log(e);
}
public void readStepReturnEnd (PHPStackFrame stackFrame) {
try {
- DBGInt.stepOut();
- phpLoop.notifyWait();
+ if (DBGInt.stepOut ()) {
+ phpLoop.notifyWait();
+ }
} catch (Exception e) {
PHPDebugCorePlugin.log(e);
}
public void readStepIntoEnd (PHPStackFrame stackFrame) {
try {
- DBGInt.stepInto();
- phpLoop.notifyWait();
+ if (DBGInt.stepInto ()) {
+ phpLoop.notifyWait();
+ }
} catch (Exception e) {
PHPDebugCorePlugin.log(e);
}
}
- /*
+ /**
* public PHPStackFrame[] readFrames(PHPThread thread) { //try { //this.println("th " + thread.getId() + " ; f "); //return new
* FramesReader(getMultiReaderStrategy()).readFrames(thread); return null; //} catch (IOException e) { //
* PHPDebugCorePlugin.log(e); // return null; //}
shouldStop = false;
this.setName ("PHPDebuggerLoop");
}
-
+
/**
*
*/
server.setSoTimeout(1); // ???
}
- newDBGInt = new PHPDBGInterface (getReader (newSocket), // Create a new interface
- newSocket.getOutputStream (),
- thisProxy);
+ newDBGInt = new PHPDBGInterface (getReader (newSocket), // The input buffer (frames from dbg)
+ newSocket.getOutputStream (), // The output buffer (frames to dbg)
+ thisProxy,
+ bRelaunch); // Whether the debugger should be relaunched after script termination
newDBGInt.waitResponse (1000); // Wait for the initial DBG response
newDBGInt.flushAllPackets (); // Read and process the DBG response
/**
* The constructor.
*/
-// public PHPDebugCorePlugin() {
-// super();
-// plugin = this;
-// try {
-// resourceBundle = ResourceBundle
-// .getBundle("net.sourceforge.phpdt.internal.debug.core.debugresources"); //$NON-NLS-1$
-// } catch (MissingResourceException x) {
-// resourceBundle = null;
-// }
-// }
+ public PHPDebugCorePlugin() {
+ super();
+ plugin = this;
+ try {
+ resourceBundle = ResourceBundle
+ .getBundle("net.sourceforge.phpdt.internal.debug.core.debugresources"); //$NON-NLS-1$
+ } catch (MissingResourceException x) {
+ resourceBundle = null;
+ }
+ }
public java.util.ResourceBundle getResourceBundle() {
return resourceBundle;
* @param var_list
* @param startIdx
*/
- private boolean ParseEvalRef(String name, PHPVariable parent, Vector list,
- Vector var_list, boolean isSoftRef, int startIdx)
- throws DebugException {
- int v;
+ private boolean ParseEvalRef (String name, PHPVariable parent, Vector list,
+ Vector var_list, boolean isSoftRef, int startIdx
+ ) throws DebugException {
+ int v; // The ref ID (index into vector list)
PHPVariable item;
PHPVariable var_item;
- v = ExtractInt(':', ';', startIdx);
- item = new PHPVariable(fStackFrame, name, parent, "",
- isSoftRef ? PHPValue.PEVT_SOFTREF : PHPValue.PEVT_REF, null);
- v--; // ref ID is 1-based, EvalList is 0-based
+ v = ExtractInt (':', ';', startIdx);
+ item = new PHPVariable (fStackFrame, name, parent, "",
+ isSoftRef ? PHPValue.PEVT_SOFTREF : PHPValue.PEVT_REF, null);
+ v--; // ref ID is 1-based, EvalList is 0-based
- if ((var_list == null) || (v < 0) || (v >= var_list.size())) {
+ if ((var_list == null) ||
+ (v < 0) || (v >= var_list.size ())) { // Check ref ID (index) bounds
//item.ref = item; // self-resolving
return true;
- } else {
- var_item = (PHPVariable) var_list.get(v);
+ }
+ else {
+// This is the original code without the problems of stackframe overflow
+ var_item = (PHPVariable) var_list.get (v); // Get the variable from the list of all variables
+
+ try {
+ item.setValue (var_item.getValue ());
+ item.setReferenceType (var_item.getReferenceType ());
+// ((PHPValue) item.getValue ()).setParent (item); // Set the new variable as parent for all child variables
+ } catch (DebugException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace ();
+ }
+
+ list.add (item);
+
+/*************
+ * this code produces a stackframe overflow if the reference contains loop references
+ var_item = (PHPVariable) var_list.get (v); // Get the referenced variable from the list of variables
+
+ PHPValue new_val = (PHPValue) var_item.getValue ();
- PHPValue new_val = (PHPValue) var_item.getValue();
if (isSoftRef) {
// expand reduced structure to full tree
// each value must have its appropriate parent
try {
- new_val = copyItems(new_val);
+ new_val = copyItems (new_val, 0); // Copy the child variables to the new referenced variable
} catch (CloneNotSupportedException e) {
// never occurs
}
//item.setValue(var_item.getValue());
//item.setReferenceType(var_item.getReferenceType());
//((PHPValue) item.getValue()).setParent(item);
- item.setValue(new_val);
- item.setReferenceType(var_item.getReferenceType());
- new_val.setParent(item);
+ item.setValue (new_val);
+ item.setReferenceType (var_item.getReferenceType ());
+ new_val.setParent (item);
} catch (DebugException e) {
// never occurs
}
- list.add(item);
+ list.add (item);
+ */
}
return true;
/*
* Copy referenced items tree
+ *
+ * @note We have to take care of recursion. We have to stop on recursion else
+ * we get a stack overflow!
+ *
+ * @param val The variable for which we build the tree of all childs
*/
- private PHPValue copyItems(PHPValue val) throws CloneNotSupportedException {
- PHPValue newVal = (PHPValue) val.clone();
- Vector vars = newVal.getChildVariables();
- Vector newVars = new Vector();
+ private PHPValue copyItems (PHPValue val, int nDepth) throws CloneNotSupportedException {
+ PHPValue newVal = (PHPValue) val.clone();
+ Vector vars = newVal.getChildVariables();
+ Vector newVars = new Vector();
+
+ nDepth++;
+
+ if (nDepth >= 10) { // A very quick and very dirty way to avoid stack overflow
+ return newVal;
+ }
+
for (int i = 0; i < vars.size(); i++) {
PHPVariable newVar = (PHPVariable) ((PHPVariable) vars.get(i)).clone();
+
try {
- newVar.setValue(copyItems((PHPValue) newVar.getValue()));
+ newVar.setValue (copyItems ((PHPValue) newVar.getValue(), nDepth));
} catch (DebugException e) {
// never occurs
}
- newVars.add(newVar);
+
+ newVars.add (newVar);
}
- val.setVariables(newVars);
+
+ val.setVariables (newVars);
+
return newVal;
}
public class PHPDebugTarget extends PHPDebugElement implements IPHPDebugTarget, ILaunchListener,
IDebugEventSetListener {
- private IProcess process;
-
- private ILaunch launch;
-
- private PHPThread[] threads = new PHPThread[0];
-
- private PHPDBGProxy phpDBGProxy;
+ private IProcess process;
+ private ILaunch launch;
+ private PHPThread[] threads = new PHPThread[0];
+ private PHPDBGProxy phpDBGProxy;
private class State {
private boolean isTerminated = false;
-
- private boolean isSuspended = false;
+ private boolean isSuspended = false;
boolean isTerminated() {
return isTerminated;
**********************************************************************/
package net.sourceforge.phpdt.internal.debug.core.model;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Vector;
public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Comparable {
private PHPThread thread; // The thread to which this stackframe belongs
- private String file; // The file name???
+ private String file; // The file name???
private int lineNumber;
private int index;
private int modno;
+ private PHPVariable[] variables; //
private int scope_id; // scope id
- private Vector varList; // Variables list
- private String description; // The source file name with the full path on target/remote system
+ private Vector varList; // Variables list
+ private String description; // The source file name with the full path on target/remote system
private boolean fUpToDate; // Indicates whether the variable list within this stackframe is
// up-to-date
private boolean fAvailable; // Needed when updating the stackframe list, shows whether the stackframe
// is within the list which was received from dbg
+ private boolean fDebug = true;
/**
*
* @param modno
* @param scope_id
*/
- public PHPStackFrame(PHPThread thread, String file, int line, int index,
- String desc, int modno, int scope_id) {
- super(null);
-
- this.lineNumber = line;
- this.index = index;
- this.file = file;
- this.thread = thread;
+ public PHPStackFrame (PHPThread thread, String file, int line, int index,
+ String desc, int modno, int scope_id) {
+ super (null);
+
+ this.lineNumber = line;
+ this.index = index;
+ this.file = file;
+ this.thread = thread;
this.description = desc;
- this.modno = modno;
- this.scope_id = scope_id;
- this.varList = new Vector();
- this.fUpToDate = false;
+ this.modno = modno;
+ this.scope_id = scope_id;
+ this.varList = new Vector();
+ this.fUpToDate = false;
}
// /**
// }
/**
- *
+ *
* @return scope id
*/
public int getScopeID() {
}
/**
- *
+ *
*/
public void setScopeID(int scope_id) {
this.scope_id = scope_id;
*
* TODO Check where this recursion can come from.
* Whether this back reference is legal or a bug.
- *
+ *
* Typically $GLOBALS contains $GLOBALS
*
* @param var
* <li> true if the PHPValue is
* </ul>
*/
- private boolean hasRecursion(PHPVariable var) {
+ private boolean hasRecursion (PHPVariable var) {
PHPVariable parentVar;
PHPValue val;
- val = (PHPValue) var.getValue(); // Get the PHPValue from the current PHPVariable
+ val = (PHPValue) var.getValue (); // Get the PHPValue from the current PHPVariable
while (var != null) { // As long as we have PHPVariable
- parentVar = var.getParent(); // Get the parent PHPVariable
+ parentVar = var.getParent (); // Get the parent PHPVariable
if (parentVar != null) { // Is there a parent?
- if (parentVar.getValue().equals(val)) { // Get the PHPValue for the parent PHPVariable and check
+ if (parentVar.getValue ().equals (val)) { // Get the PHPValue for the parent PHPVariable and check
// whether it is the same
return true; // Return, if we have recursion
}
* @param varListOld The 'static' list of variables which are to be updated.
* @param varListNew The new list of (current) variables from DBG.
*/
- private void updateVariableList(Vector varListOld, Vector varListNew) {
+ private void updateVariableList (Vector varListOld, Vector varListNew) {
PHPVariable varOld; // The variable from the 'static' list
PHPVariable varNew; // The variable from the DBG list
PHPValue valOld; // The value of the current variable from 'static' list
varOld = (PHPVariable) varListOld.get(o); // Get the static variable
if (varNew.getName().equals(varOld.getName())) { // Did we found the variable within the 'static' list?
- valOld = (PHPValue) varOld.getValue(); // Get the value from 'static'
- valNew = (PHPValue) varNew.getValue(); // Get the value from DBG
+ valOld = (PHPValue) varOld.getValue (); // Get the value from 'static'
+ valNew = (PHPValue) varNew.getValue (); // Get the value from DBG
try {
if (valOld.hasVariables() || // If the 'static' value has child variables
- valNew.hasVariables()) { // or if the DBG value has child variables
- if (!hasRecursion(varOld) && !hasRecursion(varNew)) { // Both branches should not have a recursion
- updateVariableList(valOld.getChildVariables(), // Update the variable list for the child variables
- valNew.getChildVariables());
+ valNew.hasVariables()) { // or if the DBG value has child variables
+ if (!hasRecursion(varOld) &&
+ !hasRecursion(varNew)) { // Both branches should not have a recursion
+ updateVariableList (
+ valOld.getChildVariables (), // Update the variable list for the child variables
+ valNew.getChildVariables ());
}
}
- if (!valOld.getValueString().equals(
- valNew.getValueString())) { // Has the value changed?
- valOld.setValueString(valNew.getValueString()); // Yes, set the 'static' value (variable) to the new value
- varOld.setValueChanged(true); // and set the 'has changed' flag, so that the variable view
+
+ if (!valOld.getValueString ().equals (
+ valNew.getValueString ())) { // Has the value changed?
+ valOld.setValueString (valNew.getValueString ()); // Yes, set the 'static' value (variable) to the new value
+ varOld.setValueChanged (true); // and set the 'has changed' flag, so that the variable view
// could show the user the changed status with a different
// color
}
*/
public IVariable[] getVariables() throws DebugException {
if (!fUpToDate) {
- resetHasChangedInfo(varList);
- updateVariableList(varList, this.getPHPDBGProxy().readVariables(this));
+ resetHasChangedInfo (varList);
+ updateVariableList (varList, this.getPHPDBGProxy ().readVariables (this));
fUpToDate = true;
- Collections.sort(varList, new PHPVariableComparator());
+
+ variables = (PHPVariable[]) varList.toArray (new PHPVariable[varList.size ()]);
+ Arrays.sort (variables, new PHPVariableComparator ());
+/*
+ Collections.sort (varList, new PHPVariableComparator ());
+ */
}
- return (PHPVariable[]) varList.toArray(new PHPVariable[varList.size()]);
+// return (PHPVariable[]) varList.toArray (new PHPVariable[varList.size ()]);
+
+ return variables; // Give the array back to user interface
}
/**
int i;
for (i = 0; i < varList.size(); i++) { // For all variables
- variable = (PHPVariable) varList.get(i); // Get the variable
- value = (PHPValue) variable.getValue(); // Get the value of the variable
+ variable = (PHPVariable) varList.get (i); // Get the variable
+ value = (PHPValue) variable.getValue (); // Get the value of the variable
try {
- if (value.hasVariables()) { // Does the variable/value have children
- if (!hasRecursion(variable)) { // Don't follow recursive variable/values
- PHPVariable var = findVariable(value.getChildVariables(), varname);
+ if (value.hasVariables ()) { // Does the variable/value have children
+ if (!hasRecursion (variable)) { // Don't follow recursive variable/values
+ PHPVariable var = findVariable (value.getChildVariables(), varname);
+
if (var != null) {
return var;
}
}
}
- if (variable.getName().equals(varname)) {
+
+ if (variable.getName().equals (varname)) {
return variable;
}
} catch (DebugException e) { // That's, because of the hasVariables method
StringBuffer name = new StringBuffer();
if (!this.getDescription().equals("")) {
- name.append(this.getDescription());
+ name.append (this.getDescription());
} else {
- name.append(this.getFileName());
+ name.append (this.getFileName());
}
- name.append(" [line ");
- name.append(this.getLineNumber());
- name.append("]");
+ name.append (" [line ");
+ name.append (this.getLineNumber());
+ name.append ("]");
+
+ if (fDebug) {
+ System.out.println ("PHPStackFrame getName: " + name.toString ());
+ }
return name.toString();
}
thread.prepareForResume(DebugEvent.STEP_INTO); // Don't know why, but this is necessary
this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this);
-
+
// Commented out sending the RESUME event because it was already sent by prepareForResume.
// The second RESUME event leads only to a little flickering within the variables view.
// It is also not clear why this event was necessary in eclipse < 3.2
// Also sending a SUSPEND event here leads to a total rebuild of the variables view.
// (eclipse 3.2 has a build in timeout of 500 ms which leads to a auto suspend, with
// no flickering... but why???)
- //
+ //
//ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_INTO);
//DebugPlugin.getDefault().fireDebugEventSet (new DebugEvent[] { ev });
}
this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this);
// See comment within the previous stepInto method.
- //
+ //
//ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_OVER);
//DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
}
* <li> 1 if the index of this stackframe is greater.
* </ul>
*/
- public int compareTo(Object obj) {
+ public int compareTo (Object obj) {
if (!(obj instanceof PHPStackFrame)) {
- throw new IllegalArgumentException("A PHPStackFrame can only be compared with another PHPStackFrame");
+ throw new IllegalArgumentException ("A PHPStackFrame can only be compared with another PHPStackFrame");
}
+
int frameIndex = ((PHPStackFrame) obj).getIndex();
+
if (index < frameIndex) {
return -1;
} else if (index > frameIndex) {
return 1;
}
+
return 0;
}
}
public class PHPThread extends PHPDebugElement implements IThread {
private PHPStackFrame[] frames; // The stackframes which belongs to this thread
- private PHPDebugTarget target; //
+ private PHPDebugTarget target; // This is doppel moppel, fTarget exists in PHPDebugElement
private String name; //
private int id; // The port number through which we communicate to DBG
+ private boolean fDebug = true;
private class State {
private boolean isSuspended = false;
*/
public IStackFrame[] getStackFrames () throws DebugException {
if (isSuspended()) {
+ if (fDebug) {
+ System.out.println ("PHPThread getStackFrames");
+ }
+
return ((PHPDebugTarget)getDebugTarget()).getStackFrames();
} else {
return new IStackFrame[0];
DebugEvent ev;
state.setSuspended (false); // We will leave the suspended state
- this.frames = null; // Reset the stackframes
+ frames = null; // Reset the stackframes
ev = new DebugEvent (this, DebugEvent.RESUME, de); // Create an event resume by stepping
DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev }); // Fire the event
"soft reference" }; // 9
public final static int PEVT_UNKNOWN = 0;
- public final static int PEVT_LONG = 1;
+ public final static int PEVT_LONG = 1;
public final static int PEVT_DOUBLE = 2;
public final static int PEVT_STRING = 3;
- public final static int PEVT_ARRAY = 4;
+ public final static int PEVT_ARRAY = 4;
public final static int PEVT_OBJECT = 5;
public final static int PEVT_BOOLEAN = 6;
- public final static int PEVT_RESOURCE = 7;
+ public final static int PEVT_RESOURCE = 7;
public final static int PEVT_REF = 8;
public final static int PEVT_SOFTREF = 9;
private int fValueType; // The type of this value (see the PEVT_... values)
//private boolean hasChildren; // This value (variable) has children (more variables)
- private String fValueString; // The value of this variable as text
- private Vector fVariables; // The children of this variable (other variables) if any
+ private String fValueString; // The value of this variable as text
+ private Vector fVariables; // The children of this variable (other variables) if any
private PHPStackFrame fStackFrame; // The stackframe this value (variable) belongs to
private boolean fHasChanged; // The value has changed between two suspends
// This variable was moved from PHPVariable due to the fact,
* @param fValueType The type of this value (see the PEVT_... values).
* @param subitems This value has subitems.
*/
- public PHPValue(PHPStackFrame frame, String value, int fValueType, Vector subitems) {
- this.fValueType = fValueType;
+ public PHPValue (PHPStackFrame frame, String value, int fValueType, Vector subitems) {
+ this.fValueType = fValueType;
this.fValueString = value;
- this.fStackFrame = frame;
- this.fHasChanged = false;
- this.fSorted = false;
+ this.fStackFrame = frame;
+ this.fHasChanged = false;
+ this.fSorted = false;
if (subitems != null) { // If there are children for this value (variable)
this.fVariables = new Vector(subitems); // Then add the children to this value (variable)
*/
protected Object clone() throws CloneNotSupportedException {
PHPValue val = new PHPValue();
- val.fValueType = fValueType;
- val.fValueString = fValueString;
- val.fVariables = fVariables;
- val.fStackFrame = fStackFrame;
- val.fHasChanged = fHasChanged;
- val.fSorted = fSorted;
+
+ val.fValueType = fValueType;
+ val.fValueString = fValueString;
+ val.fVariables = fVariables;
+ val.fStackFrame = fStackFrame;
+ val.fHasChanged = fHasChanged;
+ val.fSorted = fSorted;
+
return val;
}
public class PHPVariable implements IVariable {
private PHPValue fValue; // The value of this variable
- private String fName; // The name of the variable
+ private String fName; // The name of the variable
private PHPStackFrame fStackFrame; // The stackframe this variable belongs to
private PHPVariable fParent; // The parent variable (a back link)
- private String fLongName; // The qualified name
- private boolean fModifiable = true;
+ private String fLongName; // The qualified name
+ private boolean fModifiable = true;
/**
*
* @param valueType The type of the value (e.g. int, double, string etc.) @see PHPValue
* @param subitems
*/
- public PHPVariable(PHPStackFrame frame, String name, PHPVariable parent,
- String value, int valueType, Vector subitems) {
+ public PHPVariable (PHPStackFrame frame, String name, PHPVariable parent,
+ String value, int valueType, Vector subitems) {
this.fStackFrame = frame;
- this.fValue = new PHPValue(frame, value, valueType, subitems);
- this.fParent = parent;
+ this.fValue = new PHPValue(frame, value, valueType, subitems);
+ this.fParent = parent;
- setName(name);
+ setName (name);
}
/**
*/
public void setName(String name) {
if ((fParent == null) || // If we have no parent for this variable
- (fParent.getName() == "")) { // or we have a parent which is just a simple node ???
+ (fParent.getName() == "")) { // or we have a parent which is just a simple node ???
fLongName = name; // Set the long name
fName = name; // and set the name
}
switch (fParent.getReferenceType()) { // Get the type of the parent variable
- case PHPValue.PEVT_ARRAY: // It's an array
- fName = "['" + name + "']"; // So set the variable name as [name]
- fLongName = fParent.getLongName() + fName; // Set the longname to parentVariableLongname[name]
- break;
+ case PHPValue.PEVT_ARRAY: // It's an array
+ fName = "['" + name + "']"; // So set the variable name as [name]
+ fLongName = fParent.getLongName() + fName; // Set the longname to parentVariableLongname[name]
+ break;
- case PHPValue.PEVT_OBJECT: // It's an object
- fName = name; // Set the name to name
- fLongName = fParent.getLongName() + "->" + fName; // Set the longname to parentVariableLongname.name
- break;
+ case PHPValue.PEVT_OBJECT: // It's an object
+ fName = name; // Set the name to name
+ fLongName = fParent.getLongName() + "->" + fName;// Set the longname to parentVariableLongname.name
+ break;
- default:
- fName = name; // Set the name to name
- fLongName = name; // Set the Longname to name
- break;
+ default:
+ fName = name; // Set the name to name
+ fLongName = name; // Set the Longname to name
+ break;
}
}
public void setParent(PHPVariable parent) {
this.fParent = parent;
- switch (fParent.getReferenceType()) {
- case PHPValue.PEVT_ARRAY:
- fLongName = fParent.getLongName() + fName;
- break;
- case PHPValue.PEVT_OBJECT:
- fLongName = fParent.getLongName() + "->" + fName;
- break;
- default:
- fLongName = fName;
- break;
+ switch (fParent.getReferenceType ()) {
+ case PHPValue.PEVT_ARRAY:
+ fLongName = fParent.getLongName() + fName;
+ break;
+
+ case PHPValue.PEVT_OBJECT:
+ fLongName = fParent.getLongName() + "->" + fName;
+ break;
+
+ default:
+ fLongName = fName;
+ break;
}
}
/**
* @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
*/
- public void setValue(String expression) throws DebugException {
+ public void setValue (String expression) throws DebugException {
String evalString;
- if (fValue.getReferenceType() == PHPValue.PEVT_STRING)
+
+ if (fValue.getReferenceType () == PHPValue.PEVT_STRING) {
evalString = fLongName + "=\"" + expression + "\"";
- else
+ }
+ else {
evalString = fLongName + "=" + expression;
- PHPVariable[] vars = fStackFrame.getPHPDBGProxy().eval(fStackFrame,
- evalString);
+ }
+ PHPVariable[] vars = fStackFrame.getPHPDBGProxy ().eval (fStackFrame, evalString);
+///*
if (vars == null || vars.length == 0) {
- vars = fStackFrame.getPHPDBGProxy().eval(fStackFrame, fLongName);
+ vars = fStackFrame.getPHPDBGProxy ().eval (fStackFrame, fLongName);
+
if (vars == null || vars.length == 0) {
- int code = 0;
- String msg = "Could not set " + expression + " to " + fLongName;
- Status status = new Status(Status.ERROR,
- PHPDebugCorePlugin.PLUGIN_ID, code, msg, null);
- PHPDebugCorePlugin.log(status);
- throw new DebugException(status);
+ int code = 0;
+ String msg = "Could not set " + expression + " to " + fLongName;
+ Status status = new Status (Status.ERROR, PHPDebugCorePlugin.PLUGIN_ID, code, msg, null);
+ PHPDebugCorePlugin.log (status);
+
+ throw new DebugException (status);
}
}
-
+//*/
fValue = vars[0].fValue;
+///*
+ if (fValue.hasVariables ()) { // set parent if new value has children
+ Vector variables = fValue.getChildVariables ();
+
+ for (int i = 0; i < variables.size (); i++) {
+ PHPVariable var = (PHPVariable) variables.get (i);
+
+ var.setParent (this);
- // set parent if new value has children
- if (fValue.hasVariables()) {
- Vector variables = fValue.getChildVariables();
- for (int i = 0; i < variables.size(); i++) {
- PHPVariable var = (PHPVariable) variables.get(i);
- var.setParent(this);
- // adjust name if value type is array
- // (still bare name. make "['name']")
- if (fValue.getReferenceType() == PHPValue.PEVT_ARRAY) {
- var.setName(var.getName());
+ if (fValue.getReferenceType() == PHPValue.PEVT_ARRAY) { // adjust name if value type is array
+ var.setName (var.getName ()); // (still bare name. make "['name']")
}
}
}
- DebugPlugin.getDefault().fireDebugEventSet(
- new DebugEvent[] { new DebugEvent(this, DebugEvent.CHANGE,
- DebugEvent.CONTENT) });
+ DebugPlugin.getDefault().fireDebugEventSet (new DebugEvent[] {
+ new DebugEvent (this, DebugEvent.CHANGE, DebugEvent.CONTENT) });
+//*/
}
/**
/**
* Set whether this variable can be modified (default is true)
- *
+ *
* for Global Variables root element only
*/
public void setModifiable(boolean modifiable) {
*/
protected Object clone() throws CloneNotSupportedException {
PHPVariable var = new PHPVariable();
- var.fValue = fValue;
- var.fName = fName;
+
+ var.fValue = fValue;
+ var.fName = fName;
var.fStackFrame = fStackFrame;
- var.fParent = fParent;
- var.fLongName = fLongName;
+ var.fParent = fParent;
+ var.fLongName = fLongName;
var.fModifiable = fModifiable;
+
return var;
}