com php-src: Ignore non-executable opcodes in line mode of phpdbg_end_oplog(): sapi/phpdbg/phpdbg.c
| From: | Anatol Belski | Date: | Fri, 14 Oct 2016 00:03:46 +0000 |
| Subject: | com php-src: Ignore non-executable opcodes in line mode of phpdbg_end_oplog(): sapi/phpdbg/phpdbg.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95037@lists.php.net to get a copy of this message | ||
Commit: 990e2ce2a0abf2f4227f526a47abd2825c633a89
Author: Bob Weinand <bobwei9@hotmail.com> Thu, 13 Oct 2016 14:09:12 +0200
Committer: Anatol Belski <ab@php.net> Fri, 14 Oct 2016 02:03:46 +0200
Parents: c79f9a4e49d1e51a5569e60d66d3b7c6014e6135
Branches: PHP-7.1
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=990e2ce2a0abf2f4227f526a47abd2825c633a89
Log:
Ignore non-executable opcodes in line mode of phpdbg_end_oplog()
(cherry picked from commit d14498a475642642cfeee21630058941c33a6dfb)
Changed paths:
M sapi/phpdbg/phpdbg..c
Diff:
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 361b2c5..0722ed9 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -476,6 +476,16 @@ static PHP_FUNCTION(phpdbg_start_oplog)
PHPDBG_G(oplog_list)->start = PHPDBG_G(oplog_cur);
}
+static zend_always_inline zend_bool phpdbg_is_ignored_opcode(zend_uchar opcode) {
+ return
+ opcode == ZEND_NOP || opcode == ZEND_OP_DATA || opcode == ZEND_FE_FREE || opcode == ZEND_FREE
|| opcode == ZEND_ASSERT_CHECK || opcode == ZEND_VERIFY_RETURN_TYPE
+ || opcode == ZEND_DECLARE_CONST || opcode == ZEND_DECLARE_CLASS || opcode ==
ZEND_DECLARE_INHERITED_CLASS || opcode == ZEND_DECLARE_FUNCTION
+ || opcode == ZEND_DECLARE_INHERITED_CLASS_DELAYED || opcode == ZEND_VERIFY_ABSTRACT_CLASS ||
opcode == ZEND_ADD_TRAIT || opcode == ZEND_BIND_TRAITS
+ || opcode == ZEND_DECLARE_ANON_CLASS || opcode == ZEND_DECLARE_ANON_INHERITED_CLASS || opcode ==
ZEND_FAST_RET || opcode == ZEND_TICKS
+ || opcode == ZEND_EXT_STMT || opcode == ZEND_EXT_FCALL_BEGIN || opcode == ZEND_EXT_FCALL_END ||
opcode == ZEND_EXT_NOP || opcode == ZEND_BIND_GLOBAL
+ ;
+}
+
static void phpdbg_oplog_fill_executable(zend_op_array *op_array, HashTable *insert_ht, zend_bool
by_opcode) {
/* ignore RECV_* opcodes */
zend_op *cur = op_array->opcodes + op_array->num_args + !!(op_array->fn_flags &
ZEND_ACC_VARIADIC);
@@ -493,11 +503,8 @@ static void phpdbg_oplog_fill_executable(zend_op_array *op_array, HashTable
*ins
}
for (; cur < end; cur++) {
- if (cur->opcode == ZEND_NOP || cur->opcode == ZEND_OP_DATA || cur->opcode ==
ZEND_FE_FREE || cur->opcode == ZEND_FREE || cur->opcode == ZEND_ASSERT_CHECK || cur->opcode
== ZEND_VERIFY_RETURN_TYPE
- || cur->opcode == ZEND_DECLARE_CONST || cur->opcode == ZEND_DECLARE_CLASS ||
cur->opcode == ZEND_DECLARE_INHERITED_CLASS || cur->opcode == ZEND_DECLARE_FUNCTION
- || cur->opcode == ZEND_DECLARE_INHERITED_CLASS_DELAYED || cur->opcode ==
ZEND_VERIFY_ABSTRACT_CLASS || cur->opcode == ZEND_ADD_TRAIT || cur->opcode == ZEND_BIND_TRAITS
- || cur->opcode == ZEND_DECLARE_ANON_CLASS || cur->opcode ==
ZEND_DECLARE_ANON_INHERITED_CLASS || cur->opcode == ZEND_FAST_RET || cur->opcode == ZEND_TICKS
- || cur->opcode == ZEND_EXT_STMT || cur->opcode == ZEND_EXT_FCALL_BEGIN || cur->opcode
== ZEND_EXT_FCALL_END || cur->opcode == ZEND_EXT_NOP || cur->opcode == ZEND_BIND_GLOBAL) {
+ zend_uchar opcode = cur->opcode;
+ if (phpdbg_is_ignored_opcode(opcode)) {
continue;
}
@@ -507,7 +514,7 @@ static void phpdbg_oplog_fill_executable(zend_op_array *op_array, HashTable *ins
insert_idx = cur->lineno;
}
- if (cur->opcode == ZEND_NEW && (cur + 1)->opcode == ZEND_DO_FCALL) {
+ if (opcode == ZEND_NEW && cur[1].opcode == ZEND_DO_FCALL) {
cur++;
}
@@ -525,7 +532,7 @@ static inline HashTable* phpdbg_add_empty_array(HashTable *ht, zend_string *name
return Z_ARR_P(ht_zv);
}
-/* {{{ proto void phpdbg_end_oplog() */
+/* {{{ proto void phpdbg_get_executable() */
static PHP_FUNCTION(phpdbg_get_executable)
{
HashTable *options = NULL;
@@ -702,6 +709,10 @@ static PHP_FUNCTION(phpdbg_end_oplog)
if (by_opcode) {
insert_idx = cur->op - cur->opcodes;
} else {
+ if (phpdbg_is_ignored_opcode(cur->op->opcode)) {
+ continue;
+ }
+
insert_idx = cur->op->lineno;
}
@@ -713,8 +724,7 @@ static PHP_FUNCTION(phpdbg_end_oplog)
Z_LVAL_P(num)++;
}
- cur = cur->next;
- } while (cur != NULL);
+ } while ((cur = cur->next));
}
if (!prev) {