[xdebug-dev] xdebug xdebug/xdebug_handler_dbgp.c xdebug/xdebug_handler_dbgp.h - ignore post mortem if detached

From: Shane Caraveo <shane[@]caraveo.com>
Date: Fri, 24 Aug 2007 03:37:55 +0200

Date: Fri Aug 24 03:37:54 CEST 2007
User: Shane Caraveo
Directory: xdebug

Log Message:
[1.00]
- ignore post mortem if detached
- detach does respond
- fixup post mortem command handler checking
- dont bail if detaching

Modified files:
           xdebug/xdebug_handler_dbgp.c (version: 1.128)
           xdebug/xdebug_handler_dbgp.h (version: 1.21)

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- xdebug/xdebug_handler_dbgp.c:1.127 Thu Aug 23 23:07:57 2007 GMT
+++ xdebug/xdebug_handler_dbgp.c Thu Aug 23 23:37:54 2007 GMT
@@ -63,6 +63,7 @@
 #define DBGP_STATUS_STOPPED 3
 #define DBGP_STATUS_RUNNING 4
 #define DBGP_STATUS_BREAK 5
+#define DBGP_STATUS_DETACHED 6
 
 char *xdebug_dbgp_status_strings[6] =
         {"", "starting", "stopping", "stopped", "running", "break"};
@@ -201,12 +202,13 @@
         DBGP_FUNC_ENTRY(stderr, XDEBUG_DBGP_NONE)
         DBGP_FUNC_ENTRY(stdout, XDEBUG_DBGP_NONE)
 
- DBGP_FUNC_ENTRY(stop, XDEBUG_DBGP_NONE)
         DBGP_CONT_FUNC_ENTRY(run, XDEBUG_DBGP_NONE)
         DBGP_CONT_FUNC_ENTRY(step_into, XDEBUG_DBGP_NONE)
         DBGP_CONT_FUNC_ENTRY(step_out, XDEBUG_DBGP_NONE)
         DBGP_CONT_FUNC_ENTRY(step_over, XDEBUG_DBGP_NONE)
- DBGP_CONT_FUNC_ENTRY(detach, XDEBUG_DBGP_NONE)
+
+ DBGP_STOP_FUNC_ENTRY(stop, XDEBUG_DBGP_POST_MORTEM)
+ DBGP_STOP_FUNC_ENTRY(detach, XDEBUG_DBGP_NONE)
 
         /* Non standard functions */
         DBGP_FUNC_ENTRY(xcmd_profiler_name_get, XDEBUG_DBGP_POST_MORTEM)
@@ -1375,7 +1377,9 @@
 
 DBGP_FUNC(detach)
 {
- XG(status) = DBGP_STATUS_STOPPED;
+ XG(status) = DBGP_STATUS_DETACHED;
+ xdebug_xml_add_attribute(*retval, "status", xdebug_dbgp_status_strings[DBGP_STATUS_STOPPED]);
+ xdebug_xml_add_attribute(*retval, "reason", xdebug_dbgp_reason_strings[XG(reason)]);
         XG(remote_enabled) = 0;
         XG(remote_enable) = 0;
 }
@@ -2197,7 +2201,7 @@
                                 XG(lastcmd) = command->name;
                                 XG(lasttransid) = xdstrdup(CMD_OPTION('i'));
                         }
