Modified: 1764120 - Variables View doesn't show global vars in class context
authortoshihiro <toshihiro>
Tue, 7 Aug 2007 01:08:38 +0000 (01:08 +0000)
committertoshihiro <toshihiro>
Tue, 7 Aug 2007 01:08:38 +0000 (01:08 +0000)
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGBase.java
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/debugresources.properties
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDBGEvalString.java
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPVariable.java

index f814943..86a45cc 100644 (file)
@@ -15,44 +15,48 @@ public class PHPDBGBase {
        // Constants
        // php-engine commands/events
        public static final int DBGC_REPLY                      = 0x0000;                               // reply to previous DBGA_REQUEST request
-       public static final int DBGC_STARTUP            = 0x0001;                               // script startup
-       public static final int DBGC_END                        = 0x0002;                               // script done
+       public static final int DBGC_STARTUP                    = 0x0001;                               // script startup
+       public static final int DBGC_END                                = 0x0002;                               // script done
        public static final int DBGC_BREAKPOINT         = 0x0003;                               // user definded breakpoint occured
        public static final int DBGC_STEPINTO_DONE      = 0x0004;                               // step to the next statement is completed
        public static final int DBGC_STEPOVER_DONE      = 0x0005;                               // step to the next statement is completed
-       public static final int DBGC_STEPOUT_DONE       = 0x0006;                               // step to the next statement is completed
+       public static final int DBGC_STEPOUT_DONE               = 0x0006;                               // step to the next statement is completed
        public static final int DBGC_EMBEDDED_BREAK     = 0x0007;                               // breakpoint caused by DebugBreak() function
        public static final int DBGC_ERROR                      = 0x0010;                               // error occured
-       public static final int DBGC_LOG                        = 0x0011;                               // logging support
-       public static final int DBGC_SID                        = 0x0012;                               // send SID
+       public static final int DBGC_LOG                                = 0x0011;                               // logging support
+       public static final int DBGC_SID                                = 0x0012;                               // send SID
        public static final int DBGC_PAUSE                      = 0x0013;                               // pause current session as soon as possible
 
-       public static final char[] DBGA_CONTINUE        = IntToChar4(0x8001);   // php should continue run
-       public static final char[] DBGA_STOP            = IntToChar4(0x8002);
-       public static final char[] DBGA_STEPINTO        = IntToChar4(0x8003);
-       public static final char[] DBGA_STEPOVER        = IntToChar4(0x8004);
+       public static final char[] DBGA_CONTINUE                = IntToChar4(0x8001);   // php should continue run
+       public static final char[] DBGA_STOP                    = IntToChar4(0x8002);
+       public static final char[] DBGA_STEPINTO                = IntToChar4(0x8003);
+       public static final char[] DBGA_STEPOVER                = IntToChar4(0x8004);
        public static final char[] DBGA_STEPOUT         = IntToChar4(0x8005);
        public static final char[] DBGA_IGNORE          = IntToChar4(0x8006);
        public static final char[] DBGA_REQUEST         = IntToChar4(0x8010);   // debugger client requests some information from PHP engine
 
        public static final int FRAME_STACK                     = 100000;                               // "call:stack" - e.g. backtrace
-       public static final int FRAME_SOURCE            = 100100;                               // source text
+       public static final int FRAME_SOURCE                    = 100100;                               // source text
        public static final int FRAME_SRC_TREE          = 100200;                               // tree of source files
-       public static final int FRAME_RAWDATA           = 100300;                               // raw data or string
+       public static final int FRAME_RAWDATA                   = 100300;                               // raw data or string
        public static final int FRAME_ERROR                     = 100400;                               // error notification
        public static final int FRAME_EVAL                      = 100500;                               // evaluating/watching
-       public static final int FRAME_BPS                       = 100600;                               // set/remove breakpoint
-       public static final int FRAME_BPL                       = 100700;                               // breakpoint(s) request = get the list
-       public static final int FRAME_VER                       = 100800;                               // version request
-       public static final int FRAME_SID                       = 100900;                               // session id info
+       public static final int FRAME_BPS                               = 100600;                               // set/remove breakpoint
+       public static final int FRAME_BPL                               = 100700;                               // breakpoint(s) request = get the list
+       public static final int FRAME_VER                               = 100800;                               // version request
+       public static final int FRAME_SID                               = 100900;                               // session id info
        public static final int FRAME_SRCLINESINFO      = 101000;                               // source lines info
-       public static final int FRAME_SRCCTXINFO        = 101100;                               // source contexts info
-       public static final int FRAME_LOG                       = 101200;                               // logging
+       public static final int FRAME_SRCCTXINFO                = 101100;                               // source contexts info
+       public static final int FRAME_LOG                               = 101200;                               // logging
        public static final int FRAME_PROF                      = 101300;                               // profiler
-       public static final int FRAME_PROF_C            = 101400;                               // profiler counter/accuracy
-       public static final int FRAME_SET_OPT           = 101500;                               // set/update options
+       public static final int FRAME_PROF_C                    = 101400;                               // profiler counter/accuracy
+       public static final int FRAME_SET_OPT                   = 101500;                               // set/update options
 
-       public static final char[] DBGSYNC                      = { 0, 0, (char) 89, (char) 83};        // DBG syncronization chars
+       public static final int CURLOC_SCOPE_ID                 = 1;                                    // nested locations are 2,3... and so on in backward order,
+                                                                                                                                                       //  so 2 represents most out-standing stack context
+       public static final int GLOBAL_SCOPE_ID                 = -1;                                   // it is global context, not stacked
+
+       public static final char[] DBGSYNC                      = { 0, 0, (char) 89, (char) 83 };       // DBG syncronization chars
 
        // Session Types
        public static final int DBG_COMPAT                      = 0x0001;
@@ -61,21 +65,21 @@ public class PHPDBGBase {
        public static final int DBG_EMB                         = 0x0004;
 
        public static final int BPS_DELETED                     = 0;
-       public static final int BPS_DISABLED            = 1;
+       public static final int BPS_DISABLED                    = 1;
        public static final int BPS_ENABLED                     = 2;
        public static final int BPS_UNRESOLVED          = 0x100;
 
        public static final int E_ERROR                         = (1<<0L);
-       public static final int E_WARNING                       = (1<<1L);
+       public static final int E_WARNING                               = (1<<1L);
        public static final int E_PARSE                         = (1<<2L);
-       public static final int E_NOTICE                        = (1<<3L);
-       public static final int E_CORE_ERROR            = (1<<4L);
+       public static final int E_NOTICE                                = (1<<3L);
+       public static final int E_CORE_ERROR                    = (1<<4L);
        public static final int E_CORE_WARNING          = (1<<5L);
        public static final int E_COMPILE_ERROR         = (1<<6L);
-       public static final int E_COMPILE_WARNING       = (1<<7L);
-       public static final int E_USER_ERROR            = (1<<8L);
+       public static final int E_COMPILE_WARNING               = (1<<7L);
+       public static final int E_USER_ERROR                    = (1<<8L);
        public static final int E_USER_WARNING          = (1<<9L);
-       public static final int E_USER_NOTICE           = (1<<10L);
+       public static final int E_USER_NOTICE                   = (1<<10L);
 
        public PHPDBGBase() {
        }
index 0ae3bc0..79a9ae5 100644 (file)
@@ -14,13 +14,14 @@ package net.sourceforge.phpdt.internal.debug.core;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Vector;
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Vector;
 
 import net.sourceforge.phpdt.internal.debug.core.model.PHPDBGEvalString;
 import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame;
-import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable;
 import net.sourceforge.phpdt.internal.debug.core.model.PHPValue;
+import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable;
 
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -31,28 +32,31 @@ import org.eclipse.debug.core.DebugException;
  *
  */
 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 ();
-       private PHPStackFrame[] DBGStackList;
-       private Vector                  DBGMods          = new Vector ();                       // The module names and their numbers
-       private Vector          stackListOld = 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 String                  serGlobals       = 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 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;
+       private int                             sid = 0;
+       private boolean                         stopOnError = false;
+       private char[]                  lastCommand = new char[4];
+
+       private static final String GlobalVariablesTitle = PHPDebugCorePlugin
+                       .getResourceString("VariablesView.GlobalVariables.title");
 
        /**
         * @param in    The input stream (communication from DBG).
@@ -418,52 +422,121 @@ public class PHPDBGInterface {
         * @param stack The stackframe for which we want the variables.
         * @return      The array of variables
         */
-       public synchronized Vector getVariables (PHPStackFrame stack) throws IOException, DebugException  {
+       public synchronized Vector getVariables(PHPStackFrame stack) throws IOException, DebugException {
                PHPDBGPacket            DBGPacket;
-               PHPDBGFrame             DBGFrame1;
+               PHPDBGFrame             DBGFrame1;
                PHPDBGEvalString        evalStr;
 
-               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 
+               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;
+                                       }
+                               }
+                               var.setName(GlobalVariablesTitle);
+                               var.setModifiable(false);
+                       }
                }
 
