com php-src: class printer: phpdbg_opcode.c phpdbg_prin t.c phpdbg_prompt.c phpdbg_utils.c test.php
| From: | Bob Weinand | Date: | Wed, 13 Nov 2013 01:35:39 +0000 |
| Subject: | com php-src: class printer: phpdbg_opcode.c phpdbg_prin t.c phpdbg_prompt.c phpdbg_utils.c test.php | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75043@lists.php.net to get a copy of this message | ||
Commit: 68cff82d8bd6b046cbac556136b88dd76d6a116b
Author: krakjoe <joe.watkins@live.co.uk> Wed, 13 Nov 2013 01:35:39 +0000
Parents: 43c2748dced2a77b34c09c15e403c6970b74e2b2
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=68cff82d8bd6b046cbac556136b88dd76d6a116b
Log:
class printer
Changed paths:
M phpdbg_opcode.c
M phpdbg_print.c
M phpdbg_prompt.c
M phpdbg_utils.c
M test.php
Diff:
diff --git a/phpdbg_opcode.c b/phpdbg_opcode.c
index 5796678..39a5169 100644
--- a/phpdbg_opcode.c
+++ b/phpdbg_opcode.c
@@ -191,6 +191,7 @@ const char *phpdbg_decode_opcode(zend_uchar opcode) /* {{{ */
CASE(ZEND_RECV_VARIADIC);
#endif
CASE(ZEND_OP_DATA);
- default: return "UNKNOWN";
+ default:
+ return "UNKNOWN";
}
} /* }}} */
diff --git a/phpdbg_print.c b/phpdbg_print.c
index c0d8fb4..f5cbbd3 100644
--- a/phpdbg_print.c
+++ b/phpdbg_print.c
@@ -20,6 +20,7 @@
#include "phpdbg.h"
#include "phpdbg_print.h"
#include "phpdbg_utils.h"
+#include "phpdbg_opcode.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@@ -41,7 +42,59 @@ PHPDBG_PRINT(class) /* {{{ */
if (expr && expr_len > 0L) {
if (zend_lookup_class(expr, strlen(expr), &ce TSRMLS_CC) == SUCCESS) {
+ phpdbg_notice(
+ "%s %s: %s",
+ ((*ce)->type == ZEND_USER_CLASS) ?
+ "User" : "Internal",
+ ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
+ "Interface" :
+ ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
+ "Abstract Class" :
+ "Class",
+ (*ce)->name);
+ phpdbg_writeln("Methods (%d):",
zend_hash_num_elements(&(*ce)->function_table));
+ if (zend_hash_num_elements(&(*ce)->function_table)) {
+ HashPosition position;
+ zend_function *method;
+
+ for (zend_hash_internal_pointer_reset_ex(&(*ce)->function_table,
&position);
+ zend_hash_get_current_data_ex(&(*ce)->function_table, (void**)
&method, &position) == SUCCESS;
+ zend_hash_move_forward_ex(&(*ce)->function_table, &position)) {
+ switch (method->type) {
+ case ZEND_USER_FUNCTION: {
+ zend_op_array* op_array = &method->op_array;
+
+ if (op_array) {
+ zend_op *opline = &op_array->opcodes[0];
+ zend_uint opcode = 0,
+ end = op_array->last-1;
+
+ phpdbg_writeln(
+ "\t%s::%s() in %s:%d-%d",
+ (*ce)->name, method->common.function_name,
+ op_array->filename ? op_array->filename :
"unknown",
+ op_array->line_start, op_array->line_end);
+
+ do {
+ char *decode = phpdbg_decode_opcode(opline->opcode);
+ if (decode != NULL) {
+ phpdbg_writeln(
+ "\t\t%p:%s", opline, decode);
+ } else phpdbg_error("\tFailed to decode opline @
%ld", opline);
+
+ opline++;
+ } while (++opcode < end);
+ }
+ } break;
+
+ default: {
+ phpdbg_writeln(
+ "\tInternal Method %s::%s()", (*ce)->name,
method->common.function_name);
+ }
+ }
+ }
+ }
} else {
phpdbg_error("Cannot find class %s/%lu", expr, expr_len);
}
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index f7cba8c..d2cd8be 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -547,7 +547,7 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
phpdbg_interactive_enter:
phpdbg_write(PROMPT);
-
+
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING) &&
fgets(cmd, PHPDBG_MAX_CMD, stdin) != NULL) {
cmd_len = strlen(cmd) - 1;
diff --git a/phpdbg_utils.c b/phpdbg_utils.c
index 27ada70..3c8606c 100644
--- a/phpdbg_utils.c
+++ b/phpdbg_utils.c
@@ -23,6 +23,7 @@
#include "php.h"
#include "spprintf.h"
#include "phpdbg.h"
+#include "phpdbg_opcode.h"
#include "phpdbg_utils.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
diff --git a/test.php b/test.php
index 457e487..0f240e1 100644
--- a/test.php
+++ b/test.php
@@ -2,6 +2,7 @@
class my {
public function method() {
+ echo "Hello";
return $this;
}
}