[xdebug-dev] xdebug xdebug/xdebug.c - fix the availability of used vars from included files.

From: Shane Caraveo <shane[@]caraveo.com>
Date: Fri, 16 Jul 2004 23:42:06 +0200

Date: Fri Jul 16 23:42:05 CEST 2004
User: Shane Caraveo
Directory: xdebug

Log Message:
[2.00]
- fix the availability of used vars from included files.
# since included files are treated as a stack frame, we have to update
# the used vars in all the parent stack frames, up to the 'real' previous
# stack, which is either the top stack or the first fuction stack we find.
# Without this patch, when you step into an included file, you would not
# see the variables defined at the global level of that file.

Modified files:
           xdebug/xdebug.c (version: 1.229)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -r1.228 -r1.229
--- xdebug/xdebug.c:1.228 Tue Jul 13 09:13:20 2004 GMT
+++ xdebug/xdebug.c Fri Jul 16 19:42:05 2004 GMT
@@ -804,7 +804,10 @@
         int i = 0;
         int j = op_array->size;
 
- fse->used_vars = xdebug_hash_alloc(64, used_var_dtor);
+ if (!fse->used_vars) {
+ fse->used_vars = xdebug_hash_alloc(64, used_var_dtor);
+ }
+
         while (i < j) {
                 if (op_array->opcodes[i].opcode == ZEND_FETCH_R || op_array->opcodes[i].opcode == ZEND_FETCH_W) {
                         if (op_array->opcodes[i].op1.op_type == IS_CONST) {
@@ -884,10 +887,11 @@
 {
         zval **dummy;
         zend_execute_data *edata = EG(current_execute_data);
- function_stack_entry *fse;
+ function_stack_entry *fse, *xfse;
         char *magic_cookie = NULL;
         int do_return = (XG(do_trace) && XG(trace_file));
         int function_nr = 0;
+ xdebug_llist_element *le;
 
         if (XG(level) == 0) {
                 /* Set session cookie if requested */
@@ -988,8 +992,16 @@
 
         fse->symbol_table = EG(active_symbol_table);
 
- if (XDEBUG_IS_FUNCTION(fse->function.type)) {
- add_used_variables(fse, op_array);
+ /* Because include/require is treated as a stack level, we have to
+ add used variables in include/required files to all the stack levels
+ above, until we hit a function or the to level stack. This is so
+ that the variables show up correctly where they should be. We
+ always call add_used_varialbes on the current stack level, otherwise
+ vars in include files do not show up in the locals list. */
+ for (le = XDEBUG_LLIST_TAIL(XG(stack)); le != NULL; le = XDEBUG_LLIST_PREV(le)) {
+ xfse = XDEBUG_LLIST_VALP(le);
+ add_used_variables(xfse, op_array);
+ if (XDEBUG_IS_FUNCTION(xfse->function.type)) break;
         }
 
         /* Check for entry breakpoints */
Received on Fri Jul 16 2004 - 23:42:15 BST

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