com php-src: Merge remote-tracking branch 'origin/PHP-5.6': sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_bp.c sapi/phpdbg/ phpdbg_bp.h
sapi/phpdbg/phpdbg_out.c sapi/phpdbg/ph pdbg_prompt.c

From: Date: Tue, 28 Oct 2014 16:40:27 +0000
Subject: com php-src: Merge remote-tracking branch 'origin/PHP-5.6': sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_bp.c sapi/phpdbg/ phpdbg_bp.h
sapi/phpdbg/phpdbg_out.c sapi/phpdbg/ph pdbg_prompt.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82759@lists.php.net to get a copy of this message
Commit: ec533514473d480b2619ee0f81e49f8a7683bdf2 Author: Bob Weinand <bobwei9@hotmail.com> Tue, 28 Oct 2014 17:40:27 +0100 Parents: efe9cc3a86a769f1ac3d16f4b12f5e83053c6822 297baa0c18d8d04de7a683a51b9f069c84a855f3 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ec533514473d480b2619ee0f81e49f8a7683bdf2 Log: Merge remote-tracking branch 'origin/PHP-5.6' Conflicts: configure.in main/php_version.h sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_bp.c sapi/phpdbg/phpdbg_prompt.c Changed paths: MM sapi/phpdbg/phpdbg.c MM sapi/phpdbg/phpdbg_bp.c MM sapi/phpdbg/phpdbg_bp.h MM sapi/phpdbg/phpdbg_out.c MM sapi/phpdbg/phpdbg_prompt..c

