Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c

From: Date: Sat, 11 May 2002 14:43:42 +0000
Subject: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_builtin_functions.c
References: 1 2  Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-115@lists.php.net to get a copy of this message
Yes, this is a bit of a problem. I think I'll only fix it once we start seriously changing a PHP tree for Engine 2 because I don't want to screw things up there right now. I don't think it's very important for now. Nice catch though. Andi At 13:28 10/05/2002 +0200, Markus Fischer wrote:
    Hi,
    I've noticed a difference when using the '-r' switch:
    $ php4-ze2-bt -r '$bt = debug_backtrace(); var_dump($bt);'
    array(0) {
    }
    $ echo '<? $bt = debug_backtrace(); var_dump($bt); ?>' |
php4-ze2-bt array(1) { [0]=> array(3) {
    ["function"]=>
    string(15) "debug_backtrace"
    ["file"]=>
    string(1) "-"
    ["line"]=>
    int(1)
} }
    - Markus
On Fri, May 10, 2002 at 09:41:50AM -0000, Andi Gutmans wrote :
andi          Fri May 10 05:41:50 2002 EDT
Modified files:
    /ZendEngine2      zend_builtin_functions.c
Log: - Make debug_backtrace() return an array. Still not finished because I might want to differentiate between method calls and static methods. Example: $bt = debug_backtrace(); foreach ($bt as $frame) {
      if (isset($frame['class'])) {
              print $frame['class'];
              print "::";
      }
      print $frame['function'];
      print "   [";
      print $frame['file'];
      print ":";
      print $frame['line'];
      print "]\n";
} Index: ZendEngine2/zend_builtin_functions.c diff -u ZendEngine2/zend_builtin_functions.c:1.122 ZendEngine2/zend_builtin_functions.c:1.123
--- ZendEngine2/zend_builtin_functions.c:1.122        Wed May  8 14:43:18 2002
+++ ZendEngine2/zend_builtin_functions.c      Fri May 10 05:41:50 2002
@@ -1195,16 +1195,27 @@
      int lineno;
      char *function_name;
      char *filename;
+     char *class_name;
+     zend_uint class_name_length;
+     zval *stack_frame;
      ptr = EG(current_execute_data);
      lineno = ptr->opline->lineno;
+     array_init(return_value);
+
      while (ptr) {
+             MAKE_STD_ZVAL(stack_frame);
+             array_init(stack_frame);
+
+             class_name = NULL;
+
              if (ptr->object) {
-                     printf("%s::", Z_OBJCE(*ptr->object)->name);
+                     class_name = Z_OBJCE(*ptr->object)->name;
+                     class_name_length = Z_OBJCE(*ptr->object)->name_length;
              }
              if (ptr->function_state.function->common.scope) {
-                     printf("%s::", ptr->function_state.function->common.scope->name);
+                     class_name = ptr->function_state.function->common.scope->name;
              }
              function_name = ptr->function_state.function->common.function_name;
              if (!function_name) {
@@ -1213,17 +1224,26 @@
              ptr = ptr->prev_execute_data;
              if (!ptr) {
+                     zval_ptr_dtor(&stack_frame);
                      break;
              }
- +
              filename = ptr->function_state.function->op_array.filename;
+
+             add_assoc_string_ex(stack_frame, "function", sizeof("function"), function_name, 1);
+             if (class_name) {
+                     add_assoc_string_ex(stack_frame, "class", sizeof("class"), class_name, 1);
+             }
+             add_assoc_string_ex(stack_frame, "file", sizeof("file"), filename, 1);
+             add_assoc_long_ex(stack_frame, "line", sizeof("line"), lineno);
+             //add_assoc_stringl_ex(stack_frame, "class", sizeof("class")-1, class_name, class_name_length, 1);
-             printf("%s() [%s:%d]\n", function_name, filename, lineno);
+             add_next_index_zval(return_value, stack_frame);
+
              if (ptr->opline) {
                      lineno = ptr->opline->lineno;
              }
      }
-     RETURN_TRUE;
} -- Zend Engine CVS Mailing List (http://cvs.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Please always Cc to me when replying to me on the lists. GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc "I'm not stupid, you know? :)" - Jani Taskinen


« previous php.zend-engine.cvs (#115) next »