mirror of
https://github.com/php/php-src.git
synced 2024-09-22 18:37:25 +00:00
fix bug in passing correct expression length
add class printer (half done)
This commit is contained in:
parent
5204026308
commit
43c2748dce
@ -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;
|
||||
} /* }}} */
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
} /* }}} */
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user