diff options
| author | Christoph M. Becker <cmb@php.net> | 2015-07-14 10:02:25 +0200 |
|---|---|---|
| committer | Christoph M. Becker <cmb@php.net> | 2015-07-14 10:02:25 +0200 |
| commit | 9f4135ad800a33ab3458ea2cb97abcd33cefe69e (patch) | |
| tree | b097ffad2551d563ff434ee4bb9654e295c60185 /sapi/phpdbg | |
| parent | ae5d04cd6a6965ff47a468964f6db4a4b04acecf (diff) | |
| parent | 50866846c4c7fb94f4fee30ca53459f96eeb5eae (diff) | |
| download | php-git-9f4135ad800a33ab3458ea2cb97abcd33cefe69e.tar.gz | |
Merge branch 'master' of http://git.php.net/repository/php-src
# By Bob Weinand (5) and others
# Via Bob Weinand
* 'master' of http://git.php.net/repository/php-src:
We want to track phpdbg bugs in official bug tracker now; updated URL
Show also runtime-bound functions/classes/methods with phpdbg -p
One less comparison
Fix potential segfault
Closures only have {closure}() as method name Prefixing a class name does not make sense as they may be rebound to another scope, where this will be confusing
Fix __METHOD__ in functions nested into methods
Init variable to NULL before passing to zpp
Format alignment
PHP 7 OCI8: fix bug57702.phpt regression
Diffstat (limited to 'sapi/phpdbg')
| -rw-r--r-- | sapi/phpdbg/phpdbg.c | 2 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg.h | 5 | ||||
| -rw-r--r-- | sapi/phpdbg/phpdbg_print.c | 74 |
3 files changed, 58 insertions, 23 deletions
diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index 85a085b26e..3ee0bde97f 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -447,7 +447,7 @@ static PHP_FUNCTION(phpdbg_end_oplog) phpdbg_oplog_entry *cur = PHPDBG_G(oplog_list)->start; phpdbg_oplog_list *prev = PHPDBG_G(oplog_list)->prev; - HashTable *options; + HashTable *options = NULL; zval *option_buffer; zend_bool by_function = 0; zend_bool by_opcode = 0; diff --git a/sapi/phpdbg/phpdbg.h b/sapi/phpdbg/phpdbg.h index 7fb8083793..f900866211 100644 --- a/sapi/phpdbg/phpdbg.h +++ b/sapi/phpdbg/phpdbg.h @@ -100,9 +100,8 @@ /* {{{ strings */ #define PHPDBG_NAME "phpdbg" #define PHPDBG_AUTHORS "Felipe Pena, Joe Watkins and Bob Weinand" /* Ordered by last name */ -#define PHPDBG_URL "http://phpdbg.com" -#define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues" -#define PHPDBG_VERSION "0.4.0" +#define PHPDBG_ISSUES "http://bugs.php.net/report.php" +#define PHPDBG_VERSION "0.5.0" #define PHPDBG_INIT_FILENAME ".phpdbginit" #define PHPDBG_DEFAULT_PROMPT "prompt>" /* }}} */ diff --git a/sapi/phpdbg/phpdbg_print.c b/sapi/phpdbg/phpdbg_print.c index eff9a406e1..b7bb9e688a 100644 --- a/sapi/phpdbg/phpdbg_print.c +++ b/sapi/phpdbg/phpdbg_print.c @@ -270,23 +270,27 @@ void phpdbg_print_opcodes_function(const char *function, size_t len) { zend_function *func = zend_hash_str_find_ptr(EG(function_table), function, len); if (!func) { + zend_string *rt_name; + ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), rt_name, func) { + if (func->type == ZEND_USER_FUNCTION && *rt_name->val == '\0') { + if (func->op_array.function_name->len == len && !zend_binary_strcasecmp(function, len, func->op_array.function_name->val, func->op_array.function_name->len)) { + phpdbg_print_opcodes_function(rt_name->val, rt_name->len); + } + } + } ZEND_HASH_FOREACH_END(); + return; } - phpdbg_out("function name: %.*s\n", (int) len, function); + phpdbg_out("function name: %.*s\n", ZSTR_LEN(func->op_array.function_name), ZSTR_VAL(func->op_array.function_name)); phpdbg_print_function_helper(func); } -void phpdbg_print_opcodes_method(const char *class, const char *function) { - zend_class_entry *ce; +static void phpdbg_print_opcodes_method_ce(zend_class_entry *ce, const char *function) { zend_function *func; - if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) { - return; - } - if (ce->type != ZEND_USER_CLASS) { - phpdbg_out("function name: %s::%s (internal)\n", class, function); + phpdbg_out("function name: %s::%s (internal)\n", ce->name->val, function); return; } @@ -294,20 +298,34 @@ void phpdbg_print_opcodes_method(const char *class, const char *function) { return; } - phpdbg_out("function name: %s::%s\n", class, function); + phpdbg_out("function name: %s::%s\n", ce->name->val, function); phpdbg_print_function_helper(func); } -void phpdbg_print_opcodes_class(const char *class) { +void phpdbg_print_opcodes_method(const char *class, const char *function) { zend_class_entry *ce; - zend_function *method; - zend_string *method_name; - zend_bool first = 1; if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) { + zend_string *rt_name; + ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), rt_name, ce) { + if (ce->type == ZEND_USER_CLASS && *rt_name->val == '\0') { + if (ce->name->len == strlen(class) && !zend_binary_strcasecmp(class, strlen(class), ce->name->val, ce->name->len)) { + phpdbg_print_opcodes_method_ce(ce, function); + } + } + } ZEND_HASH_FOREACH_END(); + return; } + phpdbg_print_opcodes_method_ce(ce, function); +} + +static void phpdbg_print_opcodes_ce(zend_class_entry *ce) { + zend_function *method; + zend_string *method_name; + zend_bool first = 1; + phpdbg_out("%s %s: %s\n", (ce->type == ZEND_USER_CLASS) ? "user" : "internal", @@ -342,10 +360,28 @@ void phpdbg_print_opcodes_class(const char *class) { } ZEND_HASH_FOREACH_END(); } +void phpdbg_print_opcodes_class(const char *class) { + zend_class_entry *ce; + + if (phpdbg_safe_class_lookup(class, strlen(class), &ce) != SUCCESS) { + zend_string *rt_name; + ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), rt_name, ce) { + if (ce->type == ZEND_USER_CLASS && *rt_name->val == '\0') { + if (ce->name->len == strlen(class) && !zend_binary_strcasecmp(class, strlen(class), ce->name->val, ce->name->len)) { + phpdbg_print_opcodes_ce(ce); + } + } + } ZEND_HASH_FOREACH_END(); + + return; + } + + phpdbg_print_opcodes_ce(ce); +} + PHPDBG_API void phpdbg_print_opcodes(char *function) { - char *method_name; - strtok(function, ":"); + char *method_name = strtok(function, ":"); if (function == NULL) { phpdbg_print_opcodes_main(); @@ -364,15 +400,15 @@ PHPDBG_API void phpdbg_print_opcodes(char *function) } } ZEND_HASH_FOREACH_END(); - ZEND_HASH_FOREACH_STR_KEY_PTR(EG(class_table), name, ce) { + ZEND_HASH_FOREACH_PTR(EG(class_table), ce) { if (ce->type == ZEND_USER_CLASS) { phpdbg_out("\n\n"); - phpdbg_print_opcodes_class(ZSTR_VAL(name)); + phpdbg_print_opcodes_ce(ce); } } ZEND_HASH_FOREACH_END(); - } else if ((method_name = strtok(NULL, ":")) == NULL) { + } else if (method_name == NULL) { phpdbg_print_opcodes_function(function, strlen(function)); - } else if ((method_name + 1) == NULL) { + } else if ((method_name = strtok(NULL, ":")) == NULL) { phpdbg_print_opcodes_class(function); } else { phpdbg_print_opcodes_method(function, method_name); |
