stack frame bugs fixed
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / PHPDBGInterface.java
index 40b27b4..e7bf98e 100644 (file)
@@ -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: