com php-src: fix bug in passing correct expression length add class printer (half done): phpdbg_print.c phpdbg_print.h phpdbg _prompt.c phpdbg_utils.c
phpdbg_utils.h
| From: | Bob Weinand | Date: | Wed, 13 Nov 2013 00:36:47 +0000 |
| Subject: | com php-src: fix bug in passing correct expression length add class printer (half done): phpdbg_print.c phpdbg_print.h phpdbg _prompt.c phpdbg_utils.c phpdbg_utils.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75042@lists.php.net to get a copy of this message | ||
Commit: 43c2748dced2a77b34c09c15e403c6970b74e2b2
Author: krakjoe <joe.watkins@live.co.uk> Wed, 13 Nov 2013 00:36:47 +0000
Parents: 52040263083b1ab748d850d0a614b8b8bd62ffc4
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=43c2748dced2a77b34c09c15e403c6970b74e2b2
Log:
fix bug in passing correct expression length
add class printer (half done)
Changed paths:
M phpdbg_print.c
M phpdbg_print.h
M phpdbg_prompt.c
M phpdbg_utils.c
M phpdbg_utils.h
Diff:
diff --git a/phpdbg_print.c b/phpdbg_print.c
index 37daf02..c0d8fb4 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 ae8453b..2358f0b 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 f221b58..f7cba8c 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 4031b2d..27ada70 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 7682201..278019f 100644
--- a/phpdbg_utils.h
+++ b/phpdbg_utils.h
@@ -29,6 +29,12 @@ 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
*/
enum {