summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/phpdbg/phpdbg_info.c')
-rw-r--r--sapi/phpdbg/phpdbg_info.c137
1 files changed, 78 insertions, 59 deletions
diff --git a/sapi/phpdbg/phpdbg_info.c b/sapi/phpdbg/phpdbg_info.c
index 5596255d6e..97f88bfa1e 100644
--- a/sapi/phpdbg/phpdbg_info.c
+++ b/sapi/phpdbg/phpdbg_info.c
@@ -23,9 +23,25 @@
#include "phpdbg_utils.h"
#include "phpdbg_info.h"
#include "phpdbg_bp.h"
+#include "phpdbg_prompt.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+#define PHPDBG_INFO_COMMAND_D(f, h, a, m, l, s) \
+ PHPDBG_COMMAND_D_EXP(f, h, a, m, l, s, &phpdbg_prompt_commands[14])
+
+const phpdbg_command_t phpdbg_info_commands[] = {
+ PHPDBG_INFO_COMMAND_D(break, "show breakpoints", 'b', info_break, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(files, "show included files", 'F', info_files, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(classes, "show loaded classes", 'c', info_classes, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(funcs, "show loaded classes", 'f', info_funcs, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(error, "show last error", 'e', info_error, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(vars, "show active variables", 'v', info_vars, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(literal, "show active literal constants", 'l', info_literal, NULL, 0),
+ PHPDBG_INFO_COMMAND_D(memory, "show memory manager stats", 'm', info_memory, NULL, 0),
+ PHPDBG_END_COMMAND
+};
+
PHPDBG_INFO(break) /* {{{ */
{
phpdbg_print_breakpoints(PHPDBG_BREAK_FILE TSRMLS_CC);
@@ -44,14 +60,15 @@ PHPDBG_INFO(break) /* {{{ */
PHPDBG_INFO(files) /* {{{ */
{
HashPosition pos;
- zend_string *fname;
+ char *fname;
phpdbg_notice("Included files: %d",
zend_hash_num_elements(&EG(included_files)));
zend_hash_internal_pointer_reset_ex(&EG(included_files), &pos);
- while (zend_hash_get_current_key_ex(&EG(included_files), &fname, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
- phpdbg_writeln("File: %s", fname->val);
+ while (zend_hash_get_current_key_ex(&EG(included_files), &fname,
+ NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
+ phpdbg_writeln("File: %s", fname);
zend_hash_move_forward_ex(&EG(included_files), &pos);
}
@@ -73,8 +90,8 @@ PHPDBG_INFO(vars) /* {{{ */
{
HashTable vars;
HashPosition pos;
- zend_string *var;
- zval *data;
+ char *var;
+ zval **data;
if (!EG(active_op_array)) {
phpdbg_error("No active op array!");
@@ -92,13 +109,15 @@ PHPDBG_INFO(vars) /* {{{ */
zend_hash_init(&vars, 8, NULL, NULL, 0);
- zend_hash_internal_pointer_reset_ex(&EG(active_symbol_table)->ht, &pos);
- while (zend_hash_get_current_key_ex(&EG(active_symbol_table)->ht, &var, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
- data = zend_hash_get_current_data_ex(&EG(active_symbol_table)->ht, &pos);
- if (*(var->val) != '_') {
- zend_hash_update(&vars, var, data);
+ zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos);
+ while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var,
+ NULL, NULL, 0, &pos) == HASH_KEY_IS_STRING) {
+ zend_hash_get_current_data_ex(EG(active_symbol_table), (void **)&data, &pos);
+ if (*var != '_') {
+ zend_hash_update(
+ &vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL);
}
- zend_hash_move_forward_ex(&EG(active_symbol_table)->ht, &pos);
+ zend_hash_move_forward_ex(EG(active_symbol_table), &pos);
}
{
@@ -107,15 +126,15 @@ PHPDBG_INFO(vars) /* {{{ */
if (ops->function_name) {
if (ops->scope) {
phpdbg_notice(
- "Variables in %s::%s() (%d)", ops->scope->name->val, ops->function_name->val, zend_hash_num_elements(&vars));
+ "Variables in %s::%s() (%d)", ops->scope->name, ops->function_name, zend_hash_num_elements(&vars));
} else {
phpdbg_notice(
- "Variables in %s() (%d)", ops->function_name->val, zend_hash_num_elements(&vars));
+ "Variables in %s() (%d)", ops->function_name, zend_hash_num_elements(&vars));
}
} else {
if (ops->filename) {
phpdbg_notice(
- "Variables in %s (%d)", ops->filename->val, zend_hash_num_elements(&vars));
+ "Variables in %s (%d)", ops->filename, zend_hash_num_elements(&vars));
} else {
phpdbg_notice(
"Variables @ %p (%d)", ops, zend_hash_num_elements(&vars));
@@ -126,19 +145,19 @@ PHPDBG_INFO(vars) /* {{{ */
if (zend_hash_num_elements(&vars)) {
phpdbg_writeln("Address\t\tRefs\tType\t\tVariable");
for (zend_hash_internal_pointer_reset_ex(&vars, &pos);
- (data = zend_hash_get_current_data_ex(&vars, &pos)) != NULL;
+ zend_hash_get_current_data_ex(&vars, (void**) &data, &pos) == SUCCESS;
zend_hash_move_forward_ex(&vars, &pos)) {
- zend_string *var;
+ char *var;
- zend_hash_get_current_key_ex(&vars, &var, NULL, 0, &pos);
+ zend_hash_get_current_key_ex(&vars, &var, NULL, NULL, 0, &pos);
- if (data) {
+ if (*data) {
phpdbg_write(
"%p\t%d\t",
- data,
- Z_REFCOUNT_P(data));
+ *data,
+ Z_REFCOUNT_PP(data));
- switch (Z_TYPE_P(data)) {
+ switch (Z_TYPE_PP(data)) {
case IS_STRING: phpdbg_write("(string)\t"); break;
case IS_LONG: phpdbg_write("(integer)\t"); break;
case IS_DOUBLE: phpdbg_write("(float)\t"); break;
@@ -148,13 +167,12 @@ PHPDBG_INFO(vars) /* {{{ */
case IS_NULL: phpdbg_write("(null)\t"); break;
}
- if (Z_TYPE_P(data) == IS_RESOURCE) {
+ if (Z_TYPE_PP(data) == IS_RESOURCE) {
int type;
phpdbg_writeln(
- "%s$%s", Z_ISREF_P(data) ? "&": "", var->val);
- /*!!! FIXME
- if (zend_list_find(Z_RESVAL_P(data), &type)) {
+ "%s$%s", Z_ISREF_PP(data) ? "&": "", var);
+ if (zend_list_find(Z_RESVAL_PP(data), &type)) {
phpdbg_write(
"|-------(typeof)------> (%s)",
zend_rsrc_list_get_rsrc_type(type TSRMLS_CC));
@@ -162,21 +180,20 @@ PHPDBG_INFO(vars) /* {{{ */
phpdbg_write(
"|-------(typeof)------> (unknown)");
}
- */
phpdbg_writeln(EMPTY);
- } else if (Z_TYPE_P(data) == IS_OBJECT) {
+ } else if (Z_TYPE_PP(data) == IS_OBJECT) {
phpdbg_writeln(
- "%s$%s", Z_ISREF_P(data) ? "&": "", var->val);
+ "%s$%s", Z_ISREF_PP(data) ? "&": "", var);
phpdbg_write(
- "|-----(instanceof)----> (%s)", Z_OBJCE_P(data)->name->val);
+ "|-----(instanceof)----> (%s)", Z_OBJCE_PP(data)->name);
phpdbg_writeln(EMPTY);
} else {
phpdbg_write(
- "%s$%s", Z_ISREF_P(data) ? "&": "", var->val);
+ "%s$%s", Z_ISREF_PP(data) ? "&": "", var);
}
} else {
phpdbg_write(
- "n/a\tn/a\tn/a\t$%s", var->val);
+ "n/a\tn/a\tn/a\t$%s", var);
}
phpdbg_writeln(EMPTY);
}
@@ -196,15 +213,15 @@ PHPDBG_INFO(literal) /* {{{ */
if (ops->function_name) {
if (ops->scope) {
phpdbg_notice(
- "Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name->val, count);
+ "Literal Constants in %s::%s() (%d)", ops->scope->name, ops->function_name, count);
} else {
phpdbg_notice(
- "Literal Constants in %s() (%d)", ops->function_name->val, count);
+ "Literal Constants in %s() (%d)", ops->function_name, count);
}
} else {
if (ops->filename) {
phpdbg_notice(
- "Literal Constants in %s (%d)", ops->filename->val, count);
+ "Literal Constants in %s (%d)", ops->filename, count);
} else {
phpdbg_notice(
"Literal Constants @ %p (%d)", ops, count);
@@ -212,10 +229,10 @@ PHPDBG_INFO(literal) /* {{{ */
}
while (literal < ops->last_literal) {
- if (Z_TYPE(ops->literals[literal]) != IS_NULL) {
+ if (Z_TYPE(ops->literals[literal].constant) != IS_NULL) {
phpdbg_write("|-------- C%u -------> [", literal);
zend_print_zval(
- &ops->literals[literal], 0 TSRMLS_CC);
+ &ops->literals[literal].constant, 0);
phpdbg_write("]");
phpdbg_writeln(EMPTY);
}
@@ -248,34 +265,35 @@ PHPDBG_INFO(memory) /* {{{ */
return SUCCESS;
} /* }}} */
-static inline void phpdbg_print_class_name(zend_class_entry *ce TSRMLS_DC) /* {{{ */
+static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) /* {{{ */
{
phpdbg_write(
"%s %s %s (%d)",
- (ce->type == ZEND_USER_CLASS) ?
+ ((*ce)->type == ZEND_USER_CLASS) ?
"User" : "Internal",
- (ce->ce_flags & ZEND_ACC_INTERFACE) ?
+ ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
"Interface" :
- (ce->ce_flags & ZEND_ACC_ABSTRACT) ?
+ ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
"Abstract Class" :
"Class",
- ce->name->val, zend_hash_num_elements(&ce->function_table));
+ (*ce)->name, zend_hash_num_elements(&(*ce)->function_table));
} /* }}} */
PHPDBG_INFO(classes) /* {{{ */
{
HashPosition position;
- zend_class_entry *ce;
+ zend_class_entry **ce;
HashTable classes;
zend_hash_init(&classes, 8, NULL, NULL, 0);
for (zend_hash_internal_pointer_reset_ex(EG(class_table), &position);
- (ce = zend_hash_get_current_data_ptr_ex(EG(class_table), &position)) != NULL;
+ zend_hash_get_current_data_ex(EG(class_table), (void**)&ce, &position) == SUCCESS;
zend_hash_move_forward_ex(EG(class_table), &position)) {
- if (ce->type == ZEND_USER_CLASS) {
- zend_hash_next_index_insert_mem(&classes, ce, sizeof(ce));
+ if ((*ce)->type == ZEND_USER_CLASS) {
+ zend_hash_next_index_insert(
+ &classes, ce, sizeof(ce), NULL);
}
}
@@ -283,26 +301,26 @@ PHPDBG_INFO(classes) /* {{{ */
zend_hash_num_elements(&classes));
for (zend_hash_internal_pointer_reset_ex(&classes, &position);
- (ce = zend_hash_get_current_data_ptr_ex(&classes, &position)) != NULL;
+ zend_hash_get_current_data_ex(&classes, (void**)&ce, &position) == SUCCESS;
zend_hash_move_forward_ex(&classes, &position)) {
phpdbg_print_class_name(ce TSRMLS_CC);
phpdbg_writeln(EMPTY);
- if (ce->parent) {
- zend_class_entry *pce = ce->parent;
+ if ((*ce)->parent) {
+ zend_class_entry *pce = (*ce)->parent;
do {
phpdbg_write("|-------- ");
- phpdbg_print_class_name(pce TSRMLS_CC);
+ phpdbg_print_class_name(&pce TSRMLS_CC);
phpdbg_writeln(EMPTY);
} while ((pce = pce->parent));
}
- if (ce->info.user.filename) {
+ if ((*ce)->info.user.filename) {
phpdbg_writeln(
"|---- in %s on line %u",
- ce->info.user.filename->val,
- ce->info.user.line_start);
+ (*ce)->info.user.filename,
+ (*ce)->info.user.line_start);
} else {
phpdbg_writeln("|---- no source code");
}
@@ -317,17 +335,18 @@ PHPDBG_INFO(classes) /* {{{ */
PHPDBG_INFO(funcs) /* {{{ */
{
HashPosition position;
- zend_function *zf, *pzf;
+ zend_function *zf, **pzf;
HashTable functions;
zend_hash_init(&functions, 8, NULL, NULL, 0);
for (zend_hash_internal_pointer_reset_ex(EG(function_table), &position);
- (zf = zend_hash_get_current_data_ptr_ex(EG(function_table), &position)) != NULL;
+ zend_hash_get_current_data_ex(EG(function_table), (void**)&zf, &position) == SUCCESS;
zend_hash_move_forward_ex(EG(function_table), &position)) {
if (zf->type == ZEND_USER_FUNCTION) {
- zend_hash_next_index_insert_mem(&functions, zf, sizeof(zend_function));
+ zend_hash_next_index_insert(
+ &functions, (void**) &zf, sizeof(zend_function), NULL);
}
}
@@ -335,14 +354,14 @@ PHPDBG_INFO(funcs) /* {{{ */
zend_hash_num_elements(&functions));
for (zend_hash_internal_pointer_reset_ex(&functions, &position);
- (pzf = zend_hash_get_current_data_ptr_ex(&functions, &position)) != NULL;
+ zend_hash_get_current_data_ex(&functions, (void**)&pzf, &position) == SUCCESS;
zend_hash_move_forward_ex(&functions, &position)) {
- zend_op_array *op_array = &pzf->op_array;
+ zend_op_array *op_array = &((*pzf)->op_array);
phpdbg_writeln(
"|-------- %s in %s on line %d",
- op_array->function_name ? op_array->function_name->val : "{main}",
- op_array->filename ? op_array->filename->val : "(no source code)",
+ op_array->function_name ? op_array->function_name : "{main}",
+ op_array->filename ? op_array->filename : "(no source code)",
op_array->line_start);
}