com php-src: - Splitting prototype dumping code: phpdbg_frame .c phpdbg_frame.h
| From: | Bob Weinand | Date: | Sun, 08 Dec 2013 18:47:53 +0000 |
| Subject: | com php-src: - Splitting prototype dumping code: phpdbg_frame .c phpdbg_frame.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75284@lists.php.net to get a copy of this message | ||
Commit: 1fc10b5706422e4a59788040b7fbba497e5939a6
Author: Felipe Pena <felipensp@gmail.com> Sun, 8 Dec 2013 16:47:53 -0200
Parents: e5a2d2efbd02004bb729aad6719ddbafde19207a
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1fc10b5706422e4a59788040b7fbba497e5939a6
Log:
- Splitting prototype dumping code
Changed paths:
M phpdbg_frame.c
M phpdbg_frame.h
Diff:
diff --git a/phpdbg_frame.c b/phpdbg_frame.c
index bbd7d340..c35a4f9 100644
--- a/phpdbg_frame.c
+++ b/phpdbg_frame.c
@@ -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);
diff --git a/phpdbg_frame.h b/phpdbg_frame.h
index 4b874b0..fbccd54 100644
--- a/phpdbg_frame.h
+++ b/phpdbg_frame.h
@@ -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);