mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00
added phpdbg_write to replace all the printf
This commit is contained in:
parent
ff54d20b58
commit
a712674964
3 changed files with 34 additions and 20 deletions
|
@ -357,19 +357,21 @@ static int clean_non_persistent_function_full(zend_function *function TSRMLS_DC)
|
|||
static PHPDBG_COMMAND(clean) /* {{{ */
|
||||
{
|
||||
if (!EG(in_execution)) {
|
||||
printf("[Cleaning Environment:]\n");
|
||||
printf("[\tClasses: %d]\n", zend_hash_num_elements(EG(class_table)));
|
||||
printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
|
||||
printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
|
||||
printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
|
||||
phpdbg_notice("Cleaning Execution Environment");
|
||||
|
||||
phpdbg_write("Classes\t%d", zend_hash_num_elements(EG(class_table)));
|
||||
phpdbg_write("Functions\t%d", zend_hash_num_elements(EG(function_table)));
|
||||
phpdbg_write("Constants\t%d", zend_hash_num_elements(EG(zend_constants)));
|
||||
phpdbg_write("Includes\t%d", zend_hash_num_elements(&EG(included_files)));
|
||||
|
||||
phpdbg_clean(1 TSRMLS_CC);
|
||||
|
||||
printf("[Clean Environment:]\n");
|
||||
printf("[\tClasses: %d]\n", zend_hash_num_elements(EG(class_table)));
|
||||
printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
|
||||
printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
|
||||
printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
|
||||
phpdbg_notice("Clean Execution Environment");
|
||||
|
||||
phpdbg_write("Classes\t%d", zend_hash_num_elements(EG(class_table)));
|
||||
phpdbg_write("Functions\t%d", zend_hash_num_elements(EG(function_table)));
|
||||
phpdbg_write("Constants\t%d", zend_hash_num_elements(EG(zend_constants)));
|
||||
phpdbg_write("Includes\t%d", zend_hash_num_elements(&EG(included_files)));
|
||||
} else {
|
||||
phpdbg_error("Cannot clean environment while executing");
|
||||
return FAILURE;
|
||||
|
@ -380,11 +382,12 @@ static PHPDBG_COMMAND(clean) /* {{{ */
|
|||
|
||||
static PHPDBG_COMMAND(clear) /* {{{ */
|
||||
{
|
||||
printf("[Clearing Breakpoints:]\n");
|
||||
printf("[\tFile\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]));
|
||||
printf("[\tSymbols\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]));
|
||||
printf("[\tOplines\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]));
|
||||
printf("[\tMethods\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]));
|
||||
phpdbg_notice("Clearing Breakpoints");
|
||||
|
||||
phpdbg_write("File\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]));
|
||||
phpdbg_write("Functions\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]));
|
||||
phpdbg_write("Methods\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]));
|
||||
phpdbg_write("Oplines\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]));
|
||||
|
||||
phpdbg_clear_breakpoints(TSRMLS_C);
|
||||
|
||||
|
|
|
@ -79,19 +79,28 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
|
|||
vspprintf(&buffer, 0, format, args);
|
||||
va_end(args);
|
||||
|
||||
/* TODO(anyone) colours */
|
||||
|
||||
switch (type) {
|
||||
case ERROR:
|
||||
printf("%s%s%s\n",
|
||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
|
||||
buffer,
|
||||
PHPDBG_END_LINE(TSRMLS_D));
|
||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
|
||||
break;
|
||||
|
||||
case NOTICE:
|
||||
printf("%s%s%s\n",
|
||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
|
||||
buffer,
|
||||
PHPDBG_END_LINE(TSRMLS_D));
|
||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
|
||||
break;
|
||||
|
||||
case WRITE:
|
||||
printf("%s%s%s\n",
|
||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m" : ""),
|
||||
buffer,
|
||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[0m" : ""));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,16 +31,18 @@ int phpdbg_is_addr(const char*);
|
|||
int phpdbg_is_class_method(const char*, size_t, char**, char**);
|
||||
|
||||
/**
|
||||
* Error/notice printing helper
|
||||
* Error/notice/formatting helper
|
||||
*/
|
||||
enum {
|
||||
ERROR = 1,
|
||||
NOTICE
|
||||
NOTICE,
|
||||
WRITE
|
||||
};
|
||||
|
||||
void phpdbg_print(int TSRMLS_DC, const char*, ...);
|
||||
|
||||
#define phpdbg_error(fmt, ...) phpdbg_print(ERROR TSRMLS_CC, fmt, ##__VA_ARGS__)
|
||||
#define phpdbg_notice(fmt, ...) phpdbg_print(NOTICE TSRMLS_CC, fmt, ##__VA_ARGS__)
|
||||
#define phpdbg_write(fmt, ...) phpdbg_print(WRITE TSRMLS_CC, fmt, ##__VA_ARGS__)
|
||||
|
||||
#endif /* PHPDBG_UTILS_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue