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 {
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 PHPDBGProxy thisProxy= null;
private int port;
public PHPDBGProxy() {
+ thisProxy= this;
}
public void start() {
public void stop() {
phpLoop.setShouldStop();
if(DBGInt != null) DBGInt.setShouldStop();
+ try {
+ getDebugTarget().getProcess().terminate();
+ } catch (DebugException e) {
+ e.printStackTrace();
+ }
phpLoop.notifyWait();
}
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
}
}
- protected Socket getSocket() throws IOException {
+ public Socket getSocket() throws IOException {
return socket;
}
}
public BufferedReader getReader() throws IOException {
- if (reader == null) {
+ if (reader == null) {
reader = new BufferedReader(new InputStreamReader(this.getSocket().getInputStream(), "ISO8859_1"));
}
return reader;
phpLoop.start();
}
- public void resume(PHPThread thread) {
+ public void resume() {
try {
DBGInt.continueExecution();
phpLoop.notifyWait();
}
}
+ public void pause() {
+ try {
+ DBGInt.pauseExecution();
+ } catch (IOException e) {
+ PHPDebugCorePlugin.log(e);
+ stop();
+ }
+ }
protected IPHPDebugTarget getDebugTarget() {
return debugTarget;
}
public void run() {
try {
char[] buf= new char[16];
- int i, pos;
+ int i, pos, timeout;
long interval= 1000*20;
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= new PHPThread(getDebugTarget(), getPort());
PHPMainThread.setName("Thread [main]");
+ 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();
// Check version and session ID
-
setBreakPoints();
DBGInt.continueExecution();
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();
}
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.");
}
}
- }
+ }
}