]> granicus.if.org Git - php/commitdiff
Fix frames output
authorBob Weinand <bobwei9@hotmail.com>
Mon, 6 Oct 2014 09:46:39 +0000 (11:46 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Mon, 6 Oct 2014 09:46:39 +0000 (11:46 +0200)
phpdbg_frame.c
phpdbg_utils.c

index 8c7b1084ea97a2b0242486cd8a51061cd8c0db45..eb4a9a8b4d1b6a9d49962ed61113dde9d953b7ce 100644 (file)
@@ -104,6 +104,7 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
 {
        zval **funcname, **class, **type, **args, **argstmp;
        char is_class;
+       int has_args = FAILURE;
 
        zend_hash_find(Z_ARRVAL_PP(tmp), "function", sizeof("function"),
                (void **)&funcname);
@@ -121,19 +122,26 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
                zend_hash_find(Z_ARRVAL_PP(tmp), "type", sizeof("type"), (void **)&type);
        }
 
+       has_args = zend_hash_find(Z_ARRVAL_PP(tmp), "args", sizeof("args"), (void **)&args) == SUCCESS;
+
        phpdbg_xml(" symbol=\"%s%s%s\"",
                is_class == FAILURE?"":Z_STRVAL_PP(class),
                is_class == FAILURE?"":Z_STRVAL_PP(type),
                Z_STRVAL_PP(funcname)
        );
+       if (has_args) {
+               phpdbg_xml(">");
+       } else {
+               phpdbg_xml(" />");
+       }
+
        phpdbg_out("%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) {
+       if (has_args) {
                HashPosition iterator;
                const zend_function *func = phpdbg_get_function(
                        Z_STRVAL_PP(funcname), is_class == FAILURE ? NULL : Z_STRVAL_PP(class) TSRMLS_CC);
@@ -141,8 +149,6 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
                int j = 0, m = func ? func->common.num_args : 0;
                zend_bool is_variadic = 0;
 
-               phpdbg_xml(">");
-
                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) {
@@ -154,15 +160,14 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
 #if PHP_VERSION_ID >= 50600
                                is_variadic = arginfo[j].is_variadic;
 #endif
-                               phpdbg_xml(" variadic=\"%s\" name=\"%s\"", is_variadic ? "variadic" : "", arginfo[j].name);
+                               phpdbg_xml(" variadic=\"%s\" name=\"%s\">", is_variadic ? "variadic" : "", arginfo[j].name);
+                               phpdbg_out("%s=%s", arginfo[j].name, is_variadic ? "[": "");
 
-                               phpdbg_out("%s=%s",
-                                       arginfo[j].name, is_variadic ? "[": "");
+                       } else {
+                               phpdbg_xml(">");
                        }
                        ++j;
 
-                       phpdbg_xml(">");
-
                        zend_print_flat_zval_r(*argstmp TSRMLS_CC);
                        zend_hash_move_forward_ex(Z_ARRVAL_PP(args), &iterator);
 
@@ -172,8 +177,6 @@ static void phpdbg_dump_prototype(zval **tmp TSRMLS_DC) /* {{{ */
                        phpdbg_out("]");
                }
                phpdbg_xml("</frame>");
-       } else {
-               phpdbg_xml(" />");
        }
        phpdbg_out(")");
 }
@@ -210,13 +213,13 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
                }
 
                if (user_defined == SUCCESS) {
-                       phpdbg_xml("<frame id=\"%d\" file=\"%s\" line=\"%d\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
                        phpdbg_out("frame #%d: ", i++);
+                       phpdbg_xml("<frame %r id=\"%d\" file=\"%s\" line=\"%d\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
                        phpdbg_dump_prototype(tmp TSRMLS_CC);
                        phpdbg_out(" at %s:%ld\n", Z_STRVAL_PP(file), Z_LVAL_PP(line));
                } else {
-                       phpdbg_xml("<frame id=\"%d\" internal=\"internal\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
                        phpdbg_out(" => ");
+                       phpdbg_xml("<frame %r id=\"%d\" internal=\"internal\"", i, Z_STRVAL_PP(file), Z_LVAL_PP(line));
                        phpdbg_dump_prototype(tmp TSRMLS_CC);
                        phpdbg_out(" (internal function)\n");
                }
@@ -225,5 +228,5 @@ void phpdbg_dump_backtrace(size_t num TSRMLS_DC) /* {{{ */
        phpdbg_out("\n");
        zval_dtor(&zbacktrace);
 
-       phpdbg_xml("<backtrace>");
+       phpdbg_xml("</backtrace>");
 } /* }}} */
index 782a8f085f97854a92d7338beed09cddc1ed0319..c303bc1665435dac5df8e6c92df09aa48899e526 100644 (file)
@@ -771,6 +771,12 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca
                                        break;
 
 
+                               case 'r':
+                                       s_len = asprintf(&s, "req=\"%lu\"", PHPDBG_G(req_id));
+                                       free_s = s;
+                                       break;
+
+
                                case 'f':
                                case 'F':
                                case 'e':
@@ -1279,7 +1285,7 @@ PHPDBG_API int phpdbg_xml_internal(FILE *fp TSRMLS_DC, const char *fmt, ...) {
                int buflen;
 
                va_start(args, fmt);
-               buflen = vspprintf(&buffer, 0, fmt, args);
+               buflen = phpdbg_xml_vasprintf(&buffer, fmt, 0, args TSRMLS_CC);
                va_end(args);
 
                if (PHPDBG_G(in_script_xml)) {