1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 Vicente Fernando - www.alfersoft.com.ar - Initial implementation
10 **********************************************************************/
11 package net.sourceforge.phpdt.internal.debug.core;
13 import java.io.IOException;
14 import java.io.BufferedReader;
15 import java.io.OutputStream;
16 import java.util.Vector;
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.core.runtime.Status;
20 import org.eclipse.debug.core.DebugException;
22 import net.sourceforge.phpdt.internal.debug.core.model.PHPStackFrame;
23 import net.sourceforge.phpdt.internal.debug.core.model.PHPVariable;
24 import net.sourceforge.phpdt.internal.debug.core.model.PHPValue;
26 public class PHPDBGInterface {
29 public boolean sessionEnded= false;
30 public int sessType= -1;
31 public int BPUnderHit= 0;
32 public String sessID= new String();
35 private int[] LastBPRead= new int[10];
36 private Vector DBGBPList= new Vector();
37 private PHPStackFrame[] DBGStackList;
38 private PHPVariable[] DBGVariableList;
39 private Vector DBGMods= new Vector();
40 private Vector DBGVars= new Vector();
41 private BufferedReader in;
42 private OutputStream os;
43 private boolean shouldStop= false, isRef= false, hasChildren= false, isObject= false;
44 private String evalRet= new String("");
45 private String serGlobals= new String("");
46 private String typeRead= new String("");
47 private String className= new String("");
48 private int finalPos=0, refCounter=0, rawCounter=1000;
49 private PHPDBGProxy proxy= null;
50 private boolean stopOnError= false;
51 private char[] lastCommand= new char[4];
53 public PHPDBGInterface(BufferedReader in, OutputStream os, PHPDBGProxy proxy) {
60 public int addBreakpoint(String mod_name, int line) throws IOException {
61 return setBreakpoint(mod_name, "", line, PHPDBGBase.BPS_ENABLED + PHPDBGBase.BPS_UNRESOLVED, 0, 0, 0, 0, 0);
64 public void removeBreakpoint(String mod_name, int line, int bpNo) throws IOException {
65 setBreakpoint(mod_name, "", line, PHPDBGBase.BPS_DISABLED, 0, 0, 0, bpNo, 0);
68 public void requestDBGVersion() throws IOException {
69 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
70 PHPDBGFrame DBGFrame= new PHPDBGFrame(PHPDBGBase.FRAME_VER);
72 DBGPacket.addFrame(DBGFrame);
74 if(proxy.getSocket().isClosed()) return;
75 DBGPacket.sendPacket(os);
78 public void getSourceTree() throws IOException {
79 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
80 PHPDBGFrame DBGFrame= new PHPDBGFrame(PHPDBGBase.FRAME_SRC_TREE);
82 DBGPacket.addFrame(DBGFrame);
84 if(proxy.getSocket().isClosed()) return;
85 DBGPacket.sendPacket(os);
87 // Wait response (1 second) and read response
92 public void addDBGModName(String modName) throws IOException {
93 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
94 PHPDBGFrame DBGFrame= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
97 DBGFrame.addInt(rawCounter); // FRAME_RAWDATA ID
98 DBGFrame.addInt(modName.length() + 1); // length of rawdata (+ null char)
99 DBGFrame.addString(modName); // file name
100 DBGFrame.addChar('\0'); // null char
102 DBGPacket.addFrame(DBGFrame);
104 if(proxy.getSocket().isClosed()) return;
105 DBGPacket.sendPacket(os);
108 // Returns DBG Breakpoint ID
109 private int setBreakpoint(String mod_name, String condition, int line, int state, int istemp, int hitcount, int skiphits, int bpno, int isunderhit) throws IOException {
112 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
113 PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_BPS);
114 PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
116 modNo= getModByName(mod_name);
119 DBGFrame1.addInt(modNo); // mod number
121 DBGFrame1.addInt(0); // mod number (0 use file name)
124 DBGFrame1.addInt(line); // line number
127 DBGFrame1.addInt(0); // use mod number
130 DBGFrame1.addInt(rawCounter); // ID of FRAME_RAWDATA to send file name
133 DBGFrame1.addInt(state); // state BPS_*
134 DBGFrame1.addInt(istemp); // istemp
135 DBGFrame1.addInt(hitcount); // hit count
136 DBGFrame1.addInt(skiphits); // skip hits
137 DBGFrame1.addInt(0); // ID of condition
138 DBGFrame1.addInt(bpno); // breakpoint number
139 DBGFrame1.addInt(isunderhit); // is under hit
142 DBGFrame2.addInt(rawCounter); // FRAME_RAWDATA ID
143 DBGFrame2.addInt(mod_name.length() + 1); // length of rawdata (+ null char)
144 DBGFrame2.addString(mod_name); // file name
145 DBGFrame2.addChar('\0'); // null char
146 // First add file name data
147 DBGPacket.addFrame(DBGFrame2);
150 // Second add command data
151 DBGPacket.addFrame(DBGFrame1);
153 if(proxy.getSocket().isClosed()) return 0;
154 DBGPacket.sendPacket(os);
158 // Wait response (1 second) and read response
162 return LastBPRead[8];
165 private void clearLastBP() {
168 for(i=0; i < LastBPRead.length; i++)
172 private void copyToLastBP(int[] BPBody) {
175 for(i=0; i < LastBPRead.length; i++)
176 LastBPRead[i]= BPBody[i];
179 public void continueExecution() throws IOException {
181 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_CONTINUE);
182 if(proxy.getSocket().isClosed()) return;
183 DBGPacket.sendPacket(os);
184 lastCommand= PHPDBGBase.DBGA_CONTINUE;
187 public void pauseExecution() throws IOException {
188 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.IntToChar4(PHPDBGBase.DBGC_PAUSE));
189 if(proxy.getSocket().isClosed()) return;
190 DBGPacket.sendPacket(os);
193 private int getBPUnderHit() {
195 int[] dbg_bpl_body= new int[10];
197 // look for bp under hit
198 for(i=0; i < DBGBPList.size(); i++) {
199 dbg_bpl_body= (int[]) DBGBPList.get(i);
200 if(dbg_bpl_body[9] == 1) {
201 BPUnder= dbg_bpl_body[8];
207 public void stepInto() throws IOException {
209 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STEPINTO);
210 if(proxy.getSocket().isClosed()) return;
211 DBGPacket.sendPacket(os);
212 lastCommand= PHPDBGBase.DBGA_STEPINTO;
215 public void stepOver() throws IOException {
217 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STEPOVER);
218 if(proxy.getSocket().isClosed()) return;
219 DBGPacket.sendPacket(os);
220 lastCommand= PHPDBGBase.DBGA_STEPOVER;
223 public void stepOut() throws IOException {
225 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STEPOUT);
226 if(proxy.getSocket().isClosed()) return;
227 DBGPacket.sendPacket(os);
228 lastCommand= PHPDBGBase.DBGA_STEPOUT;
231 public void stopExecution() throws IOException {
233 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_STOP);
234 if(proxy.getSocket().isClosed()) return;
235 DBGPacket.sendPacket(os);
238 public PHPVariable[] getVariables(PHPStackFrame stack) throws IOException, DebugException {
239 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
240 PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_EVAL);
242 DBGFrame1.addInt(0); // istr = raw data ID
243 DBGFrame1.addInt(1); // scope_id = -1 means current location, 0 never used, +1 first depth
246 DBGPacket.addFrame(DBGFrame1);
248 if(proxy.getSocket().isClosed()) return null;
249 DBGPacket.sendPacket(os);
254 // Process serialized variables
255 DBGVariableList= procVars(stack);
257 return DBGVariableList;
260 public void log(String logString) throws IOException, DebugException {
261 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
262 PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_LOG);
263 PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
266 DBGFrame1.addInt(rawCounter); // ilog
267 DBGFrame1.addInt(1); // type
268 DBGFrame1.addInt(0); // mod_no
269 DBGFrame1.addInt(0); // line_no
270 DBGFrame1.addInt(0); // imod_name
271 DBGFrame1.addInt(0); // ext_info
273 DBGFrame2.addInt(rawCounter); // FRAME_RAWDATA ID
274 DBGFrame2.addInt(logString.length() + 1); // length of rawdata (+ null char)
275 DBGFrame2.addString(logString); // log string
276 DBGFrame2.addChar('\0'); // null char
278 // Add raw data first
279 DBGPacket.addFrame(DBGFrame2);
281 DBGPacket.addFrame(DBGFrame1);
283 if(proxy.getSocket().isClosed()) return;
284 DBGPacket.sendPacket(os);
290 public void evalBlock(String evalString) throws IOException, DebugException {
291 PHPDBGPacket DBGPacket= new PHPDBGPacket(PHPDBGBase.DBGA_REQUEST);
292 PHPDBGFrame DBGFrame1= new PHPDBGFrame(PHPDBGBase.FRAME_EVAL);
293 PHPDBGFrame DBGFrame2= new PHPDBGFrame(PHPDBGBase.FRAME_RAWDATA);
296 DBGFrame1.addInt(rawCounter); // istr = raw data ID
297 DBGFrame1.addInt(-1); // scope_id = -1 means current location, 0 never used, +1 first depth
299 DBGFrame2.addInt(rawCounter); // FRAME_RAWDATA ID
300 DBGFrame2.addInt(evalString.length() + 1); // length of rawdata (+ null char)
301 DBGFrame2.addString(evalString); // eval block
302 DBGFrame2.addChar('\0'); // null char
304 // Add raw data first
305 DBGPacket.addFrame(DBGFrame2);
307 DBGPacket.addFrame(DBGFrame1);
309 if(proxy.getSocket().isClosed()) return;
310 DBGPacket.sendPacket(os);
316 public void flushAllPackets() throws IOException {
317 while(readResponse() != 0);
320 public String getModByNo(int modNo) {
325 for(i=0; i < DBGMods.size(); i++) {
326 dbg_mod= (PHPDBGMod) DBGMods.get(i);
327 if(dbg_mod.getNo() == modNo) {
328 return dbg_mod.getName();
334 private int getModByName(String modName) {
339 for(i=0; i < DBGMods.size(); i++) {
340 dbg_mod= (PHPDBGMod) DBGMods.get(i);
341 if(dbg_mod.getName().equalsIgnoreCase(modName)) {
342 return dbg_mod.getNo();
348 private String getRawFrameData(char[] framesInfo, int frameNo) {
350 int[] dbg_frame= new int[2];
352 while(nextFrame < framesInfo.length) {
353 dbg_frame[0] = PHPDBGBase.Char4ToInt(framesInfo, nextFrame); // frame name
354 dbg_frame[1] = PHPDBGBase.Char4ToInt(framesInfo, nextFrame + 4); // frame size
357 if(dbg_frame[1] == 0) return "";
359 switch(dbg_frame[0]) {
360 case PHPDBGBase.FRAME_RAWDATA:
361 if(frameNo == PHPDBGBase.Char4ToInt(framesInfo, nextFrame)) {
362 int toRead= PHPDBGBase.Char4ToInt(framesInfo, nextFrame + 4);
363 return String.copyValueOf(framesInfo, nextFrame + 8, toRead);
368 nextFrame += dbg_frame[1];
373 public PHPVariable[] getInstVars(PHPVariable phpVar) throws DebugException {
374 Vector vecVars= new Vector();
375 PHPVariable localPHPVar;
378 // already unserialized
379 for(i=0; i < DBGVars.size(); i++) {
380 localPHPVar= (PHPVariable)DBGVars.get(i);
381 if(localPHPVar.getParent() == phpVar) {
382 vecVars.add(localPHPVar);
385 PHPVariable[] arrVars= new PHPVariable[vecVars.size()];
386 arrVars= (PHPVariable[]) vecVars.toArray(arrVars);
391 private PHPVariable[] procVars(PHPStackFrame stack) throws DebugException {
392 Vector vecVars= new Vector();
397 doUnserialize(stack, vecVars, null);
401 return(getInstVars(null));
404 private String readValue(String serialVars) throws DebugException {
405 int startPos=0, endPos=0, lenStr=0, i=0, elements=0;
406 String ret= new String("");
408 switch(serialVars.charAt(0)) {
409 case 'a': // associative array, a:elements:{[index][value]...}
412 endPos= serialVars.indexOf(':', startPos + 1);
413 if(endPos == -1) return "";
414 finalPos += endPos + 2;
415 ret= new String(serialVars.substring(startPos + 1, endPos));
419 case 'O': // object, O:name_len:"name":elements:{[attribute][value]...}
423 endPos= serialVars.indexOf(':', startPos + 1);
424 if(endPos == -1) return "";
427 lenStr= Integer.parseInt(serialVars.substring(startPos + 1, endPos));
428 startPos= endPos + 2;
429 endPos= lenStr + startPos;
430 className= new String(serialVars.substring(startPos, endPos).toString());
432 // get num of elements
433 startPos= endPos + 1;
434 endPos= serialVars.indexOf(':', startPos + 1);
435 if(endPos == -1) return "";
436 finalPos += endPos + 2;
437 ret= new String(serialVars.substring(startPos + 1, endPos));
442 case 's': // string, s:length:"data";
445 endPos= serialVars.indexOf(':', startPos + 1);
446 if(endPos == -1) return "";
448 lenStr= Integer.parseInt(serialVars.substring(startPos + 1, endPos));
449 startPos= endPos + 2;
450 endPos= lenStr + startPos;
451 ret= new String(serialVars.substring(startPos, endPos).toString());
452 finalPos += endPos + 2;
454 case 'i': // integer, i:123;
457 endPos= serialVars.indexOf(';', startPos + 1);
458 if(endPos == -1) return "";
460 ret= new String(serialVars.substring(startPos + 1, endPos).toString());
461 finalPos += endPos + 1;
463 case 'd': // double (float), d:1.23;
466 endPos= serialVars.indexOf(';', startPos + 1);
467 if(endPos == -1) return "";
469 ret= new String(serialVars.substring(startPos + 1, endPos).toString());
470 finalPos += endPos + 1;
472 case 'N': // NULL, N;
477 case 'b': // bool, b:0 or 1
479 ret= (serialVars.charAt(2) == '1')?"true":"false";
480 finalPos += endPos + 4;
482 case 'z': // resource, z:typename_len:"typename":valres;
483 typeRead= "resource";
486 endPos= serialVars.indexOf(':', startPos + 1);
487 if(endPos == -1) return "";
489 // get resource type name
490 lenStr= Integer.parseInt(serialVars.substring(startPos + 1, endPos));
491 startPos= endPos + 2;
492 endPos= lenStr + startPos;
493 className= new String(serialVars.substring(startPos, endPos).toString());
495 // get resource value
496 startPos= endPos + 1;
497 endPos= serialVars.indexOf(';', startPos + 1);
498 if(endPos == -1) return "";
499 ret= new String(serialVars.substring(startPos + 1, endPos));
500 finalPos += endPos + 1;
504 typeRead= "reference";
506 endPos= serialVars.indexOf(';', startPos + 1);
507 if(endPos == -1) return "0";
509 ret= new String(serialVars.substring(startPos + 1, endPos));
510 finalPos += endPos + 1;
527 private void doUnserialize(PHPStackFrame stack, Vector vecVars, PHPVariable parent) throws DebugException {
529 PHPVariable newVar= null;
530 String value= new String("");
531 String name= new String("");
532 String tmp= new String("");
535 if(finalPos > serGlobals.length() || serGlobals.equals("") || serGlobals.substring(finalPos).equals("")) return;
540 name= readValue(serGlobals.substring(finalPos));
544 if(refCounter == 0) {
551 value= readValue(serGlobals.substring(finalPos));
552 // replaceAll doesn't work, why???
553 tmpSplit= value.split("\\\\");
555 for(i= 0; i < tmpSplit.length; i++) {
556 value= value + tmpSplit[i];
557 if(!tmpSplit[i].equals("")) {
558 if(i < (tmpSplit.length - 1)) {
565 if(!name.equals("")) {
568 for(i=0; i < vecVars.size(); i++) {
569 varPHP= (PHPVariable) vecVars.get(i);
570 if(varPHP.getObjectId().equals(value)) {
571 newVar= new PHPVariable(stack, name, "local", true, (PHPValue)varPHP.getValue());
576 newVar= new PHPVariable(stack, name, "local", false, null);
580 newVar= new PHPVariable(stack, name, "local", value, typeRead, hasChildren, Integer.toString(refCounter), className);
582 newVar.setParent(parent);
586 elements= Integer.parseInt(value);
587 for(i=0; i < elements; i++)
588 doUnserialize(stack, vecVars, newVar);
595 public int readResponse() throws IOException {
596 int bytesToRead=0, nextFrame=0, i=0, cmdReceived=0, stackIndex=0;
597 boolean errorStack= false;
598 char[] dbg_header_struct_read= new char[16];
599 int[] dbg_header_struct= new int[4];
600 int[] dbg_bpl_tmp= new int[10];
601 int[] dbg_frame= new int[2];
602 int[] dbg_eval_tmp= new int[3];
603 int[] dbg_src_tree_tmp= new int[4];
604 int[] dbg_error_tmp= new int[2];
605 Vector rawList= new Vector();
606 Vector stackList= new Vector();
607 PHPStackFrame[] newStackList;
612 while(readInput(dbg_header_struct_read, 16) != 0) {
613 dbg_header_struct[0] = PHPDBGBase.Char4ToInt(dbg_header_struct_read, 0);
614 dbg_header_struct[1] = PHPDBGBase.Char4ToInt(dbg_header_struct_read, 4);
615 dbg_header_struct[2] = PHPDBGBase.Char4ToInt(dbg_header_struct_read, 8);
616 dbg_header_struct[3] = PHPDBGBase.Char4ToInt(dbg_header_struct_read, 12);
618 // Check DBG sync bytes
619 if(dbg_header_struct[0] != 0x5953) return 0;
621 cmdReceived= dbg_header_struct[1];
622 bytesToRead= dbg_header_struct[3];
624 //System.out.println("Response Received: " + cmdReceived);
625 char[] entirePack= new char[bytesToRead];
627 if(bytesToRead > 0) {
628 if(readInput(entirePack, bytesToRead) < bytesToRead) return 0;
631 // First process frames
633 while(nextFrame < bytesToRead) {
634 dbg_frame[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame); // frame name
635 dbg_frame[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4); // frame size
637 if(dbg_frame[1] == 0) return 0;
638 switch(dbg_frame[0]) {
639 case PHPDBGBase.FRAME_STACK:
640 int[] dbg_stack_new= new int[4];
641 dbg_stack_new[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 0); // line no
642 dbg_stack_new[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4); // mod no
643 dbg_stack_new[2] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 8); // scope id
644 dbg_stack_new[3] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 12); // id of description string
646 if(dbg_stack_new[1] != 0 && !errorStack) {
648 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]);
649 stackList.add(newStack);
653 case PHPDBGBase.FRAME_SOURCE:
655 case PHPDBGBase.FRAME_SRC_TREE:
656 dbg_src_tree_tmp[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 0); // parent_mod_no
657 dbg_src_tree_tmp[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4); // parent_line_no /* NOT USED */
658 dbg_src_tree_tmp[2] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 8); // mod_no
659 dbg_src_tree_tmp[3] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 12); // imod_name
661 if(getModByNo(dbg_src_tree_tmp[2]).equals("")) {
662 String fileName= new String(getRawFrameData(entirePack, dbg_src_tree_tmp[3]));
664 if(fileName.length() > 0) fileName= fileName.substring(0, fileName.length() - 1);
666 if(dbg_src_tree_tmp[2] != 0) {
667 PHPDBGMod modNew= new PHPDBGMod(dbg_src_tree_tmp[2], fileName);
672 case PHPDBGBase.FRAME_RAWDATA:
674 case PHPDBGBase.FRAME_ERROR:
676 dbg_error_tmp[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 0); // type /* type of error */
677 dbg_error_tmp[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4); // imessage /* ID of error message */
680 switch(dbg_error_tmp[0]) {
681 case PHPDBGBase.E_ERROR:
684 case PHPDBGBase.E_WARNING:
687 case PHPDBGBase.E_PARSE:
688 error+= "[Parse Error]";
690 case PHPDBGBase.E_NOTICE:
693 case PHPDBGBase.E_CORE_ERROR:
694 error+= "[Core Error]";
696 case PHPDBGBase.E_CORE_WARNING:
697 error+= "[Core Warning]";
699 case PHPDBGBase.E_COMPILE_ERROR:
700 error+= "[Compile Error]";
702 case PHPDBGBase.E_COMPILE_WARNING:
703 error+= "[Compile Warning]";
705 case PHPDBGBase.E_USER_ERROR:
706 error+= "[User Error]";
708 case PHPDBGBase.E_USER_WARNING:
709 error+= "[User Warning]";
711 case PHPDBGBase.E_USER_NOTICE:
712 error+= "[User Notice]";
715 error+= "[Unexpected Error]";
719 error+= new String(getRawFrameData(entirePack, dbg_error_tmp[1]));
721 if(error.length() > 0) error= error.substring(0, error.length() - 1);
724 PHPDebugCorePlugin.log(new DebugException(new Status(IStatus.WARNING, PHPDebugCorePlugin.PLUGIN_ID, IStatus.OK, error, null)));
725 // To print errors on the console, I must execute a code in the
726 // php context, that write the stderr... I didn't found a better way
727 // TODO: Find a better way????
729 codeExec= "fwrite(fopen('php://stderr', 'w'),\\\"" + error + "\\\");";
731 evalBlock("eval(\"" + codeExec + "\");");
732 } catch (DebugException e) {
733 PHPDebugCorePlugin.log(e);
736 if(lastCommand.equals(PHPDBGBase.DBGA_CONTINUE)) {
738 } else if(lastCommand.equals(PHPDBGBase.DBGA_STEPINTO)) {
740 } else if(lastCommand.equals(PHPDBGBase.DBGA_STEPOUT)) {
742 } else if(lastCommand.equals(PHPDBGBase.DBGA_STEPOVER)) {
747 case PHPDBGBase.FRAME_EVAL:
748 String evalString= new String("");
749 dbg_eval_tmp[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 0); // istr
750 dbg_eval_tmp[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4); // iresult
751 dbg_eval_tmp[2] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 8); // ierror
753 evalRet= getRawFrameData(entirePack, dbg_eval_tmp[1]);
754 evalString= getRawFrameData(entirePack, dbg_eval_tmp[0]);
757 case PHPDBGBase.FRAME_BPS:
759 case PHPDBGBase.FRAME_BPL:
760 int[] dbg_bpl_new= new int[10];
761 dbg_bpl_new[0] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 0);
762 dbg_bpl_new[1] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 4);
763 dbg_bpl_new[2] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 8);
764 dbg_bpl_new[3] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 12);
765 dbg_bpl_new[4] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 16);
766 dbg_bpl_new[5] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 20);
767 dbg_bpl_new[6] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 24);
768 dbg_bpl_new[7] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 28);
769 dbg_bpl_new[8] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 32);
770 dbg_bpl_new[9] = PHPDBGBase.Char4ToInt(entirePack, nextFrame + 36);
772 // look if breakpoint already exists in vector
773 for(i=0; i < DBGBPList.size(); i++) {
774 dbg_bpl_tmp= (int[]) DBGBPList.get(i);
775 if(dbg_bpl_tmp[8] == dbg_bpl_new[8]) {
781 // add breakpoint to vector
782 DBGBPList.add(dbg_bpl_new);
783 copyToLastBP(dbg_bpl_new);
786 if(getModByNo(dbg_bpl_new[0]).equals("")) {
787 String fileName= new String(getRawFrameData(entirePack, dbg_bpl_new[2]));
789 if(fileName.length() > 0) fileName= fileName.substring(0, fileName.length() - 1);
790 if(dbg_bpl_new[0] != 0) {
791 PHPDBGMod modNew= new PHPDBGMod(dbg_bpl_new[0], fileName);
796 case PHPDBGBase.FRAME_VER:
798 case PHPDBGBase.FRAME_SID:
800 case PHPDBGBase.FRAME_SRCLINESINFO:
802 case PHPDBGBase.FRAME_SRCCTXINFO:
804 case PHPDBGBase.FRAME_LOG:
806 case PHPDBGBase.FRAME_PROF:
808 case PHPDBGBase.FRAME_PROF_C:
810 case PHPDBGBase.FRAME_SET_OPT:
814 nextFrame += dbg_frame[1];
817 // Now process command
818 switch(cmdReceived) {
819 case PHPDBGBase.DBGC_REPLY:
821 case PHPDBGBase.DBGC_STARTUP:
823 case PHPDBGBase.DBGC_END:
826 case PHPDBGBase.DBGC_BREAKPOINT:
827 newStackList= new PHPStackFrame[stackList.size()];
828 newStackList= (PHPStackFrame[]) stackList.toArray(newStackList);
829 DBGStackList= newStackList;
830 BPUnderHit= getBPUnderHit();
832 case PHPDBGBase.DBGC_STEPINTO_DONE:
833 case PHPDBGBase.DBGC_STEPOVER_DONE:
834 case PHPDBGBase.DBGC_STEPOUT_DONE:
835 case PHPDBGBase.DBGC_EMBEDDED_BREAK:
836 case PHPDBGBase.DBGC_PAUSE:
838 newStackList= new PHPStackFrame[stackList.size()];
839 newStackList= (PHPStackFrame[]) stackList.toArray(newStackList);
840 DBGStackList= newStackList;
842 case PHPDBGBase.DBGC_ERROR:
844 newStackList= new PHPStackFrame[stackList.size()];
845 newStackList= (PHPStackFrame[]) stackList.toArray(newStackList);
846 DBGStackList= newStackList;
848 case PHPDBGBase.DBGC_LOG:
850 case PHPDBGBase.DBGC_SID:
857 public PHPStackFrame[] getStackList() {
861 private int readInput(char[] buffer, int bytes) throws IOException {
864 for(int i=0; i < bytes; i++) {
866 buffer[i]= (char) (in.read() & 0x00FF);
875 public void setShouldStop() {
876 this.shouldStop= true;
879 public void waitResponse(long milliseconds) throws IOException {
880 long timeout= System.currentTimeMillis() + milliseconds;
881 while(System.currentTimeMillis() < timeout) {
882 if(in.ready() || shouldStop) {