com php-src: Add info globals command: phpdbg_help.c phpd bg_info.c phpdbg_info.h

From: Date: Tue, 23 Sep 2014 14:48:37 +0000
Subject: com php-src: Add info globals command: phpdbg_help.c phpd bg_info.c phpdbg_info.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82622@lists.php.net to get a copy of this message
Commit: 92fe2d0a85ab831b01e2de9802da1753c144b808 Author: Bob Weinand <bobwei9@hotmail.com> Tue, 23 Sep 2014 16:48:37 +0200 Parents: e2329bc70495adfaf8070fc6194aaefa2c5999c1 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=92fe2d0a85ab831b01e2de9802da1753c144b808 Log: Add info globals command Changed paths: M phpdbg_help.c M phpdbg_info.c M phpdbg_info.h Diff: diff --git a/phpdbg_help.c b/phpdbg_help.c index 3244b65..57d70c3 100644 --- a/phpdbg_help.c +++ b/phpdbg_help.c @@ -646,6 +646,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **funcs** **f** show loaded classes" CR " **error** **e** show last error" CR " **vars** **v** show active variables" CR +" **globals** **g** show superglobal variables" CR " **literal** **l** show active literal constants" CR " **memory** **m** show memory manager stats" }, diff --git a/phpdbg_info.c b/phpdbg_info.c index 97f88bf..a783bf4 100644 --- a/phpdbg_info.c +++ b/phpdbg_info.c @@ -37,6 +37,7 @@ const phpdbg_command_t phpdbg_info_commands[] = { 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(globals, "show superglobals", 'g', info_globals, 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 @@ -86,9 +87,16 @@ PHPDBG_INFO(error) /* {{{ */ return SUCCESS; } /* }}} */ -PHPDBG_INFO(vars) /* {{{ */ -{ - HashTable vars; +static int phpdbg_arm_auto_global(zend_auto_global *auto_global TSRMLS_DC) { + if (auto_global->armed) { + auto_global->armed = auto_global->auto_global_callback(auto_global->name, auto_global->name_len TSRMLS_CC); + } + + return 0; +} + +static int phpdbg_print_symbols(zend_bool show_globals TSRMLS_DC) { + HashTable vars, *symtable; HashPosition pos; char *var; zval **data; @@ -107,22 +115,31 @@ PHPDBG_INFO(vars) /* {{{ */ } } + + if (show_globals) { + zend_hash_apply(CG(auto_globals), (apply_func_t) phpdbg_arm_auto_global TSRMLS_CC); + symtable = &EG(symbol_table); + } else { + symtable = EG(active_symbol_table); + } + zend_hash_init(&vars, 8, NULL, NULL, 0); - zend_hash_internal_pointer_reset_ex(EG(active_symbol_table), &pos); - while (zend_hash_get_current_key_ex(EG(active_symbol_table), &var, + zend_hash_internal_pointer_reset_ex(symtable, &pos); + while (zend_hash_get_current_key_ex(symtable, &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_get_current_data_ex(symtable, (void **)&data, &pos); + if (zend_is_auto_global(var, strlen(var) TSRMLS_CC) ^ !show_globals) { + zend_hash_update(&vars, var, strlen(var)+1, (void**)data, sizeof(zval*), NULL); } - zend_hash_move_forward_ex(EG(active_symbol_table), &pos); + zend_hash_move_forward_ex(symtable, &pos); } - { + if (show_globals) { + phpdbg_notice("Superglobal variables (%d)", zend_hash_num_elements(&vars)); + } else { zend_op_array *ops = EG(active_op_array); - + if (ops->function_name) { if (ops->scope) { phpdbg_notice( @@ -204,6 +221,16 @@ PHPDBG_INFO(vars) /* {{{ */ return SUCCESS; } /* }}} */ +PHPDBG_INFO(vars) /* {{{ */ +{ + return phpdbg_print_symbols(0 TSRMLS_CC); +} + +PHPDBG_INFO(globals) /* {{{ */ +{ + return phpdbg_print_symbols(1 TSRMLS_CC); +} + PHPDBG_INFO(literal) /* {{{ */ { if ((EG(in_execution) && EG(active_op_array)) || PHPDBG_G(ops)) { diff --git a/phpdbg_info.h b/phpdbg_info.h index c36e6be..6930cdd 100644 --- a/phpdbg_info.h +++ b/phpdbg_info.h @@ -31,6 +31,7 @@ PHPDBG_INFO(classes); PHPDBG_INFO(funcs); PHPDBG_INFO(error); PHPDBG_INFO(vars); +PHPDBG_INFO(globals); PHPDBG_INFO(literal); PHPDBG_INFO(memory);

« previous php.cvs (#82622) next »