From 8c88498688f01977ab9edca417e65c7bd910c0de Mon Sep 17 00:00:00 2001 From: robekras Date: Tue, 18 Oct 2005 19:34:16 +0000 Subject: [PATCH] 1) A temporary fix for the recursion problem with the $GLOBALS array. --- .../phpdt/internal/debug/core/PHPDBGInterface.java | 50 ++++++++++++++++++-- 1 files changed, 45 insertions(+), 5 deletions(-) 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 d0576f9..03a735f 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 @@ -394,6 +394,43 @@ public class PHPDBGInterface { } /** + * Go up the tree of PHPVariables + * look whether the PHPValue is a reference to a parent PHPValue + * + * TODO Check where this recursion can come from. + * Whether this back reference is legal or a bug. + * + * @param var + * @return + * + */ + + private boolean hasRecursion (PHPVariable var) { + PHPVariable parentVar; + PHPValue val; + + 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 + + if (parentVar != null) { // Is there a parent? + 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 + } + } + + var = parentVar; + } + + return false; // No recursion found + } + + /** * This method updates the 'static' variables list. * It does a replication between the 'static' list (the variable list which * is a member of this DBG interface object) and the DBG variable list @@ -436,10 +473,13 @@ public class PHPDBGInterface { 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 - updateVariableList (valOld.getChildVariables (), // Update the variable list for the child variables - valNew.getChildVariables ()); + 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 ()); + } } else if (!valOld.getValueString ().equals (valNew.getValueString ())) { // Has the value changed? valOld.setValueString (valNew.getValueString ()); // Yes, set the 'static' value (variable) to the new value @@ -517,7 +557,7 @@ public class PHPDBGInterface { evalStr = new PHPDBGEvalString (stack, serGlobals); // Process serialized variables updateVariableList (DBGVarList, evalStr.getVariables ()); // Replicate the 'static' variable list and the via DBG received variable list - return DBGVarList; // Convert the list to an array and return the array + return DBGVarList; // Return the variables as list } /** -- 1.7.1