com php-src: method printer: phpdbg_print.c phpdbg_prin t.h phpdbg_prompt.c phpdbg_utils.c phpdbg_uti ls.h
| From: | Bob Weinand | Date: | Wed, 13 Nov 2013 05:36:01 +0000 |
| Subject: | com php-src: method printer: phpdbg_print.c phpdbg_prin t.h phpdbg_prompt.c phpdbg_utils.c phpdbg_uti ls.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75033@lists.php.net to get a copy of this message | ||
Commit: 99bbc8e8118804367cf4a77f0c9b66118135229f
Author: krakjoe <joe.watkins@live.co.uk> Wed, 13 Nov 2013 05:36:01 +0000
Parents: 88ad7f92791f7578656b3a9e0de5a78e7dd66e86
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=99bbc8e8118804367cf4a77f0c9b66118135229f
Log:
method printer
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 8b2f520..6ef3d4c 100644
--- a/phpdbg_print.c
+++ b/phpdbg_print.c
@@ -124,6 +124,41 @@ PHPDBG_PRINT(class) /* {{{ */
return SUCCESS;
} /* }}} */
+PHPDBG_PRINT(method) /* {{{ */
+{
+ if (expr && expr_len > 0L) {
+ char *class_name = NULL;
+ char *func_name = NULL;
+
+ if (phpdbg_is_class_method(expr, expr_len, &class_name, &func_name)) {
+ zend_class_entry **ce;
+
+ if (zend_lookup_class(class_name, strlen(class_name), &ce TSRMLS_CC) == SUCCESS) {
+ zend_function *fbc;
+
+ if (zend_hash_find(&(*ce)->function_table, func_name, strlen(func_name),
(void**)&fbc) == SUCCESS) {
+ phpdbg_notice(
+ "%s Method %s",
+ (fbc->type == ZEND_USER_FUNCTION) ? "User" :
"Internal",
+ fbc->common.function_name);
+
+ phpdbg_print_function_helper(fbc TSRMLS_CC);
+ } else {
+ phpdbg_error("The method %s could not be found", func_name);
+ }
+ }
+
+ efree(class_name);
+ efree(func_name);
+ } else {
+ phpdbg_error("The expression provided is not a valid method %s", expr);
+ }
+ } else {
+ phpdbg_error("No expression provided");
+ }
+ return SUCCESS;
+} /* }}} */
+
PHPDBG_PRINT(func) /* {{{ */
{
if (expr && expr_len > 0L) {
@@ -152,8 +187,9 @@ PHPDBG_PRINT(func) /* {{{ */
if (zend_hash_find(func_table, func_name, func_name_len+1, (void**)&fbc) == SUCCESS) {
phpdbg_notice(
- "%s Function %s",
+ "%s %s %s",
(fbc->type == ZEND_USER_FUNCTION) ? "User" : "Internal",
+ (fbc->common.scope) ? "Method" : "Function",
fbc->common.function_name);
phpdbg_print_function_helper(fbc TSRMLS_CC);
diff --git a/phpdbg_print.h b/phpdbg_print.h
index 0af042b..d906ab0 100644
--- a/phpdbg_print..h
+++ b/phpdbg_print.h
@@ -36,6 +36,7 @@
*/
PHPDBG_PRINT(opline);
PHPDBG_PRINT(class);
+PHPDBG_PRINT(method);
PHPDBG_PRINT(func);
/**
@@ -44,8 +45,9 @@ PHPDBG_PRINT(func);
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"),
+ PHPDBG_PRINT_D(method, "print out the instructions in the specified method"),
PHPDBG_PRINT_D(func, "print out the instructions in the specified function"),
- {NULL, 0, 0}
+ {0, 0, 0, 0}
};
#endif /* PHPDBG_PRINT_H */
diff --git a/phpdbg_prompt.c b/phpdbg_prompt.c
index f9b1bf5..60982a9 100644
--- a/phpdbg_prompt.c
+++ b/phpdbg_prompt.c
@@ -208,7 +208,8 @@ static PHPDBG_COMMAND(back) /* {{{ */
static PHPDBG_COMMAND(print) /* {{{ */
{
if (expr && expr_len > 0L) {
- if (phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) {
+ if (phpdbg_print_commands &&
+ phpdbg_do_cmd(phpdbg_print_commands, (char*)expr, expr_len TSRMLS_CC) == FAILURE) {
phpdbg_error("Failed to find print command %s", expr);
}
return SUCCESS;
@@ -521,7 +522,7 @@ int phpdbg_do_cmd(const phpdbg_command_t *command, char *cmd_line, size_t cmd_le
#endif
size_t expr_len = (cmd != NULL) ? strlen(cmd) : 0;
- while (command && command->name) {
+ while (command && command->name && command->handler) {
if (command->name_len == expr_len
&& memcmp(cmd, command->name, expr_len) == 0) {
@@ -546,20 +547,19 @@ int phpdbg_interactive(TSRMLS_D) /* {{{ */
#ifndef HAVE_LIBREADLINE
char cmd[PHPDBG_MAX_CMD];
-phpdbg_interactive_enter:
- phpdbg_write(PROMPT);
-
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING) &&
- fgets(cmd, PHPDBG_MAX_CMD, stdin) != NULL) {
+ phpdbg_write(PROMPT) &&
+ (fgets(cmd, PHPDBG_MAX_CMD, stdin) != NULL)) {
cmd_len = strlen(cmd) - 1;
#else
char *cmd = NULL;
-phpdbg_interactive_enter:
while (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
cmd = readline(PROMPT);
- cmd_len = strlen(cmd);
+ if (cmd) {
+ cmd_len = strlen(cmd);
+ } else cmd_len = 0L;
#endif
/* trim space from end of input */
@@ -595,15 +595,10 @@ phpdbg_interactive_enter:
cmd = NULL;
}
#endif
-
} else if (PHPDBG_G(last)) {
PHPDBG_G(last)->handler(
PHPDBG_G(last_params), PHPDBG_G(last_params_len) TSRMLS_CC);
}
-
- if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
- goto phpdbg_interactive_enter;
- }
}
#ifdef HAVE_LIBREADLINE
diff --git a/phpdbg_utils.c b/phpdbg_utils.c
index fb22535..b567850 100644
--- a/phpdbg_utils.c
+++ b/phpdbg_utils.c
@@ -74,7 +74,7 @@ int phpdbg_is_class_method(const char *str, size_t len, char **class, char **met
void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
{
char *buffer = NULL;
- va_list args = {0};
+ va_list args;
if (format != NULL && strlen(format) > 0L) {
va_start(args, format);
@@ -122,19 +122,3 @@ 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 278019f..7682201 100644
--- a/phpdbg_utils.h
+++ b/phpdbg_utils.h
@@ -29,12 +29,6 @@ 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 {