X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java index 79a9ae5..5769aab 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java @@ -14,7 +14,6 @@ package net.sourceforge.phpdt.internal.debug.core; import java.io.BufferedReader; import java.io.IOException; import java.io.OutputStream; -import java.util.Arrays; import java.util.Collections; import java.util.Vector; @@ -47,7 +46,6 @@ public class PHPDBGInterface { private OutputStream os; // The stream which goes to DBG private boolean shouldStop = false; private String evalRet = new String(""); - //private String serGlobals = new String(""); private int rawCounter = 1000; // An rawData frame ID counter private PHPDBGProxy proxy = null; private int lastCmd = -1; @@ -427,64 +425,43 @@ public class PHPDBGInterface { PHPDBGFrame DBGFrame1; PHPDBGEvalString evalStr; + // get global variables (and assign them to 'main()' stackframe) Vector globalList = new Vector(); - // IStackFrame[] stacks = stack.getThread().getStackFrames(); - // ( PHPStackFrame.getThread().getStackFrames() returns DBGStackList ) - if (DBGStackList.length > 1) { - // get global variables (and assign them to 'main()' stackframe) - globalList = getVariables(DBGStackList[DBGStackList.length - 1], PHPDBGBase.GLOBAL_SCOPE_ID); - if (!globalList.isEmpty()) { - // remove unexpected '$this=?' variable - PHPVariable var = (PHPVariable) globalList.get(0); - PHPValue val = (PHPValue) var.getValue(); - Vector workList = val.getChildVariables(); - for (int i = 0; i < workList.size(); i++) { - if (((PHPVariable) workList.get(i)).getName().equals("$this")) { - workList.remove(i); - break; - } + globalList = getVariables(DBGStackList[DBGStackList.length - 1], PHPDBGBase.GLOBAL_SCOPE_ID); + if (!globalList.isEmpty()) { + // remove unexpected '$this=?' variable + PHPVariable var = (PHPVariable) globalList.get(0); + PHPValue val = (PHPValue) var.getValue(); + Vector workList = val.getChildVariables(); + for (int i = 0; i < workList.size(); i++) { + if (((PHPVariable) workList.get(i)).getName().equals("$this")) { + workList.remove(i); + break; } - var.setName(GlobalVariablesTitle); - var.setModifiable(false); } + var.setName(GlobalVariablesTitle); + var.setModifiable(false); } -// DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_REQUEST); // -// DBGFrame1 = new PHPDBGFrame (PHPDBGBase.FRAME_EVAL); // -// -// DBGFrame1.addInt (0); // istr = raw data ID -// DBGFrame1.addInt (1); // scope_id = -1 means current location, 0 never used, +1 first depth -// -// DBGPacket.addFrame (DBGFrame1); // Add command data -// -// if (proxy.getSocket ().isClosed ()) { // Do we have a socket for DBG communication? -// return new Vector (); // No, then leave here with an empty vector -// } -// -// serGlobals = ""; -// DBGPacket.sendPacket (os); // Send the request to DBG -// -// waitResponse (1000); // Wait for the DBG response (1 second) -// flushAllPackets (); // Read and process the response from DBG -// -// evalStr = new PHPDBGEvalString (stack, serGlobals); // Process serialized variables -// DBGVarList = evalStr.getVariables (); - - int scopeID = stack.getScopeID(); - if (scopeID == PHPDBGBase.CURLOC_SCOPE_ID) { - // current stackframe - DBGVarList = getVariables(stack, PHPDBGBase.CURLOC_SCOPE_ID); - } else if ((scopeID == PHPDBGBase.CURLOC_SCOPE_ID + 1) && !globalList.isEmpty()) { + int scopeID = stack.getScopeID(); + 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; + + } else if (scopeID == PHPDBGBase.CURLOC_SCOPE_ID) { + // current stackframe + DBGVarList = getVariables(stack, PHPDBGBase.CURLOC_SCOPE_ID); + } else { // back-trace stackframe - // Never: DBGVarList = getVariables(stack, scopeID); + DBGVarList = getVariables(stack, scopeID); // DBG 2.15.5 causes Application Error (on win32) in some cases - DBGVarList.clear(); + //DBGVarList.clear(); } if (DBGVarList.size() > 0) { // Did we get back variables? @@ -581,7 +558,11 @@ public class PHPDBGInterface { rawCounter++; DBGFrame1.addInt(rawCounter); // istr = raw data ID //DBGFrame1.addInt(1); // scope_id = -1 means current location, 0 never used, +1 first depth - DBGFrame1.addInt(stack.getScopeID()); + int scope_id = stack.getScopeID(); + if (DBGStackList.length == 1 || scope_id == PHPDBGBase.CURLOC_SCOPE_ID + 1) { + scope_id = PHPDBGBase.GLOBAL_SCOPE_ID; + } //- + DBGFrame1.addInt(scope_id); DBGFrame2.addInt(rawCounter); // FRAME_RAWDATA ID DBGFrame2.addInt(evalString.length() + 1); // length of rawdata (+ null char) @@ -1035,7 +1016,6 @@ public class PHPDBGInterface { evalRet = getRawFrameData (entirePack, dbg_eval_tmp[1]); // evalString = getRawFrameData (entirePack, dbg_eval_tmp[0]); // - //serGlobals = evalRet; // break; case PHPDBGBase.FRAME_BPS: //