From: robekras Date: Sun, 11 Dec 2005 15:25:59 +0000 (+0000) Subject: 1) Added handling of conditional breakpoints. X-Git-Url: http://git.phpeclipse.com 1) Added handling of conditional breakpoints. 2) Fixed bug #1373617 (Thanks to Mauro Casciari for submitting the fix). Need to take linenumbers into account for stackframe list. 3) Fixed bug #1378161 (Removed the terminating '\0' from the DBG strings) --- 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 ddcfcb5..1cbb0a9 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 @@ -31,7 +31,6 @@ import org.eclipse.debug.core.DebugException; * */ public class PHPDBGInterface { - public boolean sessionEnded = false; public int sessType = -1; public int BPUnderHit = 0; @@ -70,12 +69,14 @@ public class PHPDBGInterface { /** * - * @param mod_name The module (source file) to which we add the breakpoint. - * @param line The line where the breakpoint is set. - * @return Breakpoint ID ???. + * @param mod_name The module (source file) to which we add the breakpoint. + * @param line The line where the breakpoint is set. + * @param hitCount The number of hit counts before suspend. + * @param condition The break condition + * @return Breakpoint ID ???. */ - public int addBreakpoint (String mod_name, int line) throws IOException { - return setBreakpoint (mod_name, "", line, PHPDBGBase.BPS_ENABLED + PHPDBGBase.BPS_UNRESOLVED, 0, 0, 0, 0, 0); + public int addBreakpoint (String mod_name, int line, int hitCount, String condition) throws IOException { + return setBreakpoint (mod_name, condition, line, PHPDBGBase.BPS_ENABLED + PHPDBGBase.BPS_UNRESOLVED, 0, hitCount, 0, 0, 0); } /** @@ -176,11 +177,13 @@ public class PHPDBGInterface { PHPDBGPacket DBGPacket; PHPDBGFrame DBGFrame1; PHPDBGFrame DBGFrame2; + PHPDBGFrame DBGFrame3; int modNo; - + DBGPacket = new PHPDBGPacket (PHPDBGBase.DBGA_REQUEST); DBGFrame1 = new PHPDBGFrame (PHPDBGBase.FRAME_BPS); DBGFrame2 = new PHPDBGFrame (PHPDBGBase.FRAME_RAWDATA); + DBGFrame3 = new PHPDBGFrame (PHPDBGBase.FRAME_RAWDATA); modNo = getModByName (mod_name); // Get the module ID by name @@ -199,14 +202,6 @@ public class PHPDBGInterface { DBGFrame1.addInt (rawCounter); // ID of FRAME_RAWDATA to send file name } - DBGFrame1.addInt (state); // state BPS_* - DBGFrame1.addInt (istemp); // istep - DBGFrame1.addInt (hitcount); // hit count - DBGFrame1.addInt (skiphits); // skip hits - DBGFrame1.addInt (0); // ID of condition - DBGFrame1.addInt (bpno); // breakpoint number - DBGFrame1.addInt (isunderhit); // is under hit - if (modNo < 0) { // Did we find a module ID for the module name? DBGFrame2.addInt (rawCounter); // FRAME_RAWDATA ID DBGFrame2.addInt (mod_name.length() + 1); // length of rawdata (+ null char) @@ -216,6 +211,30 @@ public class PHPDBGInterface { DBGPacket.addFrame (DBGFrame2); // First add file name data } + DBGFrame1.addInt (state); // state BPS_* + DBGFrame1.addInt (istemp); // istemp + DBGFrame1.addInt (0); // hit count; this is not supported as one might think + DBGFrame1.addInt (hitcount); // skip hits is what we think is hit count. + + if (!condition.equals ("")) { // Do we have a condition for breakpoint + rawCounter++; // Set to new ID + DBGFrame1.addInt (rawCounter); // ID of condition + + DBGFrame3.addInt (rawCounter); // FRAME_RAWDATA ID + DBGFrame3.addInt (condition.length() + 1); // length of rawdata (+ null char) + DBGFrame3.addString (condition); // The break condition + DBGFrame3.addChar ('\0'); // null char + + DBGPacket.addFrame (DBGFrame3); // First add break condition + } + else { + DBGFrame1.addInt (0); // ID of condition is 0, because there is no condition + } + + + DBGFrame1.addInt (bpno); // breakpoint number + DBGFrame1.addInt (isunderhit); // is under hit + DBGPacket.addFrame (DBGFrame1); // Second add command data if (proxy.getSocket ().isClosed ()) { // Can we communiate with DBG? @@ -593,6 +612,10 @@ public class PHPDBGInterface { toRead = PHPDBGBase.Char4ToInt (framesInfo, nextFrame + 4); // The size of the string + if ((int) framesInfo[nextFrame + 8 + toRead - 1] == 0) { // Is there a string termination at the end? + return String.copyValueOf (framesInfo, nextFrame + 8, toRead - 1); // Then copy frame content to String without the \0 and return + } + return String.copyValueOf (framesInfo, nextFrame + 8, toRead); // Copy frame content to String and return } break; @@ -640,7 +663,8 @@ public class PHPDBGInterface { for (n = 0; n < stackListOld.size (); n++) { // For all StackFrames in the StackFrame list stackFrameOld = (PHPStackFrame) stackListOld.get (n); // - if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ())) { // Did we find the sent stackframe within the list of old stackframes? + if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ()) && + stackFrameNew.getLineNumber() == stackFrameOld.getLineNumber()) {// Did we find the sent stackframe within the list of old stackframes? stackFrameOld.setLineNumber (stackFrameNew.getLineNumber ()); stackFrameOld.setIndex (stackFrameNew.getIndex ()); @@ -661,7 +685,8 @@ public class PHPDBGInterface { for (i = 0; i < stackList.size (); i++) { // For all stackList entries stackFrameNew = (PHPStackFrame) stackList.get (i); - if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ())) { // Did we find the sent stackframe within the list of old stackframes? + if (stackFrameNew.getDescription ().equals (stackFrameOld.getDescription ()) && + stackFrameNew.getLineNumber() == stackFrameOld.getLineNumber()) {// Did we find the sent stackframe within the list of old stackframes? break; // Yes, then break; } } @@ -729,7 +754,7 @@ public class PHPDBGInterface { return 0; // We did not read enough bytes, error } } - + nextFrame = 0; // Start with the first frame while (nextFrame < bytesToRead) { // As long as we have something within this block @@ -781,10 +806,6 @@ public class PHPDBGInterface { fileName = new String (getRawFrameData (entirePack, dbg_src_tree_tmp[3])); // Get the filename - if (fileName.length () > 0) { // If we have a filename - fileName = fileName.substring (0, fileName.length () - 1); // Remove '\0' char - } - if (dbg_src_tree_tmp[2] != 0) { // If there is a module number PHPDBGMod modNew; @@ -822,11 +843,6 @@ public class PHPDBGInterface { error += ": "; error += new String (getRawFrameData (entirePack, dbg_error_tmp[1])); // Add the error string for this error message ID - - if (error.length () > 0) { // If we have a error message - error = error.substring (0, error.length () - 1); // Remove '\0' char - } - error += "\n"; // Append a CR PHPDebugCorePlugin.log (new DebugException (new Status (IStatus.WARNING, @@ -911,10 +927,6 @@ public class PHPDBGInterface { fileName = new String (getRawFrameData (entirePack, dbg_bpl_new[2])); - if (fileName.length () > 0) { // If we have filename - fileName = fileName.substring (0, fileName.length () - 1); // Remove '\0' char - } - if (dbg_bpl_new[0] != 0) { PHPDBGMod modNew;