private String serGlobals= new String("");
private String typeRead= new String("");
private String className= new String("");
- private int finalPos=0, refCounter=0, rawCounter=0;
+ private int finalPos=0, refCounter=0, rawCounter=1000;
public PHPDBGInterface(BufferedReader in, OutputStream os) {
DBGBPList.clear();
DBGPacket.sendPacket(os);
}
+ public void addDBGModName(String modName) throws IOException {
+ PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
+ PHPDBGFrame DBGFrame= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
+
+ rawCounter++;
+ DBGFrame.addInt(rawCounter); // FRAME_RAWDATA ID
+ DBGFrame.addInt(modName.length() + 1); // length of rawdata (+ null char)
+ DBGFrame.addString(modName); // file name
+ DBGFrame.addChar('\0'); // null char
+
+ DBGPacket.addFrame(DBGFrame);
+
+ DBGPacket.sendPacket(os);
+ }
+
// Returns DBG Breakpoint ID
private int setBreakpoint(String mod_name, String condition, int line, int state, int istemp, int hitcount, int skiphits, int bpno, int isunderhit) throws IOException {
int modNo= 0;
while(readResponse() != 0);
}
- private String getModByNo(int modNo) {
+ public String getModByNo(int modNo) {
int i;
PHPDBGMod dbg_mod;
String value= new String("");
String name= new String("");
String tmp= new String("");
+ String[] tmpSplit;
if(finalPos > serGlobals.length() || serGlobals.equals("") || serGlobals.substring(finalPos).equals("")) return;
hasChildren= false;
isRef= false;
value= readValue(serGlobals.substring(finalPos));
+ // replaceAll doesn't work, why???
+ tmpSplit= value.split("\\\\");
+ value= "";
+ for(i= 0; i < tmpSplit.length; i++) {
+ value= value + tmpSplit[i];
+ if(!tmpSplit[i].equals("")) {
+ if(i < (tmpSplit.length - 1)) {
+ value= value + "\\";
+ }
+ }
+ }
}
if(!name.equals("")) {
cmdReceived= dbg_header_struct[1];
bytesToRead= dbg_header_struct[3];
- System.out.println("Response Received: " + cmdReceived);
-
+ //System.out.println("Response Received: " + cmdReceived);
char[] entirePack= new char[bytesToRead];
if(bytesToRead > 0) {
dbg_stack_new[3] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 12); // id of description string
stackIndex++;
- if(!getModByNo(dbg_stack_new[1]).equals("")) {
- PHPStackFrame newStack= new PHPStackFrame(null, getModByNo(dbg_stack_new[1]), dbg_stack_new[0], stackIndex, getRawFrameData(entirePack, dbg_stack_new[3]));
+ if(dbg_stack_new[1] != 0) {
+ PHPStackFrame newStack= new PHPStackFrame(null, getModByNo(dbg_stack_new[1]), dbg_stack_new[0], stackIndex, getRawFrameData(entirePack, dbg_stack_new[3]), dbg_stack_new[1]);
stackList.add(newStack);
}
break;
String fileName= new String(getRawFrameData(entirePack, dbg_bpl_new[2]));
// Remove '\0' char
if(fileName.length() > 0) fileName= fileName.substring(0, fileName.length() - 1);
- PHPDBGMod modNew= new PHPDBGMod(dbg_bpl_new[0], fileName);
- DBGMods.add(modNew);
+ if(dbg_bpl_new[0] != 0) {
+ PHPDBGMod modNew= new PHPDBGMod(dbg_bpl_new[0], fileName);
+ DBGMods.add(modNew);
+ }
}
break;
case PHPDBGBase.FRAME_VER:
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;
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
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();
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);
}
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.");
}
}
}