[xdebug-dev] xdebug xdebug/xdebug_handler_dbgp.c - Support the -d option for property_get.

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Sun, 7 Nov 2004 08:25:48 +0100

Date: Sun Nov 7 08:25:48 CET 2004
User: Derick Rethans
Directory: xdebug

Log Message:
[0.75]
- Support the -d option for property_get.

Modified files:
           xdebug/xdebug_handler_dbgp.c (version: 1.64)

[FILE: /xdebug/xdebug_handler_dbgp.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -r1.63 -r1.64
--- xdebug/xdebug_handler_dbgp.c:1.63 Thu Nov 04 22:10:00 2004 GMT
+++ xdebug/xdebug_handler_dbgp.c Sun Nov 07 06:25:48 2004 GMT
@@ -236,12 +236,12 @@
                         return *retval;
                 }
         }
-
+#if 0
         st = &EG(symbol_table);
         if (zend_hash_find(st, name, name_length, (void **) &retval) == SUCCESS) {
                 return *retval;
         }
-
+#endif
         return NULL;
 }
 
@@ -1100,17 +1100,15 @@
         }
 }
 
-static int add_variable_node(xdebug_xml_node *node, char *name, int name_length, int var_only, int non_null TSRMLS_DC)
+static int add_variable_node(xdebug_xml_node *node, char *name, int name_length, int var_only, int non_null, int no_eval TSRMLS_DC)
 {
         xdebug_xml_node *contents;
         zval ret_zval;
         int res;
 
- XG(active_symbol_table) = EG(active_symbol_table);
         contents = get_symbol_contents(name, name_length TSRMLS_CC);
- XG(active_symbol_table) = NULL;
 
- if (!contents) {
+ if (!contents && !no_eval) {
                 char *varname = NULL;
                 if (var_only && name[0] != '$') {
                         varname = xdebug_sprintf("$%s", name);
@@ -1135,11 +1133,28 @@
 
 DBGP_FUNC(property_get)
 {
+ int depth = -1;
+ function_stack_entry *fse;
+
         if (!CMD_OPTION('n')) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_INVALID_ARGS);
         }
 
- if (add_variable_node(*retval, CMD_OPTION('n'), strlen(CMD_OPTION('n')) + 1, 1, 0 TSRMLS_CC) == FAILURE) {
+ if (CMD_OPTION('d')) {
+ depth = strtol(CMD_OPTION('d'), NULL, 10);
+ }
+ /* Set the symbol table corresponding with the requested stack depth */
+ if (depth == -1) {
+ XG(active_symbol_table) = EG(active_symbol_table);
+ } else {
+ if ((fse = xdebug_get_stack_frame(depth TSRMLS_CC))) {
+ XG(active_symbol_table) = fse->symbol_table;
+ } else {
+ RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_STACK_DEPTH_INVALID);
+ }
+ }
+
+ if (add_variable_node(*retval, CMD_OPTION('n'), strlen(CMD_OPTION('n')) + 1, 1, 0, 1 TSRMLS_CC) == FAILURE) {
                 RETURN_RESULT(XG(status), XG(reason), XDEBUG_ERROR_PROPERTY_NON_EXISTANT);
         }
 }
@@ -1205,7 +1220,7 @@
 {
         zval *var_data;
         zval ret_zval;
- zval *p_ret_zval = &ret_zval;
+ zval *p_ret_zval = &ret_zval;
         int res;
         char *name = CMD_OPTION('n');
         long context_id = 0, depth = 0;
@@ -1295,17 +1310,17 @@
 
 #ifdef ZEND_ENGINE_2
                 /* zend engine 2 does not give us $this, eval so we can get it */
- add_variable_node(node, "this", sizeof("this"), 1, 1 TSRMLS_CC);
+ add_variable_node(node, "this", sizeof("this"), 1, 1, 0 TSRMLS_CC);
 #endif
                 if (options->show_hidden && context_id > 0) {
                         /* add supper globals */
- add_variable_node(node, "_ENV", sizeof("_ENV"), 1, 1 TSRMLS_CC);
- add_variable_node(node, "_GET", sizeof("_GET"), 1, 1 TSRMLS_CC);
- add_variable_node(node, "_POST", sizeof("_POST"), 1, 1 TSRMLS_CC);
- add_variable_node(node, "_COOKIE", sizeof("_COOKIE"), 1, 1 TSRMLS_CC);
- add_variable_node(node, "_REQUEST", sizeof("_REQUEST"), 1, 1 TSRMLS_CC);
- add_variable_node(node, "_FILES", sizeof("_FILES"), 1, 1 TSRMLS_CC);
- add_variable_node(node, "_SERVER", sizeof("_SERVER"), 1, 1 TSRMLS_CC);
+ add_variable_node(node, "_ENV", sizeof("_ENV"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_GET", sizeof("_GET"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_POST", sizeof("_POST"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_COOKIE", sizeof("_COOKIE"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_REQUEST", sizeof("_REQUEST"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_FILES", sizeof("_FILES"), 1, 1, 0 TSRMLS_CC);
+ add_variable_node(node, "_SERVER", sizeof("_SERVER"), 1, 1, 0 TSRMLS_CC);
                 }
 
                 XG(active_symbol_table) = NULL;
@@ -1596,7 +1611,7 @@
 
 char *xdebug_dbgp_get_revision(void)
 {
- return "$Revision: 1.63 $";
+ return "$Revision: 1.64 $";
 }
 
 int xdebug_dbgp_cmdloop(xdebug_con *context TSRMLS_DC)
Received on Sun Nov 07 2004 - 08:25:53 GMT

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