-               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 ();
+//             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()) {
+                       // 'main()' stackframe
+                       PHPVariable var = (PHPVariable) globalList.get(0);
+                       PHPValue val = (PHPValue) var.getValue();
+                       DBGVarList = val.getChildVariables();
+                       return DBGVarList;
+               } else {
+                       // back-trace stackframe
+                       // Never: DBGVarList = getVariables(stack, scopeID);
+                       // DBG 2.15.5 causes Application Error (on win32) in some cases
+                       DBGVarList.clear();
+               }
 
-               if (DBGVarList.size () > 0) {                                                           // Did we get back variables?
-                       PHPVariable var = (PHPVariable) DBGVarList.get (0);             // Yes, then get the first PHPVariable
-                       PHPValue    val = (PHPValue) var.getValue ();           // Get the value
+               if (DBGVarList.size() > 0) {                                                            // Did we get back variables?
+                       PHPVariable var = (PHPVariable) DBGVarList.get(0);              // Yes, then get the first PHPVariable
+                       PHPValue    val = (PHPValue) var.getValue();                    // Get the value
 
-                       if (var.getName ().equals ("")) {                                               // Is the root node an empty node (usually it is)
-                               DBGVarList = val.getChildVariables ();              // Then remove the empty node.
+                       if (var.getName().equals("")) {                                                 // Is the root node an empty node (usually it is)
+                               DBGVarList = val.getChildVariables();                           // Then remove the empty node.
                                                                                                                                        // With removing the empty root node, it wouldn't be necessary to
                                                                                                                                        // set the name to an empty string. So the code below is just for
                                                                                                                                        // info or in case the users want to have the empty root node.
 
                                                                                                                                        // The eclipse variable view cannot handle Variables which have an empty name
                                                                                                                                        // when it comes to variable tree restore operation. Without a name, no restore!
-                               var.setName (" ");                                                              // Give a name to the variable root node. Even if it is only a space :-)
+                               //var.setName (" ");                                                            // Give a name to the variable root node. Even if it is only a space :-)
                        }                                                                                                               // TODO the best would be to remove the empty root node, but this would
                                                                                                                                        // require a understanding and reworking of the PHPDBGEvalstring class.
                }
 
+               if (!globalList.isEmpty()) {
+                       DBGVarList.add(globalList.get(0));
+               }
+
                return DBGVarList;                                                                                      // Return the variables as list
        }
 
        /**
+        * 
+        * @throws IOException 
+        */
+       private Vector getVariables(PHPStackFrame stack, int scope_id) throws IOException {
+               PHPDBGPacket DBGPacket = new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
+               PHPDBGFrame DBGFrame1 = new PHPDBGFrame(PHPDBGBase.FRAME_EVAL);
+
+               DBGFrame1.addInt(0);
+               DBGFrame1.addInt(scope_id);
+
+               DBGPacket.addFrame(DBGFrame1);
+               evalRet = "";
+
+               if (proxy.getSocket().isClosed()) {
+                       return new Vector();
+               }
+               DBGPacket.sendPacket(os);
+               waitResponse(1000);
+               flushAllPackets();
+
+               PHPDBGEvalString evalStr = new PHPDBGEvalString(stack, evalRet);
+               return evalStr.getVariables();
+       }
+
+       /**
         *
         * @param logString
         */
@@ -500,14 +573,15 @@ public class PHPDBGInterface {
                flushAllPackets();
        }
 
-       public synchronized PHPVariable[] evalBlock(PHPStackFrame stack, String evalString) throws IOException, DebugException  {
+       public synchronized PHPVariable[] evalBlock(PHPStackFrame stack, String evalString) throws IOException, DebugException {
                PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
                PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_EVAL);
                PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
 
                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(1);                                          // scope_id = -1 means current location, 0 never used, +1 first depth
+               DBGFrame1.addInt(stack.getScopeID());
 
                DBGFrame2.addInt(rawCounter);                           // FRAME_RAWDATA ID
                DBGFrame2.addInt(evalString.length() + 1);      // length of rawdata (+ null char)
@@ -519,8 +593,8 @@ public class PHPDBGInterface {
                // Add command data
                DBGPacket.addFrame(DBGFrame1);
 
-               if (proxy.getSocket ().isClosed ()) {                       // Do we have a socket for DBG communication?
-                       return null;                                                                                    //  No, then leave here
+               if (proxy.getSocket().isClosed()) {                     // Do we have a socket for DBG communication?
+                       return null;                                                    //  No, then leave here
                }
                DBGPacket.sendPacket(os);
 
@@ -530,7 +604,6 @@ public class PHPDBGInterface {
                PHPDBGEvalString evalStr=new PHPDBGEvalString(stack,evalRet);
 
                return evalStr.getVars();
-
        }
 
        /**
@@ -660,6 +733,7 @@ public class PHPDBGInterface {
                                stackFrameNew.getLineNumber () == stackFrameOld.getLineNumber ()) {     // Did we find the sent stackframe within the list of old stackframes?
                                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
                        }
                }
@@ -741,6 +815,7 @@ public class PHPDBGInterface {
                                if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ())) {// Did we find the sent stackframe within the list of old stackframes?
                                        stackFrameOld.setLineNumber (stackFrameNew.getLineNumber ());
                                        stackFrameOld.setIndex (stackFrameNew.getIndex ());
+                                       stackFrameOld.setScopeID(stackFrameNew.getScopeID());
 
                                        stackFrameOld.setAvailable (true);                                                      // And mark this stack frame as available
                                        stackFrameNew.setAvailable (true);                                                      // And mark this stack frame as available
@@ -859,7 +934,8 @@ public class PHPDBGInterface {
                                                                                                                  stackIndex,
                                                                                                                  getRawFrameData (entirePack,          // Get the string from this packet
                                                                                                                                   dbg_stack_new[3]),   // The frame ID for which we want the string
-                                                                                                                 dbg_stack_new[1]);                                    // The module number
+                                                                                                                 dbg_stack_new[1],                                     // The module number
+                                                                                                                 dbg_stack_new[2]);
                                                        stackList.add (newStack);
                                                }
 
@@ -959,7 +1035,7 @@ public class PHPDBGInterface {
 
                                                evalRet                 = getRawFrameData (entirePack, dbg_eval_tmp[1]);                //
                                                evalString              = getRawFrameData (entirePack, dbg_eval_tmp[0]);                //
-                                               serGlobals              = evalRet;                                                      //
+                                               //serGlobals            = evalRet;                                                      //
                                                break;
 
                                        case PHPDBGBase.FRAME_BPS:                                                          //
index 702aa2a..49e2c8a 100644 (file)
@@ -116,3 +116,5 @@ RegistryView.horizontalOrientation.desc = Tile horizontally
 OpenLogDialog.title=Error Log
 OpenLogDialog.message=Opening log...
 OpenLogDialog.cannotDisplay=Log file cannot be displayed.
+
+VariablesView.GlobalVariables.title = <Global Variables>
index d74a154..8916bce 100644 (file)
@@ -489,6 +489,7 @@ public class PHPDBGEvalString {
                                case 'z': ParseEvalResource (name, parent, list, var_list, startIdx);                            break;
                                case 'R': ParseEvalRef          (name, parent, list, var_list, false, startIdx);                 break;
                                case 'r': ParseEvalRef          (name, parent, list, var_list, true, startIdx);                  break;
+                               case '?': ParseEvalUnknown(name, parent, list, var_list, startIdx);                                      break;
                        }
                } catch (DebugException e) {
                        // TODO Auto-generated catch block
@@ -514,4 +515,26 @@ public class PHPDBGEvalString {
 */
                return  ret_val;                                                                                        // Always false
        }
+
+       /*
+        *
+        */
+       private void ParseEvalUnknown(String name, PHPVariable parent, Vector list,
+                       Vector var_list, int startIdx) throws DebugException {
+
+               if ((startIdx >= workStr.length()) || (workStr.charAt(startIdx) != ';')) {
+                       Status status = new Status(Status.ERROR, PHPDebugCorePlugin
+                                       .getUniqueIdentifier(), Status.OK, "unexpected response",
+                                       null);
+                       throw new DebugException(status);
+               }
+
+               workStr = workStr.substring(1);
+               PHPVariable item = new PHPVariable(fStackFrame, name, parent, "?",
+                               PHPValue.PEVT_UNKNOWN, null);
+               list.add(item);
+               if (var_list != null) {
+                       var_list.add(item);
+               }
+       }
 }
index dcd372e..c9cde49 100644 (file)
@@ -14,11 +14,12 @@ package net.sourceforge.phpdt.internal.debug.core.model;
 import java.util.Arrays;
 import java.util.Vector;
 
+import net.sourceforge.phpdt.internal.debug.core.PHPDBGBase;
 import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
 
+import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.debug.core.DebugEvent;
 import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IDebugTarget;
 import org.eclipse.debug.core.model.IRegisterGroup;
@@ -31,20 +32,21 @@ import org.eclipse.debug.core.model.IVariable;
  * TODO Remove the variables array and use only the varList vector
  *      Have also to change hasVariables
  */
-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 int                     lineNumber;         //
-       private int                     index;              //
-       private int                     modno;              //
-       private PHPVariable[]   variables;          // The array of variables TODO: better introduce a vector?
-       private Vector          varList  = new Vector ();
-       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
+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 int                     lineNumber;
+       private int                     index;
+       private int                     modno;
+       private int                     scope_id;                               // scope id
+       private PHPVariable[]   variables;                              // The array of variables TODO: better introduce a vector?
+       private Vector          varList = new Vector();
+       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
 
        /**
         *
@@ -54,17 +56,20 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa
         * @param index
         * @param desc
         * @param modno
+        * @param scope_id
         */
-       public PHPStackFrame (PHPThread thread, String file, int line, int index, String desc, int modno) {
-               super (null);
+       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.lineNumber = line;
+               this.index = index;
+               this.file = file;
+               this.thread = thread;
                this.description = desc;
-               this.modno               = modno;
-               this.fUpToDate   = false;
+               this.modno = modno;
+               this.scope_id = scope_id;
+               this.fUpToDate = false;
        }
 
        /**
@@ -85,6 +90,22 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa
        }
 
        /**
+        * 
+        * @return scope id
+        */
+       public int getScopeID() {
+               return scope_id;
+       }
+
+       /**
+        * 
+        */
+       public void setScopeID(int scope_id) {
+               this.scope_id = scope_id;
+               setUpToDate(false);
+       }
+
+       /**
         *
         */
        public IThread getThread () {
@@ -294,7 +315,6 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa
                }
        }
 
-
        /**
         *
         * This function returns the array of PHPVariables for this stackframe
@@ -308,12 +328,12 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa
         * @return The array of PHPVariables for this stackframe.
         */
        public IVariable[] getVariables() throws DebugException {
-               if (!isUpToDate ()) {
-                       resetHasChangedInfo (varList);
-                       updateVariableList (varList, this.getPHPDBGProxy ().readVariables (this));
-                       setUpToDate (true);
+               if (!isUpToDate()) {
+                       resetHasChangedInfo(varList);
+                       updateVariableList(varList, this.getPHPDBGProxy().readVariables(this));
+                       setUpToDate(true);
 
-                       variables = (PHPVariable[]) varList.toArray (new PHPVariable[varList.size ()]);
+                       variables = (PHPVariable[]) varList.toArray(new PHPVariable[varList.size()]);
                        Arrays.sort(variables, new PHPVariableComparator());
                }
 
@@ -513,8 +533,8 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa
                thread.prepareForResume (DebugEvent.STEP_RETURN);
                this.getPHPDBGProxy ().readStepReturnEnd (PHPStackFrame.this) ;
 
-               ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
-               DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
+               //ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
+               //DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
        }
 
 
index 072e0b3..e452669 100644 (file)
@@ -36,6 +36,7 @@ public class PHPVariable implements IVariable {
        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;
 
        /**
         *
@@ -119,7 +120,18 @@ public class PHPVariable implements IVariable {
         */
        public void setParent(PHPVariable parent) {
                this.fParent = parent;
-               fLongName = parent.getLongName() + fName;
+
+               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;
+               }
        }
 
        /**
@@ -213,7 +225,21 @@ public class PHPVariable implements IVariable {
                        }
                }
 
-               setValue(vars[0].fValue);
+               fValue = vars[0].fValue;
+
+               // 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());
+                               }
+                       }
+               }
 
                DebugPlugin.getDefault().fireDebugEventSet(
                                new DebugEvent[] { new DebugEvent(this, DebugEvent.CHANGE,
@@ -231,7 +257,16 @@ public class PHPVariable implements IVariable {
         * @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
         */
        public boolean supportsValueModification() {
-               return true;
+               return fModifiable;
+       }
+
+       /**
+        * Set whether this variable can be modified (default is true)
+        * 
+        * for Global Variables root element only
+        */
+       public void setModifiable(boolean modifiable) {
+               fModifiable = modifiable;
        }
 
        /**