Modified: 1216132 - Error when debugging eval()'d code
authortoshihiro <toshihiro>
Sun, 26 Aug 2007 00:43:29 +0000 (00:43 +0000)
committertoshihiro <toshihiro>
Sun, 26 Aug 2007 00:43:29 +0000 (00:43 +0000)
net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java

index fb83c89..dfac692 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Collections;
 import java.util.Vector;
 
 import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
+import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin;
 
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.debug.core.DebugEvent;
@@ -564,6 +565,36 @@ public class PHPStackFrame extends PHPDebugElement implements IStackFrame, Compa
 
        public void setFile(String file) {
                this.file = file;
+
+               final String COMPILED_EVAL = "eval()'d code";
+               final String COMPILED_LAMBDA = "runtime-created function";
+
+               int i = 0;
+               if (file.endsWith(COMPILED_EVAL)) {
+                       i = file.length() - COMPILED_EVAL.length();
+               } else if (file.endsWith(COMPILED_LAMBDA)) {
+                       i = file.length() - COMPILED_LAMBDA.length();
+               }
+               if (i > 0) {
+                       // assume COMPILED_STRING_DESCRIPTION_FORMAT
+                       // "filename(linenumber) : string"
+                       int j = i;
+                       while (--i > 0) {
+                               switch (file.charAt(i)) {
+                               case ')':
+                                       j = i;
+                                       break;
+                               case '(':
+                                       this.file = file.substring(0, i);
+                                       try {
+                                               lineNumber = Integer.parseInt(file.substring(i + 1, j));
+                                       } catch (NumberFormatException e) {
+                                               PHPDebugCorePlugin.log(e);
+                                       }
+                                       return;
+                               }
+                       }
+               }
        }
 
        public int getModNo() {