diff options
author | Anatol Belski <ab@php.net> | 2015-07-21 12:27:50 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2015-07-21 12:27:50 +0200 |
commit | b148ef44965651fcbe93e8ee35a14edc087ef17c (patch) | |
tree | f5c53fb3d448d0174610d077e0bf3c8bd76834b2 /sapi/phpdbg/phpdbg_bp.c | |
parent | ad8a73dd55c087de465ad80e8715611693bb1460 (diff) | |
parent | 6065b29fe41f09e01dd06ba21980e0344f13230c (diff) | |
download | php-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_bp.c')
-rw-r--r-- | sapi/phpdbg/phpdbg_bp.c | 85 |
1 files changed, 57 insertions, 28 deletions
diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c index 1c06646f0e..60c68e2cc3 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -285,7 +285,7 @@ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num) /* { phpdbg_debug("Compare against loaded %s\n", file); if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(ZSTR_VAL(file), ZSTR_LEN(file), path_str, broken)) == NULL))) { - new_break = *(phpdbg_breakfile_t *) zend_hash_index_find_ptr(broken, line_num); + new_break = *(phpdbg_breakfile_t *) zend_hash_index_find_ptr(fileht, line_num); break; } } ZEND_HASH_FOREACH_END(); @@ -310,7 +310,13 @@ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uin { phpdbg_debug("file: %s, filelen: %u, cur: %s, curlen %u, pos: %c, memcmp: %d\n", file, filelen, ZSTR_VAL(cur), ZSTR_LEN(cur), filelen > ZSTR_LEN(cur) ? file[filelen - ZSTR_LEN(cur) - 1] : '?', filelen > ZSTR_LEN(cur) ? memcmp(file + filelen - ZSTR_LEN(cur), ZSTR_VAL(cur), ZSTR_LEN(cur)) : 0); - if (((ZSTR_LEN(cur) < filelen && file[filelen - ZSTR_LEN(cur) - 1] == '/') || filelen == ZSTR_LEN(cur)) && !memcmp(file + filelen - ZSTR_LEN(cur), ZSTR_VAL(cur), ZSTR_LEN(cur))) { +#ifdef _WIN32 +# define WIN32_PATH_CHECK file[filelen - ZSTR_LEN(cur) - 1] == '\\' +#else +# define WIN32_PATH_CHECK 0 +#endif + + if (((ZSTR_LEN(cur) < filelen && (file[filelen - ZSTR_LEN(cur) - 1] == '/' || WIN32_PATH_CHECK)) || filelen == ZSTR_LEN(cur)) && !memcmp(file + filelen - ZSTR_LEN(cur), ZSTR_VAL(cur), ZSTR_LEN(cur))) { phpdbg_breakfile_t *brake, new_brake; HashTable *master; @@ -327,8 +333,7 @@ PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uin new_brake.filename = estrndup(file, filelen); PHPDBG_BREAK_UNMAPPING(brake->id); - if (master) { - zend_hash_index_update_mem(master, brake->line, &new_brake, sizeof(phpdbg_breakfile_t)); + if (zend_hash_index_add_mem(master, brake->line, &new_brake, sizeof(phpdbg_breakfile_t))) { PHPDBG_BREAK_MAPPING(brake->id, master); } } ZEND_HASH_FOREACH_END(); @@ -364,6 +369,15 @@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file) /* {{{ */ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len) /* {{{ */ { + char *lcname; + + if (*name == '\\') { + name++; + name_len--; + } + + lcname = zend_str_tolower_dup(name, name_len); + if (!zend_hash_str_exists(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], name, name_len)) { phpdbg_breaksymbol_t new_break; @@ -372,7 +386,7 @@ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len) PHPDBG_BREAK_INIT(new_break, PHPDBG_BREAK_SYM); new_break.symbol = estrndup(name, name_len); - zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], new_break.symbol, name_len, &new_break, sizeof(phpdbg_breaksymbol_t)); + zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], lcname, name_len, &new_break, sizeof(phpdbg_breaksymbol_t)); phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" function=\"%s\"", "Breakpoint #%d added at %s", new_break.id, new_break.symbol); @@ -380,6 +394,8 @@ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len) } else { phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" function=\"%s\"", "Breakpoint exists at %s", name); } + + efree(lcname); } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char *func_name) /* {{{ */ @@ -387,14 +403,22 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char HashTable class_breaks, *class_table; size_t class_len = strlen(class_name); size_t func_len = strlen(func_name); - char *lcname = zend_str_tolower_dup(func_name, func_len); + char *func_lcname, *class_lcname; - if (!(class_table = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, class_len))) { + if (*class_name == '\\') { + class_name++; + class_len--; + } + + func_lcname = zend_str_tolower_dup(func_name, func_len); + class_lcname = zend_str_tolower_dup(class_name, class_len); + + if (!(class_table = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_lcname, class_len))) { zend_hash_init(&class_breaks, 8, NULL, phpdbg_class_breaks_dtor, 0); - class_table = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_name, class_len, &class_breaks, sizeof(HashTable)); + class_table = zend_hash_str_update_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_lcname, class_len, &class_breaks, sizeof(HashTable)); } - if (!zend_hash_str_exists(class_table, lcname, func_len)) { + if (!zend_hash_str_exists(class_table, func_lcname, func_len)) { phpdbg_breakmethod_t new_break; PHPDBG_G(flags) |= PHPDBG_HAS_METHOD_BP; @@ -405,7 +429,7 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char new_break.func_name = estrndup(func_name, func_len); new_break.func_len = func_len; - zend_hash_str_update_mem(class_table, lcname, func_len, &new_break, sizeof(phpdbg_breakmethod_t)); + zend_hash_str_update_mem(class_table, func_lcname, func_len, &new_break, sizeof(phpdbg_breakmethod_t)); phpdbg_notice("breakpoint", "add=\"success\" id=\"%d\" method=\"%s::%s\"", "Breakpoint #%d added at %s::%s", new_break.id, class_name, func_name); @@ -414,7 +438,8 @@ PHPDBG_API void phpdbg_set_breakpoint_method(const char *class_name, const char phpdbg_error("breakpoint", "type=\"exists\" add=\"fail\" method=\"%s::%s\"", "Breakpoint exists at %s::%s", class_name, func_name); } - efree(lcname); + efree(func_lcname); + efree(class_lcname); } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_opline(zend_ulong opline) /* {{{ */ @@ -573,6 +598,8 @@ PHPDBG_API int phpdbg_resolve_opline_break(phpdbg_breakopline_t *new_break) /* { return SUCCESS; } /* }}} */ +/* TODO ... method/function oplines need to be normalized (leading backslash, lowercase) and file oplines need to be resolved properly */ + PHPDBG_API void phpdbg_set_breakpoint_method_opline(const char *class, const char *method, zend_ulong opline) /* {{{ */ { phpdbg_breakopline_t new_break; @@ -873,8 +900,6 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_file(zend_op_array *op_ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function *fbc) /* {{{ */ { - const char *fname; - size_t flen; zend_op_array *ops; if (fbc->type != ZEND_USER_FUNCTION) { @@ -889,30 +914,33 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_symbol(zend_function *f } if (ops->function_name) { - fname = ZSTR_VAL(ops->function_name); - flen = ZSTR_LEN(ops->function_name); + phpdbg_breakbase_t *brake; + zend_string *fname = zend_string_tolower(ops->function_name); + + brake = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname); + + zend_string_release(fname); + return brake; } else { - fname = "main"; - flen = 4; + return zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], ZEND_STRL("main")); } - - return zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM], fname, flen); } /* }}} */ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_method(zend_op_array *ops) /* {{{ */ { HashTable *class_table; phpdbg_breakbase_t *brake = NULL; + zend_string *class_lcname = zend_string_tolower(ops->scope->name); - if ((class_table = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], ops->scope->name))) { - size_t lcname_len = ZSTR_LEN(ops->function_name); - char *lcname = zend_str_tolower_dup(ZSTR_VAL(ops->function_name), lcname_len); + if ((class_table = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD], class_lcname))) { + zend_string *lcname = zend_string_tolower(ops->function_name); - brake = zend_hash_str_find_ptr(class_table, lcname, lcname_len); + brake = zend_hash_find_ptr(class_table, lcname); - efree(lcname); + zend_string_release(lcname); } + zend_string_release(class_lcname); return brake; } /* }}} */ @@ -929,9 +957,9 @@ static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opline(phpdbg_opline_pt static inline phpdbg_breakbase_t *phpdbg_find_breakpoint_opcode(zend_uchar opcode) /* {{{ */ { - const char *opname = phpdbg_decode_opcode(opcode); + const char *opname = zend_get_opcode_name(opcode); - if (memcmp(opname, PHPDBG_STRL("UNKNOWN")) == 0) { + if (!opname) { return NULL; } @@ -1081,8 +1109,9 @@ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakpoint(zend_execute_data *execute } if (PHPDBG_G(flags) & (PHPDBG_HAS_METHOD_BP|PHPDBG_HAS_SYM_BP)) { - /* check we are at the beginning of the stack */ - if (execute_data->opline == execute_data->func->op_array.opcodes) { + zend_op_array *op_array = &execute_data->func->op_array; + /* check we are at the beginning of the stack, but after argument RECV */ + if (execute_data->opline == op_array->opcodes + op_array->num_args + !!(op_array->fn_flags & ZEND_ACC_VARIADIC)) { if ((base = phpdbg_find_breakpoint_symbol(execute_data->func))) { goto result; } |