From: krakjoe Date: Wed, 13 Nov 2013 00:36:47 +0000 (+0000) Subject: fix bug in passing correct expression length X-Git-Tag: php-5.6.0alpha1~110^2~404 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43c2748dced2a77b34c09c15e403c6970b74e2b2;p=php fix bug in passing correct expression length add class printer (half done) --- diff --git a/phpdbg_print.c b/phpdbg_print.c index 37daf028b3..c0d8fb4dcd 100644 --- a/phpdbg_print.c +++ b/phpdbg_print.c @@ -34,3 +34,20 @@ PHPDBG_PRINT(opline) /* {{{ */ return SUCCESS; } /* }}} */ + +PHPDBG_PRINT(class) /* {{{ */ +{ + zend_class_entry **ce; + + if (expr && expr_len > 0L) { + if (zend_lookup_class(expr, strlen(expr), &ce TSRMLS_CC) == SUCCESS) { + + } else { + phpdbg_error("Cannot find class %s/%lu", expr, expr_len); + } + } else { + phpdbg_error("No class name provided!"); + } + + return SUCCESS; +} /* }}} */ diff --git a/phpdbg_print.h b/phpdbg_print.h index ae8453bd0f..2358f0bab4 100644 --- a/phpdbg_print.h +++ b/phpdbg_print.h @@ -35,12 +35,14 @@ * Printer Forward Declarations */ PHPDBG_PRINT(opline); +PHPDBG_PRINT(class); /** * Commands */ static const phpdbg_command_t phpdbg_print_commands[] = { PHPDBG_PRINT_D(opline, "print the current opline information"), + PHPDBG_PRINT_D(class, "print out the instructions in the specified class"), {NULL, 0, 0} }; diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c index f221b581ea..f7cba8cd75 100644 --- a/phpdbg_prompt.c +++ b/phpdbg_prompt.c @@ -513,21 +513,24 @@ static const phpdbg_command_t phpdbg_prompt_commands[] = { int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_len TSRMLS_DC) /* {{{ */ { - char *params = NULL; + char *expr = NULL; #ifndef _WIN32 - const char *cmd = strtok_r(cmd_line, " ", ¶ms); + const char *cmd = strtok_r(cmd_line, " ", &expr); #else - const char *cmd = strtok_s(cmd_line, " ", ¶ms); + const char *cmd = strtok_s(cmd_line, " ", &expr); #endif - size_t expr_len = cmd != NULL ? strlen(cmd) : 0; - + size_t expr_len = (cmd != NULL) ? strlen(cmd) : 0; + while (command && command->name) { if (command->name_len == expr_len && memcmp(cmd, command->name, expr_len) == 0) { + PHPDBG_G(last) = (phpdbg_command_t*) command; - PHPDBG_G(last_params) = params; - PHPDBG_G(last_params_len) = cmd_len - expr_len; - return command->handler(params, cmd_len - expr_len TSRMLS_CC); + PHPDBG_G(last_params) = expr; + PHPDBG_G(last_params_len) = ((cmd_len - expr_len) - sizeof(" "))+1; + + return command->handler( + PHPDBG_G(last_params), PHPDBG_G(last_params_len) TSRMLS_CC); } ++command; } diff --git a/phpdbg_utils.c b/phpdbg_utils.c index 4031b2d209..27ada70ef7 100644 --- a/phpdbg_utils.c +++ b/phpdbg_utils.c @@ -119,3 +119,19 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */ efree(buffer); } } /* }}} */ + +char *phpdbg_trim(const char *expr, size_t *expr_len) /* {{{ */ +{ + char *pointer = expr; + + while (*pointer && isspace(*pointer)) { + pointer++; + (*expr_len)--; + } + + while (expr_len > 0L && isspace(pointer[(*expr_len)-1])) { + pointer[--(*expr_len)]='\0'; + } + + return pointer; +} /* }}} */ diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 7682201493..278019fd1a 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -28,6 +28,12 @@ int phpdbg_is_empty(const char*); int phpdbg_is_addr(const char*); int phpdbg_is_class_method(const char*, size_t, char**, char**); +/** + * Input trim function + * NOTE: efree all the things + */ +char *phpdbg_trim(const char*, size_t*); + /** * Error/notice/formatting helper */