stack frame bugs fixed
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / PHPDBGProxy.java
index 3f6ca08..b9bf0f2 100644 (file)
@@ -37,7 +37,7 @@ public class PHPDBGProxy {
        private Socket socket;
        private BufferedReader reader= null;
        private PHPDBGInterface DBGInt= null;
-       private IPHPDebugTarget debugTarget;
+       private IPHPDebugTarget debugTarget= null;
        private PHPLoop phpLoop;
        private PHPThread PHPMainThread;
        private int port;
@@ -72,7 +72,7 @@ public class PHPDBGProxy {
                try {
                        if (server == null) {
                                server = new ServerSocket(port);
-                               System.out.println("ServerSocket on port: " + port);
+                               //System.out.println("ServerSocket on port: " + port);
                        } 
                } catch (IOException e) {
                        // IO Error
@@ -270,24 +270,27 @@ public class PHPDBGProxy {
                                String line;
                                PHPStackFrame[] StackList;
                                
-                               System.out.println("Waiting for breakpoints.");                 
+                               //System.out.println("Waiting for breakpoints.");                       
                                try{
                                        socket = server.accept();
-                                       System.out.println("Accepted! : " + socket.toString());
+                                       //System.out.println("Accepted! : " + socket.toString());
                                } catch (IOException e) {
                                        PHPDebugCorePlugin.log(e);
-                                       return;                         
+                                       return;                 
                                }
                                
                                PHPMainThread= new PHPThread(getDebugTarget(), 100);
                                PHPMainThread.setName("Thread [main]");
+                               while(getDebugTarget() == null) {
+                                       sleep(1000);
+                               }
                                getDebugTarget().addThread(PHPMainThread);
                                setDBGInterface(new PHPDBGInterface(getReader(), getOutputStream()));
 
+                               DBGInt.waitResponse(1000);
                                DBGInt.flushAllPackets();
 
                                // Check version and session ID
-                               
                                setBreakPoints();
                                DBGInt.continueExecution();
 
@@ -300,6 +303,7 @@ public class PHPDBGProxy {
                                                if(StackList.length > 0) {
                                                        for(i=0; i < StackList.length; i++) {
                                                                StackList[i].setThread(PHPMainThread);
+                                                               StackList[i].setFile(DBGInt.getModByNo(StackList[i].getModNo()));
                                                        }
                                                        PHPMainThread.setStackFrames(StackList);
                                                }
@@ -315,15 +319,15 @@ public class PHPDBGProxy {
                                PHPDebugCorePlugin.log(ex);
                                System.out.println(ex);
                        } finally {
-                               getDebugTarget().terminate();
                                try {
+                                       getDebugTarget().terminate();
                                        closeSocket();
                                        closeServerSocket();
                                } catch (IOException e) {
                                        PHPDebugCorePlugin.log(e);
                                        return;
                                }
-                               System.out.println("Socket loop finished.");
+                               //System.out.println("Socket loop finished.");
                        }
                }
        }