Browse Source

Fix op_arrays with opcache

pull/1126/merge
Bob Weinand 11 years ago
parent
commit
b4c595dd82
  1. 2
      sapi/phpdbg/phpdbg.c
  2. 1
      sapi/phpdbg/phpdbg.h
  3. 42
      sapi/phpdbg/phpdbg_list.c
  4. 2
      sapi/phpdbg/phpdbg_list.h

2
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);

1
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 */

42
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;
}

2
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;

Loading…
Cancel
Save