X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java index b9bf0f2..feb5325 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGProxy.java @@ -26,10 +26,7 @@ import net.sourceforge.phpdt.internal.debug.core.model.IPHPDebugTarget; import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame; import net.sourceforge.phpdt.internal.debug.core.model.PHPThread; import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable; -import net.sourceforge.phpdt.internal.debug.core.SocketUtil; -import net.sourceforge.phpdt.internal.debug.core.PHPDBGInterface; import net.sourceforge.phpdt.internal.debug.core.breakpoints.PHPLineBreakpoint; -import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin; public class PHPDBGProxy { @@ -40,9 +37,11 @@ public class PHPDBGProxy { private IPHPDebugTarget debugTarget= null; private PHPLoop phpLoop; private PHPThread PHPMainThread; + private PHPDBGProxy thisProxy= null; private int port; public PHPDBGProxy() { + thisProxy= this; } public void start() { @@ -53,6 +52,11 @@ public class PHPDBGProxy { public void stop() { phpLoop.setShouldStop(); if(DBGInt != null) DBGInt.setShouldStop(); + try { + getDebugTarget().getProcess().terminate(); + } catch (DebugException e) { + e.printStackTrace(); + } phpLoop.notifyWait(); } @@ -81,7 +85,7 @@ public class PHPDBGProxy { } } - protected Socket getSocket() throws IOException { + public Socket getSocket() throws IOException { return socket; } @@ -90,7 +94,7 @@ public class PHPDBGProxy { } public BufferedReader getReader() throws IOException { - if (reader == null) { + if (reader == null) { reader = new BufferedReader(new InputStreamReader(this.getSocket().getInputStream(), "ISO8859_1")); } return reader; @@ -148,7 +152,7 @@ public class PHPDBGProxy { phpLoop.start(); } - public void resume(PHPThread thread) { + public void resume() { try { DBGInt.continueExecution(); phpLoop.notifyWait(); @@ -158,6 +162,14 @@ public class PHPDBGProxy { } } + public void pause() { + try { + DBGInt.pauseExecution(); + } catch (IOException e) { + PHPDebugCorePlugin.log(e); + stop(); + } + } protected IPHPDebugTarget getDebugTarget() { return debugTarget; } @@ -265,7 +277,7 @@ public class PHPDBGProxy { public void run() { try { char[] buf= new char[16]; - int i, pos; + int i, pos, timeout; long interval= 1000*20; String line; PHPStackFrame[] StackList; @@ -279,13 +291,17 @@ public class PHPDBGProxy { return; } - PHPMainThread= new PHPThread(getDebugTarget(), 100); + PHPMainThread= new PHPThread(getDebugTarget(), getPort()); PHPMainThread.setName("Thread [main]"); - while(getDebugTarget() == null) { - sleep(1000); + timeout= 0; + while((getDebugTarget() == null) && (timeout < 100)) { + sleep(100); + timeout++; } + // Be sure debug target is set + PHPMainThread.setDebugTarget(getDebugTarget()); getDebugTarget().addThread(PHPMainThread); - setDBGInterface(new PHPDBGInterface(getReader(), getOutputStream())); + setDBGInterface(new PHPDBGInterface(getReader(), getOutputStream(), thisProxy)); DBGInt.waitResponse(1000); DBGInt.flushAllPackets(); @@ -303,12 +319,16 @@ public class PHPDBGProxy { if(StackList.length > 0) { for(i=0; i < StackList.length; i++) { StackList[i].setThread(PHPMainThread); + if(DBGInt.getModByNo(StackList[i].getModNo()).equals("")) { + DBGInt.getSourceTree(); + } StackList[i].setFile(DBGInt.getModByNo(StackList[i].getModNo())); } PHPMainThread.setStackFrames(StackList); } + // Fire debug event PHPMainThread.suspend(); - + synchronized(this) { wait(); } @@ -330,5 +350,5 @@ public class PHPDBGProxy { //System.out.println("Socket loop finished."); } } - } + } }