summaryrefslogtreecommitdiff
path: root/sapi
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-07-25 00:31:05 +0200
committerBob Weinand <bobwei9@hotmail.com>2015-07-25 00:31:05 +0200
commitb4c595dd82548575304d3b41b1c9321f50a5fefd (patch)
tree2b4b4353e05264fb01855e5bd131cad6ec9bfd8a /sapi
parentcf8598593525664d7c66a7998fae68ee9268e60e (diff)
downloadphp-git-b4c595dd82548575304d3b41b1c9321f50a5fefd.tar.gz
Fix op_arrays with opcache
Diffstat (limited to 'sapi')
-rw-r--r--sapi/phpdbg/phpdbg.c2
-rw-r--r--sapi/phpdbg/phpdbg.h1
-rw-r--r--sapi/phpdbg/phpdbg_list.c42
-rw-r--r--sapi/phpdbg/phpdbg_list.h2
4 files changed, 43 insertions, 4 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c
index 0a84202509..a40ab832a4 100644
--- a/sapi/phpdbg/phpdbg.c
+++ b/sapi/phpdbg/phpdbg.c
@@ -1756,6 +1756,8 @@ phpdbg_main:
/* Make stdin, stdout and stderr accessible from PHP scripts */
phpdbg_register_file_handles();
+ phpdbg_list_update();
+
if (show_banner && cleaning < 2) {
/* print blurb */
phpdbg_welcome(cleaning == 1);
diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h
index d6e8ddb1ce..ac9e80946b 100644
--- a/sapi/phpdbg/phpdbg.h
+++ b/sapi/phpdbg/phpdbg.h
@@ -262,6 +262,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg)
zend_bool unclean_eval; /* do not check for memory leaks when we needed to bail out during eval */
zend_op_array *(*compile_file)(zend_file_handle *file_handle, int type);
+ zend_op_array *(*init_compile_file)(zend_file_handle *file_handle, int type);
HashTable file_sources;
FILE *oplog; /* opline log */
diff --git a/sapi/phpdbg/phpdbg_list.c b/sapi/phpdbg/phpdbg_list.c
index 00788a0998..d00f944e9b 100644
--- a/sapi/phpdbg/phpdbg_list.c
+++ b/sapi/phpdbg/phpdbg_list.c
@@ -278,23 +278,52 @@ zend_op_array *phpdbg_compile_file(zend_file_handle *file, int type) {
}
dataptr->lines = ++line;
dataptr->line[line] = endptr - data.buf;
- dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
+ ret = PHPDBG_G(compile_file)(&fake, type);
+
+ if (ret == NULL) {
+ efree(dataptr);
+ return NULL;
+ }
+
+ dataptr = erealloc(dataptr, sizeof(phpdbg_file_source) + sizeof(uint) * line);
zend_hash_str_add_ptr(&PHPDBG_G(file_sources), filename, strlen(filename), dataptr);
phpdbg_resolve_pending_file_break(filename);
- ret = PHPDBG_G(compile_file)(&fake, type);
-
fake.opened_path = NULL;
zend_file_handle_dtor(&fake);
+ return ret;
+}
+
+zend_op_array *phpdbg_init_compile_file(zend_file_handle *file, int type) {
+ char *filename = (char *)(file->opened_path ? ZSTR_VAL(file->opened_path) : file->filename);
+ char resolved_path_buf[MAXPATHLEN];
+ zend_op_array *ret;
+ phpdbg_file_source *dataptr;
+
+ if (VCWD_REALPATH(filename, resolved_path_buf)) {
+ filename = resolved_path_buf;
+ }
+
+ ret = PHPDBG_G(init_compile_file)(file, type);
+
+ if (ret == NULL) {
+ return NULL;
+ }
+
+ dataptr = zend_hash_str_find_ptr(&PHPDBG_G(file_sources), filename, strlen(filename));
+ ZEND_ASSERT(dataptr != NULL);
+
dataptr->op_array = ret;
+ dataptr->destroy_op_array = 1;
if (dataptr->op_array) {
if (dataptr->op_array->refcount) {
++*dataptr->op_array->refcount;
} else {
dataptr->op_array->refcount = emalloc(sizeof(uint32_t));
*dataptr->op_array->refcount = 2;
+ dataptr->destroy_op_array = 0;
}
}
@@ -313,7 +342,7 @@ void phpdbg_free_file_source(zval *zv) {
efree(data->buf);
}
- if (destroy_op_array(data->op_array)) {
+ if (!data->destroy_op_array || destroy_op_array(data->op_array)) {
efree(data->op_array);
}
@@ -325,3 +354,8 @@ void phpdbg_init_list(void) {
zend_hash_init(&PHPDBG_G(file_sources), 1, NULL, (dtor_func_t) phpdbg_free_file_source, 0);
zend_compile_file = phpdbg_compile_file;
}
+
+void phpdbg_list_update(void) {
+ PHPDBG_G(init_compile_file) = zend_compile_file;
+ zend_compile_file = phpdbg_init_compile_file;
+}
diff --git a/sapi/phpdbg/phpdbg_list.h b/sapi/phpdbg/phpdbg_list.h
index bfaef06248..8530ea264d 100644
--- a/sapi/phpdbg/phpdbg_list.h
+++ b/sapi/phpdbg/phpdbg_list.h
@@ -39,6 +39,7 @@ void phpdbg_list_file(zend_string *, uint, int, uint);
extern const phpdbg_command_t phpdbg_list_commands[];
void phpdbg_init_list(void);
+void phpdbg_list_update(void);
typedef struct {
char *filename;
@@ -48,6 +49,7 @@ typedef struct {
void *map;
#endif
zend_op_array *op_array;
+ zend_bool destroy_op_array;
uint lines;
uint line[1];
} phpdbg_file_source;