);
} /* }}} */
+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);
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);