private String typeRead= new String("");
private String className= new String("");
private int finalPos=0, refCounter=0, rawCounter=1000;
+ private PHPDBGProxy proxy= null;
- public PHPDBGInterface(BufferedReader in, OutputStream os) {
+ public PHPDBGInterface(BufferedReader in, OutputStream os, PHPDBGProxy proxy) {
DBGBPList.clear();
this.in= in;
this.os= os;
+ this.proxy= proxy;
}
public int addBreakpoint(String mod_name, int line) throws IOException {
PHPDBGFrame DBGFrame= new PHPDBGFrame(PHPDBGBase.FRAME_VER);
DBGPacket.addFrame(DBGFrame);
+
+ if(proxy.getSocket().isClosed()) return;
+ DBGPacket.sendPacket(os);
+ }
+
+ public void getSourceTree() throws IOException {
+ PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
+ PHPDBGFrame DBGFrame= new PHPDBGFrame(PHPDBGBase.FRAME_SRC_TREE);
+ DBGPacket.addFrame(DBGFrame);
+
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
+
+ // Wait response (1 second) and read response
+ waitResponse(1000);
+ flushAllPackets();
}
public void addDBGModName(String modName) throws IOException {
DBGPacket.addFrame(DBGFrame);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
}
// Second add command data
DBGPacket.addFrame(DBGFrame1);
+ if(proxy.getSocket().isClosed()) return 0;
DBGPacket.sendPacket(os);
clearLastBP();
public void continueExecution() throws IOException {
BPUnderHit= 0;
PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_CONTINUE);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
}
public void stepInto() throws IOException {
BPUnderHit= 0;
PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STEPINTO);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
}
public void stepOver() throws IOException {
BPUnderHit= 0;
PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STEPOVER);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
}
public void stepOut() throws IOException {
BPUnderHit= 0;
PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STEPOUT);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
}
public void stopExecution() throws IOException {
BPUnderHit= 0;
PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STOP);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
}
// Add command data
DBGPacket.addFrame(DBGFrame1);
+ if(proxy.getSocket().isClosed()) return null;
DBGPacket.sendPacket(os);
waitResponse(1000);
// Add command data
DBGPacket.addFrame(DBGFrame1);
+ if(proxy.getSocket().isClosed()) return;
DBGPacket.sendPacket(os);
waitResponse(1000);
int[] dbg_bpl_tmp= new int[10];
int[] dbg_frame= new int[2];
int[] dbg_eval_tmp= new int[3];
+ int[] dbg_src_tree_tmp= new int[4];
Vector rawList= new Vector();
Vector stackList= new Vector();
PHPStackFrame[] newStackList;
case PHPDBGBase.FRAME_SOURCE:
break;
case PHPDBGBase.FRAME_SRC_TREE:
+ dbg_src_tree_tmp[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 0); // parent_mod_no
+ dbg_src_tree_tmp[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4); // parent_line_no /* NOT USED */
+ dbg_src_tree_tmp[2] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 8); // mod_no
+ dbg_src_tree_tmp[3] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 12); // imod_name
+
+ if(getModByNo(dbg_src_tree_tmp[2]).equals("")) {
+ String fileName= new String(getRawFrameData(entirePack, dbg_src_tree_tmp[3]));
+ // Remove '\0' char
+ if(fileName.length() > 0) fileName= fileName.substring(0, fileName.length() - 1);
+
+ if(dbg_src_tree_tmp[2] != 0) {
+ PHPDBGMod modNew= new PHPDBGMod(dbg_src_tree_tmp[2], fileName);
+ DBGMods.add(modNew);
+ }
+ }
break;
case PHPDBGBase.FRAME_RAWDATA:
break;
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 IPHPDebugTarget debugTarget= null;
private PHPLoop phpLoop;
private PHPThread PHPMainThread;
+ private PHPDBGProxy thisProxy= null;
private int port;
public PHPDBGProxy() {
+ thisProxy= this;
}
public void start() {
}
}
- protected Socket getSocket() throws IOException {
+ public Socket getSocket() throws IOException {
return socket;
}
public void run() {
try {
char[] buf= new char[16];
- int i, pos;
+ int i, pos, timeout;
long interval= 1000*20;
String line;
PHPStackFrame[] StackList;
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();
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();
}