]> granicus.if.org Git - php/commitdiff
- Splitting prototype dumping code
authorFelipe Pena <felipensp@gmail.com>
Sun, 8 Dec 2013 18:47:53 +0000 (16:47 -0200)
committerFelipe Pena <felipensp@gmail.com>
Sun, 8 Dec 2013 18:47:53 +0000 (16:47 -0200)
phpdbg_frame.c
phpdbg_frame.h

index bbd7d340b792db0534547c674ecd4059d8c919c0..c35a4f96f1610140e1c7820f0c1f1d9553c90012 100644 (file)
@@ -100,14 +100,58 @@ void phpdbg_switch_frame(int frame TSRMLS_DC) /* {{{ */
        );
 } /* }}} */
 
+static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
+{
+       zval **funcname, **class, **type, **args, **argstmp;
+       char is_class;
+
+       zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"),
+               (void **)&funcname);
+
+       if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp),
+               "object", sizeof("object"), (void **)&class)) == FAILURE) {
+               is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"),
+                       (void **)&class);
+       } else {
+               zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class),
+                       (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC);
+       }
+
+       if (is_class == SUCCESS) {
+               zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type);
+       }
+
+       phpdbg_write("%s%s%s(",
+               is_class == FAILURE?"":Z_STRVAL_PP(class),
+               is_class == FAILURE?"":Z_STRVAL_PP(type),
+               Z_STRVAL_PP(funcname)
+       );
+
+       if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"),
+               (void **)&args) == SUCCESS) {
+               HashPosition iterator;
+               int j = 0;
+
+               zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator);
+               while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args),
+                       (void **) &argstmp, &iterator) == SUCCESS) {
+                       if (j++) {
+                               phpdbg_write(", ");
+                       }
+                       zend_print_flat_zval_r(*argstmp TSRMLS_CC);
+                       zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator);
+               }
+       }
+       phpdbg_write(")");
+}
+
 void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
 {
        zval zbacktrace;
-       zval **tmp, **argstmp;
-       zval **file, **line, **funcname, **class, **type, **args;
+       zval **tmp;
+       zval **file, **line;
        HashPosition position;
        int i = 0, limit = num;
-       char is_class;
 
        if (limit < 0) {
                phpdbg_error("Invalid backtrace size %d", limit);
@@ -122,45 +166,16 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
                zend_hash_find(Z_ARRVAL_PP(tmp), "file", sizeof("file"), (void **)&file);
                zend_hash_find(Z_ARRVAL_PP(tmp), "line", sizeof("line"), (void **)&line);
                zend_hash_move_forward_ex(Z_ARRVAL(zbacktrace), &position);
+
+               phpdbg_write("frame #%d: ", i++);
+
                if (zend_hash_get_current_data_ex(Z_ARRVAL(zbacktrace), (void**)&tmp, &position) == FAILURE) {
-                       phpdbg_write(
-                               "frame #%d: {main} at %s:%ld",
-                               i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
+                       phpdbg_write("{main} at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line));
                        break;
                }
-               zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"), (void **)&funcname);
-               if ((is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "object", sizeof("object"), (void **)&class)) == FAILURE) {
-                       is_class = zend_hash_find(Z_ARRVAL_PP(tmp), "class", sizeof("class"), (void **)&class);
-               } else {
-                       zend_get_object_classname(*class, (const char **)&Z_STRVAL_PP(class), (zend_uint *)&Z_STRLEN_PP(class) TSRMLS_CC);
-               }
-               if (is_class == SUCCESS) {
-                       zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type);
-               }
-
-               phpdbg_write(
-                       "frame #%d: %s%s%s(",
-                       i++,
-                       is_class == FAILURE?"":Z_STRVAL_PP(class),
-                       is_class == FAILURE?"":Z_STRVAL_PP(type),
-                       Z_STRVAL_PP(funcname)
-               );
-
-               if (zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS) {
-                       HashPosition iterator;
-                       int j = 0;
-
-                       zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(args), &iterator);
-                       while (zend_hash_get_current_data_ex(Z_ARRVAL_PP(args), (void **) &argstmp, &iterator) == SUCCESS) {
-                               if (j++) {
-                                       phpdbg_write(", ");
-                               }
-                               zend_print_flat_zval_r(*argstmp TSRMLS_CC);
-                               zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator);
-                       }
-               }
 
-               phpdbg_writeln(") at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line));
+               phpdbg_dump_prototype(tmp TSRMLS_CC);
+               phpdbg_writeln(" at %s:%ld", Z_STRVAL_PP(file), Z_LVAL_PP(line));
        }
 
        phpdbg_writeln(EMPTY);
index 4b874b0ee9bdb428465b7aed499761ed7e3282fd..fbccd5404f5b9601b58cbb22192a05031a151c4c 100644 (file)
@@ -22,7 +22,6 @@
 #define PHPDBG_FRAME_H
 
 #include "TSRM.h"
-#include "phpdbg_cmd.h"
 
 void phpdbg_restore_frame(TSRMLS_D);
 void phpdbg_switch_frame(int TSRMLS_DC);