summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_print.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2015-07-21 12:27:50 +0200
committerAnatol Belski <ab@php.net>2015-07-21 12:27:50 +0200
commitb148ef44965651fcbe93e8ee35a14edc087ef17c (patch)
treef5c53fb3d448d0174610d077e0bf3c8bd76834b2 /sapi/phpdbg/phpdbg_print.c
parentad8a73dd55c087de465ad80e8715611693bb1460 (diff)
parent6065b29fe41f09e01dd06ba21980e0344f13230c (diff)
downloadphp-git-b148ef44965651fcbe93e8ee35a14edc087ef17c.tar.gz
Merge branch 'master' into PHP-7.0.0
* master: (204 commits) Reverted ad4533fdbabcc3e545277e30023b2fdce16297a0 update UPGRADING updated NEWS fix comment libwebp support for linux Replaced libvpx by libwebp (first draft; Windows only) update news with bug #70022 Change E_ERROR and some E_WARNING to E_RECOVERABLE_ERROR. Add tests for json_last_error()/json_last_error_msg() failures updated NEWS updated NEWS Exclude opcache from a few opcode related tests updated NEWS updated NEWS Fix #66387: Stack overflow with imagefilltoborder Fix various Windows issues (e.g. dir separators) Remove bogus exception_save() from FETCH_CLASS Fix readline/libedit build Do not use readline when not having a tty This is important for e.g. run-tests.php Add show_unexecuted option to phpdbg_end_oplog() ... Conflicts: Zend/tests/temporary_cleaning_001.phpt Zend/tests/temporary_cleaning_003.phpt Zend/tests/temporary_cleaning_004.phpt Zend/tests/temporary_cleaning_005.phpt Zend/zend_compile.c Zend/zend_compile.h sapi/phpdbg/phpdbg_opcode.c
Diffstat (limited to 'sapi/phpdbg/phpdbg_print.c')
-rw-r--r--sapi/phpdbg/phpdbg_print.c89
1 files changed, 60 insertions, 29 deletions
diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c
index 95e0caf784..4a00189b46 100644
--- a/sapi/phpdbg/phpdbg_print.c
+++ b/sapi/phpdbg/phpdbg_print.c
@@ -82,16 +82,11 @@ static inline void phpdbg_print_function_helper(zend_function *method) /* {{{ */
do {
char *decode = phpdbg_decode_opline(op_array, opline);
- if (decode != NULL) {
- phpdbg_writeln("print", "line=\"%u\" opnum=\"%u\" opcode=\"%s\" op=\"%s\"", " L%-4u #%-5u %-23s %s",
- opline->lineno,
- opcode,
- phpdbg_decode_opcode(opline->opcode) + 5, /* remove ZEND_ prefix */
- decode);
- free(decode);
- } else {
- phpdbg_error("print", "type=\"decodefailure\" opline=\"%16p\"", "Failed to decode opline %16p", opline);
- }
+ phpdbg_writeln("print", "line=\"%u\" opnum=\"%u\" op=\"%s\"", " L%-4u #%-5u %s",
+ opline->lineno,
+ opcode,
+ decode);
+ efree(decode);
opline++;
} while (opcode++ < end);
}
@@ -271,23 +266,27 @@ void phpdbg_print_opcodes_function(const char *function, size_t len) {
zend_function *func = zend_hash_str_find_ptr(EG(function_table), function, len);
if (!func) {
+ zend_string *rt_name;
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), rt_name, func) {
+ if (func->type == ZEND_USER_FUNCTION && *rt_name->val == '\0') {
+ if (func->op_array.function_name->len == len && !zend_binary_strcasecmp(function, len, func->op_array.function_name->val, func->op_array.function_name->len)) {
+ phpdbg_print_opcodes_function(rt_name->val, rt_name->len);
+ }
+ }
+ } ZEND_HASH_FOREACH_END();
+
return;
}
- phpdbg_out("function name: %.*s\n", (int) len, function);
+ phpdbg_out("function name: %.*s\n", ZSTR_LEN(func->op_array.function_name), ZSTR_VAL(func->op_array.function_name));
phpdbg_print_function_helper(func);
}
-void phpdbg_print_opcodes_method(const char *class, const char *function) {
- zend_class_entry *ce;
+static void phpdbg_print_opcodes_method_ce(zend_class_entry *ce, const char *function) {
zend_function *func;
- if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) {
- return;
- }
-
if (ce->type != ZEND_USER_CLASS) {
- phpdbg_out("function name: %s::%s (internal)\n", class, function);
+ phpdbg_out("function name: %s::%s (internal)\n", ce->name->val, function);
return;
}
@@ -295,20 +294,34 @@ void phpdbg_print_opcodes_method(const char *class, const char *function) {
return;
}
- phpdbg_out("function name: %s::%s\n", class, function);
+ phpdbg_out("function name: %s::%s\n", ce->name->val, function);
phpdbg_print_function_helper(func);
}
-void phpdbg_print_opcodes_class(const char *class) {
+void phpdbg_print_opcodes_method(const char *class, const char *function) {
zend_class_entry *ce;
- zend_function *method;
- zend_string *method_name;
- zend_bool first = 1;
if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) {
+ zend_string *rt_name;
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), rt_name, ce) {
+ if (ce->type == ZEND_USER_CLASS && *rt_name->val == '\0') {
+ if (ce->name->len == strlen(class) && !zend_binary_strcasecmp(class, strlen(class), ce->name->val, ce->name->len)) {
+ phpdbg_print_opcodes_method_ce(ce, function);
+ }
+ }
+ } ZEND_HASH_FOREACH_END();
+
return;
}
+ phpdbg_print_opcodes_method_ce(ce, function);
+}
+
+static void phpdbg_print_opcodes_ce(zend_class_entry *ce) {
+ zend_function *method;
+ zend_string *method_name;
+ zend_bool first = 1;
+
phpdbg_out("%s %s: %s\n",
(ce->type == ZEND_USER_CLASS) ?
"user" : "internal",
@@ -343,10 +356,28 @@ void phpdbg_print_opcodes_class(const char *class) {
} ZEND_HASH_FOREACH_END();
}
+void phpdbg_print_opcodes_class(const char *class) {
+ zend_class_entry *ce;
+
+ if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) {
+ zend_string *rt_name;
+ ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), rt_name, ce) {
+ if (ce->type == ZEND_USER_CLASS && *rt_name->val == '\0') {
+ if (ce->name->len == strlen(class) && !zend_binary_strcasecmp(class, strlen(class), ce->name->val, ce->name->len)) {
+ phpdbg_print_opcodes_ce(ce);
+ }
+ }
+ } ZEND_HASH_FOREACH_END();
+
+ return;
+ }
+
+ phpdbg_print_opcodes_ce(ce);
+}
+
PHPDBG_API void phpdbg_print_opcodes(char *function)
{
- char *method_name;
- strtok(function, ":");
+ char *method_name = strtok(function, ":");
if (function == NULL) {
phpdbg_print_opcodes_main();
@@ -365,15 +396,15 @@ PHPDBG_API void phpdbg_print_opcodes(char *function)
}
} ZEND_HASH_FOREACH_END();
- ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), name, ce) {
+ ZEND_HASH_FOREACH_PTR(EG(class_table), ce) {
if (ce->type == ZEND_USER_CLASS) {
phpdbg_out("\n\n");
- phpdbg_print_opcodes_class(ZSTR_VAL(name));
+ phpdbg_print_opcodes_ce(ce);
}
} ZEND_HASH_FOREACH_END();
- } else if ((method_name = strtok(NULL, ":")) == NULL) {
+ } else if (method_name == NULL) {
phpdbg_print_opcodes_function(function, strlen(function));
- } else if ((method_name + 1) == NULL) {
+ } else if ((method_name = strtok(NULL, ":")) == NULL) {
phpdbg_print_opcodes_class(function);
} else {
phpdbg_print_opcodes_method(function, method_name);