- if (XG(status) != DBGP_STATUS_STOPPED || (XG(status) == DBGP_STATUS_STOPPED && command->flags & XDEBUG_DBGP_POST_MORTEM)) {
+ if (XG(status) != DBGP_STATUS_STOPPING || (XG(status) == DBGP_STATUS_STOPPING && command->flags & XDEBUG_DBGP_POST_MORTEM)) {
                                 command->handler((xdebug_xml_node**) &retval, context, args TSRMLS_CC);
                                 ret = command->cont;
                         } else {
@@ -2229,7 +2233,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.127 $";
+ return "$Revision: 1.128 $";
 }
 
 static int xdebug_dbgp_cmdloop(xdebug_con *context, int bail TSRMLS_DC)
@@ -2254,7 +2258,7 @@
                 xdebug_xml_node_dtor(response);
 
                 free(option);
- } while (1 != ret && XG(status) != DBGP_STATUS_STOPPED);
+ } while (0 == ret);
         
         if (bail && XG(status) == DBGP_STATUS_STOPPED) {
                 zend_bailout();
@@ -2390,25 +2394,26 @@
         xdebug_var_export_options *options;
         TSRMLS_FETCH();
 
- XG(status) = DBGP_STATUS_STOPPING;
- XG(reason) = DBGP_REASON_OK;
- response = xdebug_xml_node_init("response");
- xdebug_xml_add_attribute(response, "xmlns", "urn:debugger_protocol_v1");
- xdebug_xml_add_attribute(response, "xmlns:xdebug", "http://xdebug.org/dbgp/xdebug");
- /* lastcmd and lasttransid are not always set (for example when the
- * connection is severed before the first command is send) */
- if (XG(lastcmd) && XG(lasttransid)) {
- xdebug_xml_add_attribute_ex(response, "command", XG(lastcmd), 0, 0);
- xdebug_xml_add_attribute_ex(response, "transaction_id", XG(lasttransid), 0, 0);
+ if (XG(remote_enabled)) {
+ XG(status) = DBGP_STATUS_STOPPING;
+ XG(reason) = DBGP_REASON_OK;
+ response = xdebug_xml_node_init("response");
+ xdebug_xml_add_attribute(response, "xmlns", "urn:debugger_protocol_v1");
+ xdebug_xml_add_attribute(response, "xmlns:xdebug", "http://xdebug.org/dbgp/xdebug");
+ /* lastcmd and lasttransid are not always set (for example when the
+ * connection is severed before the first command is send) */
+ if (XG(lastcmd) && XG(lasttransid)) {
+ xdebug_xml_add_attribute_ex(response, "command", XG(lastcmd), 0, 0);
+ xdebug_xml_add_attribute_ex(response, "transaction_id", XG(lasttransid), 0, 0);
+ }
+ xdebug_xml_add_attribute_ex(response, "status", xdebug_dbgp_status_strings[XG(status)], 0, 0);
+ xdebug_xml_add_attribute_ex(response, "reason", xdebug_dbgp_reason_strings[XG(reason)], 0, 0);
+
+ send_message(context, response TSRMLS_CC);
+ xdebug_xml_node_dtor(response);
+
+ xdebug_dbgp_cmdloop(context, 0 TSRMLS_CC);
         }
- xdebug_xml_add_attribute_ex(response, "status", xdebug_dbgp_status_strings[XG(status)], 0, 0);
- xdebug_xml_add_attribute_ex(response, "reason", xdebug_dbgp_reason_strings[XG(reason)], 0, 0);
-
- send_message(context, response TSRMLS_CC);
- xdebug_xml_node_dtor(response);
-
- xdebug_dbgp_cmdloop(context, 0 TSRMLS_CC);
-
         if (XG(stdio).php_body_write != NULL && OG(php_body_write)) {
                 OG(php_body_write) = XG(stdio).php_body_write;
                 OG(php_header_write) = XG(stdio).php_header_write;

[FILE: /xdebug/xdebug_handler_dbgp.h]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- xdebug/xdebug_handler_dbgp.h:1.20 Mon Feb 26 13:43:30 2007 GMT
+++ xdebug/xdebug_handler_dbgp.h Thu Aug 23 23:37:54 2007 GMT
@@ -74,6 +74,7 @@
 #define DBGP_FUNC(name) static void xdebug_dbgp_handle_##name(DBGP_FUNC_PARAMETERS)
 #define DBGP_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 0, flags },
 #define DBGP_CONT_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 1, flags },
+#define DBGP_STOP_FUNC_ENTRY(name,flags) { #name, xdebug_dbgp_handle_##name, 2, flags },
 
 #define XDEBUG_DBGP_NONE 0x00
 #define XDEBUG_DBGP_POST_MORTEM 0x01
Received on Fri Aug 24 2007 - 03:38:37 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST