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) {
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);
*/
PHPDBG_PRINT(opline);
PHPDBG_PRINT(class);
+PHPDBG_PRINT(method);
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 */
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;
#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) {
#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 */
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
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);
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;
-} /* }}} */
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
*/