diff --cc sapi/phpdbg/phpdbg.c index 43881a3,5ebc203..6e7e4ec --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@@ -1516,21 -1502,7 +1489,11 @@@ phpdbg_main PHPDBG_G(flags) |= PHPDBG_IS_STEPPING; } - if (phpdbg_startup_run) { - zend_try { - PHPDBG_COMMAND_HANDLER(run)(NULL TSRMLS_CC); - } zend_end_try(); - if (phpdbg_startup_run > 1) { - /* if -r is on the command line more than once just quit */ - goto phpdbg_out; - } - phpdbg_startup_run = 0; - } - +/* #ifndef for making compiler shutting up */ +#ifndef _WIN32 phpdbg_interact: +#endif ++ /* phpdbg main() */ do { zend_try { diff --cc sapi/phpdbg/phpdbg_bp.c index 4402404,33824d4..311171f --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@@ -104,22 -111,39 +104,33 @@@ PHPDBG_API void phpdbg_reset_breakpoint PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ { + char *string; + phpdbg_export_breakpoints_to_string(&string TSRMLS_CC); + fputs(string, handle); + } + + PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC) /* {{{ */ + { - HashPosition position[2]; - HashTable **table = NULL; + HashTable *table; zend_ulong id = 0L; + *str = ""; + if (zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])) { phpdbg_notice("exportbreakpoint", "count=\"%d\"", "Exporting %d breakpoints", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP])); + /* this only looks like magic, it isn't */ - for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0]); - zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], (void **) &table, &position[0]) == SUCCESS; - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], &position[0])) { + ZEND_HASH_FOREACH_NUM_KEY_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], id, table) { phpdbg_breakbase_t *brake; - zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_MAP], NULL, NULL, &id, 0, &position[0]); - - for (zend_hash_internal_pointer_reset_ex((*table), &position[1]); - zend_hash_get_current_data_ex((*table), (void**)&brake, &position[1]) == SUCCESS; - zend_hash_move_forward_ex((*table), &position[1])) { + ZEND_HASH_FOREACH_PTR(table, brake) { if (brake->id == id) { + char *new_str = NULL; + switch (brake->type) { case PHPDBG_BREAK_FILE: { - fprintf(handle, - "break %s:%lu\n", + phpdbg_asprintf(&new_str, + "%sbreak %s:%lu\n", *str, ((phpdbg_breakfile_t*)brake)->filename, ((phpdbg_breakfile_t*)brake)->line); } break; @@@ -138,23 -162,23 +149,23 @@@ } break; case PHPDBG_BREAK_METHOD_OPLINE: { - fprintf(handle, - "break %s::%s#%llu\n", + phpdbg_asprintf(&new_str, - "%sbreak %s::%s#%ld\n", *str, ++ "%sbreak %s::%s#%llu\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FUNCTION_OPLINE: { - fprintf(handle, - "break %s#%llu\n", + phpdbg_asprintf(&new_str, - "%sbreak %s#%ld\n", *str, ++ "%sbreak %s#%llu\n", *str, ((phpdbg_breakopline_t*)brake)->func_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; case PHPDBG_BREAK_FILE_OPLINE: { - fprintf(handle, - "break %s:#%llu\n", + phpdbg_asprintf(&new_str, - "%sbreak %s:#%ld\n", *str, ++ "%sbreak %s:#%llu\n", *str, ((phpdbg_breakopline_t*)brake)->class_name, ((phpdbg_breakopline_t*)brake)->opline_num); } break; @@@ -197,10 -220,19 +207,19 @@@ } } break; } + + if ((*str)[0]) { + efree(*str); + } + *str = new_str; } - } - } + } ZEND_HASH_FOREACH_END(); + } ZEND_HASH_FOREACH_END(); } + + if (!(*str)[0]) { + *str = NULL; + } } /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ @@@ -219,7 -251,9 +238,9 @@@ } path_len = strlen(path); + phpdbg_debug("file path: %s, resolved path: %s, was compiled: %d\n", original_path, path, zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)); + - if (!zend_hash_exists(&PHPDBG_G(file_sources), path, path_len)) { + if (!zend_hash_str_exists(&PHPDBG_G(file_sources), path, path_len)) { if (php_stream_stat_path(path, &ssb) == FAILURE) { if (original_path[0] == '/') { phpdbg_error("breakpoint", "type=\"nofile\" add=\"fail\" file=\"%s\"", "Cannot stat %s, it does not exist", original_path); @@@ -253,14 -293,20 +276,18 @@@ PHPDBG_BREAK_MAPPING(new_break.id, broken); if (pending) { - for (zend_hash_internal_pointer_reset_ex(&PHPDBG_G(file_sources), &position); - zend_hash_get_current_key_ex(&PHPDBG_G(file_sources), &file, &filelen, NULL, 0, &position) == HASH_KEY_IS_STRING; - zend_hash_move_forward_ex(&PHPDBG_G(file_sources), &position)) { + zend_string *file, *path_str = zend_string_init(path, path_len, 0); + ZEND_HASH_FOREACH_STR_KEY(&PHPDBG_G(file_sources), file) { - if (!(pending = ((broken = phpdbg_resolve_pending_file_break_ex(file->val, file->len, path_str, broken TSRMLS_CC)) == NULL))) { + HashTable *fileht; + + phpdbg_debug("Compare against loaded %s\n", file); + - if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(file, filelen, path, path_len, broken TSRMLS_CC)) == NULL))) { - phpdbg_breakfile_t *brake; - zend_hash_index_find(fileht, line_num, (void **) &brake); - new_break = *brake; ++ if (!(pending = ((fileht = phpdbg_resolve_pending_file_break_ex(file->val, file->len, path_str, broken TSRMLS_CC)) == NULL))) { + new_break = *(phpdbg_breakfile_t *) zend_hash_index_find_ptr(broken, line_num); break; } - } + } ZEND_HASH_FOREACH_END(); + zend_string_release(path_str); } if (pending) { @@@ -277,42 -323,38 +304,35 @@@ } } /* }}} */ -PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, const char *cur, uint curlen, HashTable *fileht TSRMLS_DC) /* {{{ */ +PHPDBG_API HashTable *phpdbg_resolve_pending_file_break_ex(const char *file, uint filelen, zend_string *cur, HashTable *fileht TSRMLS_DC) /* {{{ */ { - if (cur->len < filelen && file[filelen - cur->len - 1] == '/' && !memcmp(file + filelen - cur->len, cur->val, cur->len)) { + phpdbg_debug("file: %s, filelen: %u, cur: %s, curlen %u, pos: %c, memcmp: %d\n", file, filelen, cur, curlen, filelen > curlen ? file[filelen - curlen - 1] : '?', filelen > curlen ? memcmp(file + filelen - curlen, cur, curlen) : 0); + - if (((curlen < filelen && file[filelen - curlen - 1] == '/') || filelen == curlen) && !memcmp(file + filelen - curlen, cur, curlen)) { ++ if (((cur->len < filelen && file[filelen - cur->len - 1] == '/') || filelen == cur->len) && !memcmp(file + filelen - cur->len, cur->val, cur->len)) { phpdbg_breakfile_t *brake, new_brake; -- HashTable *master = NULL; - dtor_func_t dtor; - HashPosition position; ++ HashTable *master; PHPDBG_G(flags) |= PHPDBG_HAS_FILE_BP; - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, (void **) &master) == FAILURE) { + if (!(master = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen))) { - dtor = PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor; - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = NULL; - fileht = zend_hash_str_add_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, fileht, sizeof(HashTable)); + HashTable new_ht; + zend_hash_init(&new_ht, 8, NULL, phpdbg_file_breaks_dtor, 0); - zend_hash_add(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, &new_ht, sizeof(HashTable), (void **) &master); ++ master = zend_hash_str_add_mem(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], file, filelen, &new_ht, sizeof(HashTable)); } - for (zend_hash_internal_pointer_reset_ex(fileht, &position); - zend_hash_get_current_data_ex(fileht, (void**)&brake, &position) == SUCCESS; - zend_hash_move_forward_ex(fileht, &position)) { + ZEND_HASH_FOREACH_PTR(fileht, brake) { new_brake = *brake; new_brake.filename = estrndup(file, filelen); PHPDBG_BREAK_UNMAPPING(brake->id); if (master) { - zend_hash_index_update(master, brake->line, (void **) &new_brake, sizeof(phpdbg_breakfile_t), NULL); + zend_hash_index_update_mem(master, brake->line, &new_brake, sizeof(phpdbg_breakfile_t)); PHPDBG_BREAK_MAPPING(brake->id, master); - } else { - efree((char *) brake->filename); - *brake = new_brake; - PHPDBG_BREAK_MAPPING(brake->id, fileht); } - } + } ZEND_HASH_FOREACH_END(); - zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, curlen); + zend_hash_del(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur); - if (!master) { - PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING].pDestructor = dtor; - } - if (!zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING])) { PHPDBG_G(flags) &= ~PHPDBG_HAS_PENDING_FILE_BP; } @@@ -325,14 -369,25 +347,18 @@@ PHPDBG_API void phpdbg_resolve_pending_file_break(const char *file TSRMLS_DC) /* {{{ */ { - HashPosition position; HashTable *fileht; uint filelen = strlen(file); + zend_string *cur; + phpdbg_debug("was compiled: %s\n", file); + - zend_hash_internal_pointer_reset_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); - while (zend_hash_get_current_data_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (void**) &fileht, &position) == SUCCESS) { - const char *cur; - uint curlen; - - zend_hash_get_current_key_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], (char **) &cur, &curlen, NULL, 0, &position); - zend_hash_move_forward_ex(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], &position); - + ZEND_HASH_FOREACH_STR_KEY_PTR(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE_PENDING], cur, fileht) { + phpdbg_debug("check bp: %s\n", cur); + - phpdbg_resolve_pending_file_break_ex(file, filelen, cur, curlen, fileht TSRMLS_CC); - } -} + phpdbg_resolve_pending_file_break_ex(file, filelen, cur, fileht TSRMLS_CC); + } ZEND_HASH_FOREACH_END(); +} /* }}} */ PHPDBG_API void phpdbg_set_breakpoint_symbol(const char *name, size_t name_len TSRMLS_DC) /* {{{ */ { @@@ -815,8 -903,21 +841,21 @@@ static inline phpdbg_breakbase_t *phpdb { HashTable *breaks; phpdbg_breakbase_t *brake; + size_t path_len; + char realpath[MAXPATHLEN]; - const char *path = op_array->filename; ++ const char *path = op_array->filename->val; + + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + + path_len = strlen(path); + + #if 0 + phpdbg_debug("Op at: %.*s %d\n", path_len, path, (*EG(opline_ptr))->lineno); + #endif - if (!(breaks = zend_hash_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], op_array->filename))) { - if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&breaks) == FAILURE) { ++ if (!(breaks = zend_hash_str_find_ptr(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len))) { return NULL; } diff --cc sapi/phpdbg/phpdbg_bp.h index 83c8bbc,63a9961..99c4eb6 --- a/sapi/phpdbg/phpdbg_bp.h +++ b/sapi/phpdbg/phpdbg_bp.h @@@ -154,9 -154,10 +154,10 @@@ PHPDBG_API void phpdbg_disable_breakpoi /* {{{ Breakbase API */ PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase(zend_ulong id TSRMLS_DC); -PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable ***table, HashPosition *position TSRMLS_DC); /* }}} */ +PHPDBG_API phpdbg_breakbase_t *phpdbg_find_breakbase_ex(zend_ulong id, HashTable **table, zend_ulong *numkey, zend_string **strkey TSRMLS_DC); /* }}} */ /* {{{ Breakpoint Exportation API */ - PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); /* }}} */ + PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC); + PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str TSRMLS_DC); /* }}} */ #endif /* PHPDBG_BP_H */ diff --cc sapi/phpdbg/phpdbg_prompt.c index 16807c6,c1fcb59..60c9a2e --- a/sapi/phpdbg/phpdbg_prompt.c +++ b/sapi/phpdbg/phpdbg_prompt.c @@@ -634,10 -702,14 +664,10 @@@ PHPDBG_COMMAND(run) /* {{{ * if (EG(exception)) { phpdbg_handle_exception(TSRMLS_C); } -- - phpdbg_clean(1 TSRMLS_CC); - EG(active_op_array) = orig_op_array; - EG(opline_ptr) = orig_opline; - EG(return_value_ptr_ptr) = orig_retval_ptr; } + phpdbg_clean(1 TSRMLS_CC); + PHPDBG_G(flags) &= ~PHPDBG_IS_RUNNING; } else { phpdbg_error("inactive", "type=\"nocontext\"", "Nothing to execute!");
« previous php.cvs (#82759) next »