mirror of
https://github.com/php/php-src.git
synced 2025-08-20 09:24:05 +02:00
cleanup in list ... last time
This commit is contained in:
parent
7bc369399b
commit
a28ea698b8
3 changed files with 64 additions and 69 deletions
106
phpdbg_list.c
106
phpdbg_list.c
|
@ -31,44 +31,6 @@
|
||||||
|
|
||||||
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
|
||||||
|
|
||||||
static inline void i_phpdbg_list_func(const char *str, size_t len TSRMLS_DC)
|
|
||||||
{
|
|
||||||
HashTable *func_table = EG(function_table);
|
|
||||||
zend_function* fbc;
|
|
||||||
char *func_name = str;
|
|
||||||
size_t func_name_len = len;
|
|
||||||
|
|
||||||
/* search active scope if begins with period */
|
|
||||||
if (func_name[0] == '.') {
|
|
||||||
if (EG(scope)) {
|
|
||||||
func_name++;
|
|
||||||
func_name_len--;
|
|
||||||
|
|
||||||
func_table = &EG(scope)->function_table;
|
|
||||||
} else {
|
|
||||||
phpdbg_error("No active class");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (!EG(function_table)) {
|
|
||||||
phpdbg_error("No function table loaded");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
func_table = EG(function_table);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* use lowercase names, case insensitive */
|
|
||||||
func_name = zend_str_tolower_dup(func_name, func_name_len);
|
|
||||||
|
|
||||||
if (zend_hash_find(func_table, func_name, func_name_len+1,
|
|
||||||
(void**)&fbc) == SUCCESS) {
|
|
||||||
phpdbg_list_function(fbc TSRMLS_CC);
|
|
||||||
} else {
|
|
||||||
phpdbg_error("Function %s not found", func_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
efree(func_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
PHPDBG_LIST(lines) /* {{{ */
|
PHPDBG_LIST(lines) /* {{{ */
|
||||||
{
|
{
|
||||||
switch (param->type) {
|
switch (param->type) {
|
||||||
|
@ -92,7 +54,7 @@ PHPDBG_LIST(func) /* {{{ */
|
||||||
{
|
{
|
||||||
switch (param->type) {
|
switch (param->type) {
|
||||||
case STR_PARAM:
|
case STR_PARAM:
|
||||||
i_phpdbg_list_func(
|
phpdbg_list_function_byname(
|
||||||
param->str, param->len TSRMLS_CC);
|
param->str, param->len TSRMLS_CC);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -163,34 +125,6 @@ PHPDBG_LIST(class) /* {{{ */
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
void phpdbg_list_dispatch(phpdbg_param_t *param TSRMLS_DC) /* {{{ */
|
|
||||||
{
|
|
||||||
switch (param->type) {
|
|
||||||
case NUMERIC_PARAM:
|
|
||||||
case EMPTY_PARAM: {
|
|
||||||
if (PHPDBG_G(exec) || zend_is_executing(TSRMLS_C)) {
|
|
||||||
if (param->type == EMPTY_PARAM) {
|
|
||||||
phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0 TSRMLS_CC);
|
|
||||||
} else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0 TSRMLS_CC);
|
|
||||||
} else phpdbg_error("Not executing, and execution context not set");
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case FILE_PARAM:
|
|
||||||
phpdbg_list_file(param->file.name, param->file.line, 0 TSRMLS_CC);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STR_PARAM: {
|
|
||||||
i_phpdbg_list_func(param->str, param->len TSRMLS_CC);
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case METHOD_PARAM:
|
|
||||||
phpdbg_do_list_method(param TSRMLS_CC);
|
|
||||||
break;
|
|
||||||
|
|
||||||
phpdbg_default_switch_case();
|
|
||||||
}
|
|
||||||
} /* }}} */
|
|
||||||
|
|
||||||
void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */
|
void phpdbg_list_file(const char *filename, long count, long offset TSRMLS_DC) /* {{{ */
|
||||||
{
|
{
|
||||||
unsigned char *mem, *pos, *last_pos, *end_pos;
|
unsigned char *mem, *pos, *last_pos, *end_pos;
|
||||||
|
@ -289,3 +223,41 @@ void phpdbg_list_function(const zend_function *fbc TSRMLS_DC) /* {{{ */
|
||||||
ops->line_end - ops->line_start + 1, ops->line_start TSRMLS_CC);
|
ops->line_end - ops->line_start + 1, ops->line_start TSRMLS_CC);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
void phpdbg_list_function_byname(const char *str, size_t len TSRMLS_DC)
|
||||||
|
{
|
||||||
|
HashTable *func_table = EG(function_table);
|
||||||
|
zend_function* fbc;
|
||||||
|
char *func_name = str;
|
||||||
|
size_t func_name_len = len;
|
||||||
|
|
||||||
|
/* search active scope if begins with period */
|
||||||
|
if (func_name[0] == '.') {
|
||||||
|
if (EG(scope)) {
|
||||||
|
func_name++;
|
||||||
|
func_name_len--;
|
||||||
|
|
||||||
|
func_table = &EG(scope)->function_table;
|
||||||
|
} else {
|
||||||
|
phpdbg_error("No active class");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (!EG(function_table)) {
|
||||||
|
phpdbg_error("No function table loaded");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
func_table = EG(function_table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* use lowercase names, case insensitive */
|
||||||
|
func_name = zend_str_tolower_dup(func_name, func_name_len);
|
||||||
|
|
||||||
|
if (zend_hash_find(func_table, func_name, func_name_len+1,
|
||||||
|
(void**)&fbc) == SUCCESS) {
|
||||||
|
phpdbg_list_function(fbc TSRMLS_CC);
|
||||||
|
} else {
|
||||||
|
phpdbg_error("Function %s not found", func_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
efree(func_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,9 +39,9 @@ PHPDBG_LIST(class);
|
||||||
PHPDBG_LIST(method);
|
PHPDBG_LIST(method);
|
||||||
PHPDBG_LIST(func);
|
PHPDBG_LIST(func);
|
||||||
|
|
||||||
|
void phpdbg_list_function_byname(const char *, size_t TSRMLS_DC);
|
||||||
void phpdbg_list_function(const zend_function* TSRMLS_DC);
|
void phpdbg_list_function(const zend_function* TSRMLS_DC);
|
||||||
void phpdbg_list_file(const char*, long, long TSRMLS_DC);
|
void phpdbg_list_file(const char*, long, long TSRMLS_DC);
|
||||||
void phpdbg_list_dispatch(phpdbg_param_t *param TSRMLS_DC);
|
|
||||||
|
|
||||||
static const phpdbg_command_t phpdbg_list_commands[] = {
|
static const phpdbg_command_t phpdbg_list_commands[] = {
|
||||||
PHPDBG_LIST_EX_D(lines, "lists the specified lines", 'l'),
|
PHPDBG_LIST_EX_D(lines, "lists the specified lines", 'l'),
|
||||||
|
|
|
@ -685,7 +685,30 @@ static PHPDBG_COMMAND(quiet) { /* {{{ */
|
||||||
|
|
||||||
static PHPDBG_COMMAND(list) /* {{{ */
|
static PHPDBG_COMMAND(list) /* {{{ */
|
||||||
{
|
{
|
||||||
phpdbg_list_dispatch(param TSRMLS_CC);
|
switch (param->type) {
|
||||||
|
case NUMERIC_PARAM:
|
||||||
|
case EMPTY_PARAM: {
|
||||||
|
if (PHPDBG_G(exec) || zend_is_executing(TSRMLS_C)) {
|
||||||
|
if (param->type == EMPTY_PARAM) {
|
||||||
|
phpdbg_list_file(phpdbg_current_file(TSRMLS_C), 0, 0 TSRMLS_CC);
|
||||||
|
} else phpdbg_list_file(phpdbg_current_file(TSRMLS_C), param->num, 0 TSRMLS_CC);
|
||||||
|
} else phpdbg_error("Not executing, and execution context not set");
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case FILE_PARAM:
|
||||||
|
phpdbg_list_file(param->file.name, param->file.line, 0 TSRMLS_CC);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case STR_PARAM: {
|
||||||
|
phpdbg_list_function_byname(param->str, param->len TSRMLS_CC);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case METHOD_PARAM:
|
||||||
|
phpdbg_do_list_method(param TSRMLS_CC);
|
||||||
|
break;
|
||||||
|
|
||||||
|
phpdbg_default_switch_case();
|
||||||
|
}
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue