com php-src: info classes + help: phpdbg_help.c phpdbg_ help.h phpdbg_info.c phpdbg_info.h
| From: | Bob Weinand | Date: | Sun, 17 Nov 2013 18:26:56 +0000 |
| Subject: | com php-src: info classes + help: phpdbg_help.c phpdbg_ help.h phpdbg_info.c phpdbg_info.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-74882@lists.php.net to get a copy of this message | ||
Commit: 7c76e454108c90c287ab4d088ab57b475fa62ff1
Author: krakjoe <joe.watkins@live.co.uk> Sun, 17 Nov 2013 18:26:56 +0000
Parents: 33098232dc27c4f22dd38d17268fd59a64b1d000
Branches: PHP-5.6
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7c76e454108c90c287ab4d088ab57b475fa62ff1
Log:
info classes + help
Changed paths:
M phpdbg_help.c
M phpdbg_help.h
M phpdbg_info.c
M phpdbg_info.h
Diff:
diff --git a/phpdbg_help.c b/phpdbg_help.c
index fd09432..c5d7690 100644
--- a/phpdbg_help.c
+++ b/phpdbg_help.c
@@ -23,6 +23,7 @@
#include "phpdbg_utils.h"
#include "phpdbg_break.h"
#include "phpdbg_list.h"
+#include "phpdbg_info.h"
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
@@ -213,6 +214,28 @@ PHPDBG_HELP(clear) /* {{{ */
return SUCCESS;
} /* }}} */
+PHPDBG_HELP(info) /* {{{ */
+{
+ phpdbg_help_header();
+ phpdbg_writeln("info commands provides quick access to various types of information about
the PHP environment");
+ phpdbg_writeln("Specific info commands are show below:");
+ phpdbg_notice("Commands");
+ {
+ const phpdbg_command_t *info_command = phpdbg_info_commands;
+
+ phpdbg_writeln("\tAlias\tCommand\t\tPurpose");
+ while (info_command && info_command->name) {
+ if (info_command->alias) {
+ phpdbg_writeln("\t[%c]\t%s\t\t%s", info_command->alias, info_command->name,
info_command->tip);
+ } else phpdbg_writeln("\t[-]\t%s\t\t%s", info_command->name, info_command->tip);
+ ++info_command;
+ }
+ }
+
+ phpdbg_help_footer();
+ return SUCCESS;
+} /* }}} */
+
PHPDBG_HELP(quiet) /* {{{ */
{
phpdbg_help_header();
diff --git a/phpdbg_help.h b/phpdbg_help.h
index e73782b..445b84f 100644
--- a/phpdbg_help.h
+++ b/phpdbg_help.h
@@ -47,6 +47,7 @@ PHPDBG_HELP(print);
PHPDBG_HELP(break);
PHPDBG_HELP(clean);
PHPDBG_HELP(clear);
+PHPDBG_HELP(info);
PHPDBG_HELP(back);
PHPDBG_HELP(quiet);
PHPDBG_HELP(list);
@@ -69,6 +70,7 @@ static const phpdbg_command_t phpdbg_help_commands[] = {
PHPDBG_HELP_D(break, "breakpoints allow execution interruption", 'b'),
PHPDBG_HELP_D(clean, "resetting the environment is useful while debugging and
recompiling", 'X'),
PHPDBG_HELP_D(clear, "clearing breakpoints allows you to run code without
interruption", 'c'),
+ PHPDBG_HELP_D(info, "quick access to useful information on the console",
'i'),
PHPDBG_HELP_D(back, "show debug backtrace information during execution",
't'),
PHPDBG_HELP_D(quiet, "be quiet during execution", 's'),
PHPDBG_HELP_D(list, "listing code gives you quick access to code while executing",
'l'),
diff --git a/phpdbg_info.c b/phpdbg_info.c
index c396f15..1b3770e 100644
--- a/phpdbg_info.c
+++ b/phpdbg_info.c
@@ -38,3 +38,68 @@ PHPDBG_INFO(files) /* {{{ */
return SUCCESS;
} /* }}} */
+
+static inline void phpdbg_print_class_name(zend_class_entry **ce TSRMLS_DC) { /* {{{ */
+ phpdbg_write(
+ "%s %s %s (%d)",
+ ((*ce)->type == ZEND_USER_CLASS) ?
+ "User" : "Internal",
+ ((*ce)->ce_flags & ZEND_ACC_INTERFACE) ?
+ "Interface" :
+ ((*ce)->ce_flags & ZEND_ACC_ABSTRACT) ?
+ "Abstract Class" :
+ "Class",
+ (*ce)->name, zend_hash_num_elements(&(*ce)->function_table));
+} /* }}} */
+
+PHPDBG_INFO(classes) /* {{{ */
+{
+ HashPosition position;
+ 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);
+ 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(
+ &classes, ce, sizeof(ce), NULL);
+ }
+ }
+
+ phpdbg_notice("User Classes (%d)",
+ zend_hash_num_elements(&classes));
+
+ for (zend_hash_internal_pointer_reset_ex(&classes, &position);
+ 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;
+ do {
+ phpdbg_write("|-------- ");
+ phpdbg_print_class_name(&pce TSRMLS_CC);
+ phpdbg_writeln(EMPTY);
+ } while(pce = pce->parent);
+ }
+
+ if ((*ce)->info.user.filename) {
+ phpdbg_writeln(
+ "|---- in %s on line %lu",
+ (*ce)->info.user.filename,
+ (*ce)->info.user.line_start);
+ } else phpdbg_writeln("|---- no source code");
+ }
+
+ zend_hash_destroy(&classes);
+
+ return SUCCESS;
+} /* }}} */
+
+
diff --git a/phpdbg_info..h b/phpdbg_info.h
index 1e967b0..0223ed9 100644
--- a/phpdbg_info.h
+++ b/phpdbg_info.h
@@ -37,9 +37,11 @@
int PHPDBG_INFO_HANDLER(name)(phpdbg_param_t *param TSRMLS_DC)
PHPDBG_INFO(files);
+PHPDBG_INFO(classes);
static const phpdbg_command_t phpdbg_info_commands[] = {
- PHPDBG_INFO_EX_D(files, "lists included files", 'f'),
+ PHPDBG_INFO_EX_D(files, "lists included files", 'F'),
+ PHPDBG_INFO_EX_D(classes, "lists loaded classes", 'c'),
PHPDBG_END_COMAND
};