From: fvicente Date: Sun, 9 Nov 2003 03:01:21 +0000 (+0000) Subject: stack frame bugs fixed X-Git-Url: http://git.phpeclipse.com?hp=35f01fa140dc41f4793a4bdb1537f1e10868f76b stack frame bugs fixed --- diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java index 40b27b4..e7bf98e 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/PHPDBGInterface.java @@ -43,7 +43,7 @@ public class PHPDBGInterface { 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(); @@ -68,6 +68,21 @@ public class PHPDBGInterface { 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; @@ -241,7 +256,7 @@ public class PHPDBGInterface { while(readResponse() != 0); } - private String getModByNo(int modNo) { + public String getModByNo(int modNo) { int i; PHPDBGMod dbg_mod; @@ -454,6 +469,7 @@ public class PHPDBGInterface { 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; @@ -472,6 +488,17 @@ public class PHPDBGInterface { 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("")) { @@ -530,8 +557,7 @@ public class PHPDBGInterface { 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) { @@ -554,8 +580,8 @@ public class PHPDBGInterface { 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; @@ -610,8 +636,10 @@ public class PHPDBGInterface { 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: 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 3f6ca08..b9bf0f2 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 @@ -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."); } } } diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java index bf59b50..cf68846 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPStackFrame.java @@ -29,15 +29,17 @@ public class PHPStackFrame implements IStackFrame { private String file; private int lineNumber; private int index; + private int modno; private PHPVariable[] variables; private String description; - public PHPStackFrame(PHPThread thread, String file, int line, int index, String desc) { + public PHPStackFrame(PHPThread thread, String file, int line, int index, String desc, int modno) { this.lineNumber = line; this.index = index; this.file = file; this.thread = thread; this.description = desc; + this.modno = modno; } public PHPStackFrame(PHPThread thread, String file, int line, int index) { @@ -205,4 +207,11 @@ public class PHPStackFrame implements IStackFrame { return DebugTarget.getPHPDBGProxy(); } + public void setFile(String file) { + this.file = file; + } + + public int getModNo() { + return modno; + } }