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) /* {{{ */
|
static PHPDBG_COMMAND(clean) /* {{{ */
|
||||||
{
|
{
|
||||||
if (!EG(in_execution)) {
|
if (!EG(in_execution)) {
|
||||||
printf("[Cleaning Environment:]\n");
|
phpdbg_notice("Cleaning Execution Environment");
|
||||||
printf("[\tClasses: %d]\n", zend_hash_num_elements(EG(class_table)));
|
|
||||||
printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
|
phpdbg_write("Classes\t%d", zend_hash_num_elements(EG(class_table)));
|
||||||
printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
|
phpdbg_write("Functions\t%d", zend_hash_num_elements(EG(function_table)));
|
||||||
printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
|
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);
|
phpdbg_clean(1 TSRMLS_CC);
|
||||||
|
|
||||||
printf("[Clean Environment:]\n");
|
phpdbg_notice("Clean Execution Environment");
|
||||||
printf("[\tClasses: %d]\n", zend_hash_num_elements(EG(class_table)));
|
|
||||||
printf("[\tFunctions: %d]\n", zend_hash_num_elements(EG(function_table)));
|
phpdbg_write("Classes\t%d", zend_hash_num_elements(EG(class_table)));
|
||||||
printf("[\tConstants: %d]\n", zend_hash_num_elements(EG(zend_constants)));
|
phpdbg_write("Functions\t%d", zend_hash_num_elements(EG(function_table)));
|
||||||
printf("[\tIncluded: %d]\n", zend_hash_num_elements(&EG(included_files)));
|
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 {
|
} else {
|
||||||
phpdbg_error("Cannot clean environment while executing");
|
phpdbg_error("Cannot clean environment while executing");
|
||||||
return FAILURE;
|
return FAILURE;
|
||||||
|
@ -380,12 +382,13 @@ static PHPDBG_COMMAND(clean) /* {{{ */
|
||||||
|
|
||||||
static PHPDBG_COMMAND(clear) /* {{{ */
|
static PHPDBG_COMMAND(clear) /* {{{ */
|
||||||
{
|
{
|
||||||
printf("[Clearing Breakpoints:]\n");
|
phpdbg_notice("Clearing Breakpoints");
|
||||||
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]));
|
phpdbg_write("File\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE]));
|
||||||
printf("[\tOplines\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_OPLINE]));
|
phpdbg_write("Functions\t%d", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_SYM]));
|
||||||
printf("[\tMethods\t%d]\n", zend_hash_num_elements(&PHPDBG_G(bp)[PHPDBG_BREAK_METHOD]));
|
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);
|
phpdbg_clear_breakpoints(TSRMLS_C);
|
||||||
|
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
|
|
|
@ -79,19 +79,28 @@ void phpdbg_print(int type TSRMLS_DC, const char *format, ...) /* {{{ */
|
||||||
vspprintf(&buffer, 0, format, args);
|
vspprintf(&buffer, 0, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
/* TODO(anyone) colours */
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
printf("%s%s%s\n",
|
printf("%s%s%s\n",
|
||||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
|
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;31m[" : "["),
|
||||||
buffer,
|
buffer,
|
||||||
PHPDBG_END_LINE(TSRMLS_D));
|
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "]\033[0m" : "]"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NOTICE:
|
case NOTICE:
|
||||||
printf("%s%s%s\n",
|
printf("%s%s%s\n",
|
||||||
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
|
((PHPDBG_G(flags) & PHPDBG_IS_COLOURED) ? "\033[1;64m[" : "["),
|
||||||
buffer,
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,16 +31,18 @@ int phpdbg_is_addr(const char*);
|
||||||
int phpdbg_is_class_method(const char*, size_t, char**, char**);
|
int phpdbg_is_class_method(const char*, size_t, char**, char**);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error/notice printing helper
|
* Error/notice/formatting helper
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
ERROR = 1,
|
ERROR = 1,
|
||||||
NOTICE
|
NOTICE,
|
||||||
|
WRITE
|
||||||
};
|
};
|
||||||
|
|
||||||
void phpdbg_print(int TSRMLS_DC, const char*, ...);
|
void phpdbg_print(int TSRMLS_DC, const char*, ...);
|
||||||
|
|
||||||
#define phpdbg_error(fmt, ...) phpdbg_print(ERROR TSRMLS_CC, fmt, ##__VA_ARGS__)
|
#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_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 */
|
#endif /* PHPDBG_UTILS_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue