Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Added ANSI colour output for the shell. (Patch by Michael Maclean).

SVN Rev: 3337
  • Loading branch information...
commit 23c5739ee923938aba0c029d3971db563cb43606 1 parent b6844bf
@derickr derickr authored
View
15 php_xdebug.h
@@ -38,6 +38,12 @@ extern zend_module_entry xdebug_module_entry;
#define MICRO_IN_SEC 1000000.00
+#ifndef PHP_WIN32
+#define OUTPUT_NOT_CHECKED -1
+#define OUTPUT_IS_TTY 1
+#define OUTPUT_NOT_TTY 0
+#endif
+
#ifdef PHP_WIN32
#define PHP_XDEBUG_API __declspec(dllexport)
#else
@@ -81,6 +87,10 @@ PHP_RSHUTDOWN_FUNCTION(xdebug);
PHP_MINFO_FUNCTION(xdebug);
ZEND_MODULE_POST_ZEND_DEACTIVATE_D(xdebug);
+#ifndef PHP_WIN32
+int xdebug_is_output_tty();
+#endif
+
/* call stack functions */
PHP_FUNCTION(xdebug_get_stack_depth);
PHP_FUNCTION(xdebug_get_function_stack);
@@ -177,6 +187,11 @@ ZEND_BEGIN_MODULE_GLOBALS(xdebug)
long display_max_data;
long display_max_depth;
+#ifndef PHP_WIN32
+ zend_bool cli_color;
+ int output_is_tty;
+#endif
+
/* used for code coverage */
zend_bool do_code_coverage;
xdebug_hash *code_coverage;
View
52 xdebug.c
@@ -292,6 +292,9 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("xdebug.var_display_max_children", "128", PHP_INI_ALL, OnUpdateLong, display_max_children, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.var_display_max_data", "512", PHP_INI_ALL, OnUpdateLong, display_max_data, zend_xdebug_globals, xdebug_globals)
STD_PHP_INI_ENTRY("xdebug.var_display_max_depth", "3", PHP_INI_ALL, OnUpdateLong, display_max_depth, zend_xdebug_globals, xdebug_globals)
+#ifndef PHP_WIN32
+ STD_PHP_INI_ENTRY("xdebug.cli_color", "0", PHP_INI_ALL, OnUpdateBool, cli_color, zend_xdebug_globals, xdebug_globals)
+#endif
/* Scream support */
STD_PHP_INI_BOOLEAN("xdebug.scream", "0", PHP_INI_ALL, OnUpdateBool, do_scream, zend_xdebug_globals, xdebug_globals)
@@ -308,6 +311,7 @@ static void php_xdebug_init_globals (zend_xdebug_globals *xg TSRMLS_DC)
xg->do_code_coverage = 0;
xg->breakpoint_count = 0;
xg->ide_key = NULL;
+ xg->output_is_tty = OUTPUT_NOT_CHECKED;
xdebug_llist_init(&xg->server, xdebug_superglobals_dump_dtor);
xdebug_llist_init(&xg->get, xdebug_superglobals_dump_dtor);
@@ -423,6 +427,11 @@ void xdebug_env_config()
if (strcasecmp(envvar, "remote_cookie_expire_time") == 0) {
name = "xdebug.remote_cookie_expire_time";
}
+#ifndef PHP_WIN32
+ else if (strcasecmp(envvar, "cli_color") == 0) {
+ name = "xdebug.cli_color";
+ }
+#endif
if (name) {
zend_alter_ini_entry(name, strlen(name) + 1, envval, strlen(envval), PHP_INI_SYSTEM, PHP_INI_STAGE_ACTIVATE);
@@ -478,6 +487,26 @@ static int xdebug_include_or_eval_handler(ZEND_OPCODE_HANDLER_ARGS)
return ZEND_USER_OPCODE_DISPATCH;
}
+#ifndef PHP_WIN32
+int xdebug_is_output_tty()
+{
+ if (XG(output_is_tty) == OUTPUT_NOT_CHECKED) {
+ php_stream *output = php_stream_open_wrapper("php://stdout", "w", REPORT_ERRORS, NULL);
+ int fd;
+
+ if (php_stream_cast(output, PHP_STREAM_AS_FD, (void *)&fd, REPORT_ERRORS) == FAILURE) {
+ XG(output_is_tty) = OUTPUT_NOT_TTY;
+ } else if (!isatty(fd)) {
+ XG(output_is_tty) = OUTPUT_NOT_TTY;
+ } else {
+ XG(output_is_tty) = OUTPUT_IS_TTY;
+ }
+ php_stream_close(output);
+ }
+ return (XG(output_is_tty));
+}
+#endif
+
PHP_MINIT_FUNCTION(xdebug)
{
@@ -584,6 +613,10 @@ PHP_MINIT_FUNCTION(xdebug)
REGISTER_LONG_CONSTANT("XDEBUG_CC_DEAD_CODE", XDEBUG_CC_OPTION_DEAD_CODE, CONST_CS | CONST_PERSISTENT);
XG(breakpoint_count) = 0;
+#ifndef PHP_WIN32
+ XG(output_is_tty) = OUTPUT_NOT_CHECKED;
+#endif
+
#ifndef ZTS
if (sapi_module.header_handler != xdebug_header_handler) {
xdebug_orig_header_handler = sapi_module.header_handler;
@@ -1436,7 +1469,15 @@ PHP_FUNCTION(xdebug_var_dump)
val = xdebug_get_zval_value_fancy(NULL, (zval*) *args[i], &len, 0, NULL TSRMLS_CC);
PHPWRITE(val, len);
xdfree(val);
- } else {
+ }
+#ifndef PHP_WIN32
+ else if (XG(cli_color) == 1 && xdebug_is_output_tty(TSRMLS_C)) {
+ val = xdebug_get_zval_value_ansi((zval*) *args[i], 0, NULL TSRMLS_CC);
+ PHPWRITE(val, strlen(val));
+ xdfree(val);
+ }
+#endif
+ else {
xdebug_php_var_dump(args[i], 1 TSRMLS_CC);
}
}
@@ -1478,7 +1519,14 @@ PHP_FUNCTION(xdebug_debug_zval)
if (PG(html_errors)) {
val = xdebug_get_zval_value_fancy(NULL, debugzval, &len, 1, NULL TSRMLS_CC);
PHPWRITE(val, len);
- } else {
+ }
+#ifndef PHP_WIN32
+ else if (XG(cli_color) == 1 && xdebug_is_output_tty(TSRMLS_C)) {
+ val = xdebug_get_zval_value_ansi(debugzval, 1, NULL TSRMLS_CC);
+ PHPWRITE(val, strlen(val));
+ }
+#endif
+ else {
val = xdebug_get_zval_value(debugzval, 1, NULL);
PHPWRITE(val, strlen(val));
}
View
48 xdebug_stack.c
@@ -24,6 +24,7 @@
#include "xdebug_str.h"
#include "xdebug_superglobals.h"
#include "xdebug_var.h"
+#include "php_ini.h"
#include "main/php_ini.h"
@@ -46,6 +47,25 @@ static char* text_formats[10] = {
" $%s = *uninitialized*\n"
};
+#ifndef PHP_WIN32
+static char* ansi_formats[10] = {
+ "\n",
+ "\e[1m\e[31m%s\e[0m: %s\e[22m in \e[31m%s\e[0m on line \e[32m%d\e[0m\e[22m\n",
+ "\n\e[1mCall Stack:\e[22m\n",
+#if HAVE_PHP_MEMORY_USAGE
+ "%10.4f %10ld %3d. %s(",
+#else
+ "%10.4f %3d. %s(",
+#endif
+ "'%s'",
+ ") %s:%d\n",
+ "\n\nVariables in local scope (#%d):\n",
+ "\n",
+ " $%s = %s\n",
+ " $%s = *uninitialized*\n"
+};
+#endif
+
static char* html_formats[12] = {
"<br />\n<font size='1'><table class='xdebug-error' dir='ltr' border='1' cellspacing='0' cellpadding='1'>\n",
"<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in %s on line <i>%d</i></th></tr>\n",
@@ -70,6 +90,20 @@ static char* html_formats[12] = {
"<tr><th align='left' bgcolor='#f57900' colspan=\"5\"><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> %s: %s in <a style='color: black' href='%s'>%s</a> on line <i>%d</i></th></tr>\n"
};
+static char** select_formats(int html TSRMLS_DC) {
+ if (html) {
+ return html_formats;
+ }
+#ifndef PHP_WIN32
+ else if (XG(cli_color) == 1 && xdebug_is_output_tty(TSRMLS_C)) {
+ return ansi_formats;
+ }
+#endif
+ else {
+ return text_formats;
+ }
+}
+
static void dump_used_var_with_contents(void *htmlq, xdebug_hash_element* he, void *argument)
{
int html = *(int *)htmlq;
@@ -102,11 +136,7 @@ static void dump_used_var_with_contents(void *htmlq, xdebug_hash_element* he, vo
zvar = xdebug_get_php_symbol(name, strlen(name) + 1);
XG(active_symbol_table) = tmp_ht;
- if (html) {
- formats = html_formats;
- } else {
- formats = text_formats;
- }
+ formats = select_formats(PG(html_errors));
if (!zvar) {
xdebug_str_add(str, xdebug_sprintf(formats[9], name), 1);
@@ -218,14 +248,14 @@ static int create_file_link(char **filename, const char *error_filename, int err
static void xdebug_append_error_head(xdebug_str *str, int html TSRMLS_DC)
{
- char **formats = html ? html_formats : text_formats;
+ char **formats = select_formats(html TSRMLS_CC);
xdebug_str_add(str, formats[0], 0);
}
void xdebug_append_error_description(xdebug_str *str, int html, const char *error_type_str, char *buffer, const char *error_filename, const int error_lineno TSRMLS_DC)
{
- char **formats = html ? html_formats : text_formats;
+ char **formats = select_formats(html TSRMLS_CC);
if (strlen(XG(file_link_format)) > 0 && html) {
char *file_link;
@@ -243,7 +273,7 @@ void xdebug_append_printable_stack(xdebug_str *str, int html TSRMLS_DC)
xdebug_llist_element *le;
function_stack_entry *i;
int len;
- char **formats = html ? html_formats : text_formats;
+ char **formats = select_formats(html TSRMLS_CC);
if (XG(stack) && XG(stack)->size) {
i = XDEBUG_LLIST_VALP(XDEBUG_LLIST_HEAD(XG(stack)));
@@ -388,7 +418,7 @@ void xdebug_append_printable_stack(xdebug_str *str, int html TSRMLS_DC)
static void xdebug_append_error_footer(xdebug_str *str, int html)
{
- char **formats = html ? html_formats : text_formats;
+ char **formats = select_formats(html TSRMLS_CC);
xdebug_str_add(str, formats[7], 0);
}
View
306 xdebug_var.c
@@ -503,6 +503,311 @@ char* xdebug_get_zval_synopsis(zval *val, int debug_zval, xdebug_var_export_opti
return str.d;
}
+#ifndef PHP_WIN32
+/*****************************************************************************
+** ANSI colored variable printing routines
+*/
+
+#define ANSI_COLOR_POINTER "\e[30m"
+#define ANSI_COLOR_BOOL "\e[35m"
+#define ANSI_COLOR_LONG "\e[32m"
+#define ANSI_COLOR_NULL "\e[34m"
+#define ANSI_COLOR_DOUBLE "\e[33m"
+#define ANSI_COLOR_STRING "\e[31m"
+#define ANSI_COLOR_EMPTY "\e[30m"
+#define ANSI_COLOR_ARRAY "\e[33m"
+#define ANSI_COLOR_OBJECT "\e[31m"
+#define ANSI_COLOR_RESOURCE "\e[36m"
+#define ANSI_COLOR_MODIFIER "\e[32m"
+#define ANSI_COLOR_RESET "\e[0m"
+#define ANSI_COLOR_BOLD "\e[1m"
+#define ANSI_COLOR_BOLD_OFF "\e[22m"
+
+static int xdebug_array_element_export_ansi(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+{
+ int level, debug_zval;
+ xdebug_str *str;
+ xdebug_var_export_options *options;
+
+ level = va_arg(args, int);
+ str = va_arg(args, struct xdebug_str*);
+ debug_zval = va_arg(args, int);
+ options = va_arg(args, xdebug_var_export_options*);
+
+ if (options->runtime[level].current_element_nr >= options->runtime[level].start_element_nr &&
+ options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
+ {
+ xdebug_str_add(str, xdebug_sprintf("%*s", (level * 2), ""), 1);
+
+ if (hash_key->nKeyLength==0) { /* numeric key */
+ xdebug_str_add(str, xdebug_sprintf("[%ld] %s=>%s\n", hash_key->h, ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
+ } else { /* string key */
+ int newlen = 0;
+ char *tmp, *tmp2;
+
+ tmp = php_str_to_str(hash_key->arKey, hash_key->nKeyLength, "'", 1, "\\'", 2, &newlen);
+ tmp2 = php_str_to_str(tmp, newlen - 1, "\0", 1, "\\0", 2, &newlen);
+ if (tmp) {
+ efree(tmp);
+ }
+ xdebug_str_addl(str, "'", 1, 0);
+ if (tmp2) {
+ xdebug_str_addl(str, tmp2, newlen, 0);
+ efree(tmp2);
+ }
+ xdebug_str_add(str, "' =>\n", 0);
+ }
+ xdebug_var_export_ansi(zv, str, level + 1, debug_zval, options TSRMLS_CC);
+ }
+ if (options->runtime[level].current_element_nr == options->runtime[level].end_element_nr) {
+ xdebug_str_addl(str, "...,\n ", 6, 0);
+ }
+ options->runtime[level].current_element_nr++;
+ return 0;
+}
+
+static int xdebug_object_element_export_ansi(zval **zv XDEBUG_ZEND_HASH_APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
+{
+ int level, debug_zval;
+ xdebug_str *str;
+ xdebug_var_export_options *options;
+ char *prop_name, *class_name, *modifier;
+
+ level = va_arg(args, int);
+ str = va_arg(args, struct xdebug_str*);
+ debug_zval = va_arg(args, int);
+ options = va_arg(args, xdebug_var_export_options*);
+
+ if (options->runtime[level].current_element_nr >= options->runtime[level].start_element_nr &&
+ options->runtime[level].current_element_nr < options->runtime[level].end_element_nr)
+ {
+ xdebug_str_add(str, xdebug_sprintf("%*s", (level * 2), ""), 1);
+
+ if (hash_key->nKeyLength != 0) {
+ modifier = xdebug_get_property_info(hash_key->arKey, hash_key->nKeyLength, &prop_name, &class_name);
+ xdebug_str_add(str, xdebug_sprintf("%s%s%s%s%s $%s %s=>%s",
+ ANSI_COLOR_MODIFIER, ANSI_COLOR_BOLD, modifier, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_RESET,
+ prop_name, ANSI_COLOR_POINTER, ANSI_COLOR_RESET), 1);
+ }
+ xdebug_var_export_ansi(zv, str, level + 1, debug_zval, options TSRMLS_CC);
+ }
+ if (options->runtime[level].current_element_nr == options->runtime[level].end_element_nr) {
+ xdebug_str_addl(str, "...; ", 5, 0);
+ }
+ options->runtime[level].current_element_nr++;
+ return 0;
+}
+
+void xdebug_var_export_ansi(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
+{
+ HashTable *myht;
+ char* tmp_str;
+ int tmp_len;
+
+ if (!struc || !(*struc)) {
+ return;
+ }
+ if (debug_zval) {
+ xdebug_str_add(str, xdebug_sprintf("(refcount=%d, is_ref=%d)=", (*struc)->XDEBUG_REFCOUNT, (*struc)->XDEBUG_IS_REF), 1);
+ }
+
+ xdebug_str_add(str, xdebug_sprintf("%*s", (level * 2) - 2, ""), 1);
+
+ switch (Z_TYPE_PP(struc)) {
+ case IS_BOOL:
+ xdebug_str_add(str, xdebug_sprintf("%sbool%s(%s%s%s)", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_BOOL, Z_LVAL_PP(struc) ? "true" : "false", ANSI_COLOR_RESET), 1);
+ break;
+
+ case IS_NULL:
+ xdebug_str_add(str, xdebug_sprintf("%s%sNULL%s%s", ANSI_COLOR_BOLD, ANSI_COLOR_NULL, ANSI_COLOR_RESET, ANSI_COLOR_BOLD_OFF), 1);
+ break;
+
+ case IS_LONG:
+ xdebug_str_add(str, xdebug_sprintf("%sint%s(%s%ld%s)", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_LONG, Z_LVAL_PP(struc), ANSI_COLOR_RESET), 1);
+ break;
+
+ case IS_DOUBLE:
+ xdebug_str_add(str, xdebug_sprintf("%sdouble%s(%s%.*G%s)", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_DOUBLE, (int) EG(precision), Z_DVAL_PP(struc), ANSI_COLOR_RESET), 1);
+ break;
+
+ case IS_STRING:
+ tmp_str = php_addcslashes(Z_STRVAL_PP(struc), Z_STRLEN_PP(struc), &tmp_len, 0, "'\\\0..\37", 6 TSRMLS_CC);
+ if (options->no_decoration) {
+ xdebug_str_add(str, tmp_str, 0);
+ } else if (options->max_data == 0 || Z_STRLEN_PP(struc) <= options->max_data) {
+ xdebug_str_add(str, xdebug_sprintf("%sstring%s(%s%ld%s) '%s%s%s'", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF,
+ ANSI_COLOR_LONG, Z_STRLEN_PP(struc), ANSI_COLOR_RESET,
+ ANSI_COLOR_STRING, tmp_str, ANSI_COLOR_RESET), 1);
+ } else {
+ xdebug_str_addl(str, "'", 1, 0);
+ xdebug_str_addl(str, xdebug_sprintf("%sstring%s(%s%ld%s) %s%s%s", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF,
+ ANSI_COLOR_LONG, Z_STRLEN_PP(struc), ANSI_COLOR_RESET,
+ ANSI_COLOR_STRING, tmp_str, ANSI_COLOR_RESET), options->max_data, 1);
+ xdebug_str_addl(str, "...'", 4, 0);
+ }
+ efree(tmp_str);
+ break;
+
+ case IS_ARRAY:
+ myht = Z_ARRVAL_PP(struc);
+ if (myht->nApplyCount < 1) {
+ xdebug_str_add(str, xdebug_sprintf("%sarray%s(%s%d%s) {\n", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_LONG, myht->nNumOfElements, ANSI_COLOR_RESET), 1);
+ if (level <= options->max_depth) {
+ options->runtime[level].current_element_nr = 0;
+ options->runtime[level].start_element_nr = 0;
+ options->runtime[level].end_element_nr = options->max_children;
+
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_array_element_export_ansi, 4, level, str, debug_zval, options);
+ } else {
+ xdebug_str_addl(str, "...", 3, 0);
+ }
+ xdebug_str_add(str, xdebug_sprintf("%*s}", (level * 2) - 2 , ""), 1);
+ } else {
+ xdebug_str_add(str, xdebug_sprintf("&%sarray%s", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF), 1);
+ }
+ break;
+
+ case IS_OBJECT:
+ myht = Z_OBJPROP_PP(struc);
+ if (myht->nApplyCount < 1) {
+ char *class_name;
+ zend_uint class_name_len;
+
+ zend_get_object_classname(*struc, &class_name, &class_name_len TSRMLS_CC);
+ xdebug_str_add(str, xdebug_sprintf("%sclass%s %s%s%s#%d (%s%d%s) {\n", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_OBJECT, class_name, ANSI_COLOR_RESET,
+ Z_OBJ_HANDLE_PP(struc),
+ ANSI_COLOR_LONG, myht->nNumOfElements, ANSI_COLOR_RESET), 1);
+ efree(class_name);
+
+ if (level <= options->max_depth) {
+ options->runtime[level].current_element_nr = 0;
+ options->runtime[level].start_element_nr = 0;
+ options->runtime[level].end_element_nr = options->max_children;
+
+ zend_hash_apply_with_arguments(myht XDEBUG_ZEND_HASH_APPLY_TSRMLS_CC, (apply_func_args_t) xdebug_object_element_export_ansi, 4, level, str, debug_zval, options);
+ } else {
+ xdebug_str_addl(str, "...", 3, 0);
+ }
+ xdebug_str_add(str, xdebug_sprintf("%*s}", (level * 2) - 2, ""), 1);
+ } else {
+ xdebug_str_addl(str, "...", 3, 0);
+ }
+ break;
+
+ case IS_RESOURCE: {
+ char *type_name;
+
+ type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
+ xdebug_str_add(str, xdebug_sprintf("%sresource%s(%s%ld%s) of type (%s)", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF,
+ ANSI_COLOR_RESOURCE, Z_LVAL_PP(struc), ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
+ break;
+ }
+
+ default:
+ xdebug_str_add(str, xdebug_sprintf("%sNULL%s", ANSI_COLOR_NULL, ANSI_COLOR_RESET), 0);
+ break;
+ }
+
+ xdebug_str_addl(str, "\n", 1, 0);
+}
+
+char* xdebug_get_zval_value_ansi(zval *val, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
+{
+ xdebug_str str = {0, 0, NULL};
+ int default_options = 0;
+
+ if (!options) {
+ options = xdebug_var_export_options_from_ini(TSRMLS_C);
+ default_options = 1;
+ }
+
+ xdebug_var_export_ansi(&val, (xdebug_str*) &str, 1, debug_zval, options TSRMLS_CC);
+
+ if (default_options) {
+ xdfree(options->runtime);
+ xdfree(options);
+ }
+
+ return str.d;
+}
+
+static void xdebug_var_synopsis_ansi(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
+{
+ HashTable *myht;
+
+ if (!struc || !(*struc)) {
+ return;
+ }
+ if (debug_zval) {
+ xdebug_str_add(str, xdebug_sprintf("(refcount=%d, is_ref=%d)=", (*struc)->XDEBUG_REFCOUNT, (*struc)->XDEBUG_IS_REF), 1);
+ }
+ switch (Z_TYPE_PP(struc)) {
+ case IS_BOOL:
+ xdebug_str_add(str, xdebug_sprintf("%sbool%s", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF), 1);
+ break;
+
+ case IS_NULL:
+ xdebug_str_add(str, xdebug_sprintf("%snull%s", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF), 1);
+ break;
+
+ case IS_LONG:
+ xdebug_str_add(str, xdebug_sprintf("%sint%s", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF), 1);
+ break;
+
+ case IS_DOUBLE:
+ xdebug_str_add(str, xdebug_sprintf("%sdouble%s", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF), 1);
+ break;
+
+ case IS_STRING:
+ xdebug_str_add(str, xdebug_sprintf("%sstring%s(%s%d%s)", ANSI_COLOR_BOLD, ANSI_COLOR_BOLD_OFF, ANSI_COLOR_LONG, Z_STRLEN_PP(struc), ANSI_COLOR_RESET), 1);
+ break;
+
+ case IS_ARRAY:
+ myht = Z_ARRVAL_PP(struc);
+ xdebug_str_add(str, xdebug_sprintf("array(%s%d%s)", ANSI_COLOR_LONG, myht->nNumOfElements, ANSI_COLOR_RESET), 1);
+ break;
+
+ case IS_OBJECT: {
+ char *class_name;
+ zend_uint class_name_len;
+
+ zend_get_object_classname(*struc, &class_name, &class_name_len TSRMLS_CC);
+ xdebug_str_add(str, xdebug_sprintf("class %s", class_name), 1);
+ break;
+ }
+
+ case IS_RESOURCE: {
+ char *type_name;
+
+ type_name = zend_rsrc_list_get_rsrc_type(Z_LVAL_PP(struc) TSRMLS_CC);
+ xdebug_str_add(str, xdebug_sprintf("resource(%s%ld%s) of type (%s)", ANSI_COLOR_LONG, Z_LVAL_PP(struc), ANSI_COLOR_RESET, type_name ? type_name : "Unknown"), 1);
+ break;
+ }
+ }
+}
+
+char* xdebug_get_zval_synopsis_ansi(zval *val, int debug_zval, xdebug_var_export_options *options TSRMLS_DC)
+{
+ xdebug_str str = {0, 0, NULL};
+ int default_options = 0;
+
+ if (!options) {
+ options = xdebug_var_export_options_from_ini(TSRMLS_C);
+ default_options = 1;
+ }
+
+ xdebug_var_synopsis_ansi(&val, (xdebug_str*) &str, 1, debug_zval, options TSRMLS_CC);
+
+ if (default_options) {
+ xdfree(options->runtime);
+ xdfree(options);
+ }
+
+ return str.d;
+}
+#endif
+
+
/*****************************************************************************
** XML node printing routines
*/
@@ -1175,3 +1480,4 @@ char* xdebug_show_fname(xdebug_func f, int html, int flags TSRMLS_DC)
return xdstrdup("{unknown}");
}
}
+
View
9 xdebug_var.h
@@ -48,6 +48,9 @@ xdebug_var_export_options* xdebug_var_export_options_from_ini(TSRMLS_D);
xdebug_var_export_options* xdebug_var_get_nolimit_options(TSRMLS_D);
void xdebug_var_export(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
+#ifndef PHP_WIN32
+void xdebug_var_export_ansi(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
+#endif
void xdebug_var_export_xml(zval **struc, xdebug_str *str, int level TSRMLS_DC);
void xdebug_var_export_fancy(zval **struc, xdebug_str *str, int level, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
void xdebug_var_export_xml_node(zval **struc, char *name, xdebug_xml_node *node, xdebug_var_export_options *options, int level TSRMLS_DC);
@@ -56,11 +59,17 @@ char* xdebug_xmlize(char *string, int len, int *newlen);
char* xdebug_error_type(int type);
zval *xdebug_get_zval(zend_execute_data *zdata, znode *node, temp_variable *Ts, int *is_var);
char* xdebug_get_zval_value(zval *val, int debug_zval, xdebug_var_export_options *options);
+#ifndef PHP_WIN32
+char* xdebug_get_zval_value_ansi(zval *val, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
+#endif
char* xdebug_get_zval_value_xml(char *name, zval *val);
char* xdebug_get_zval_value_fancy(char *name, zval *val, int *len, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
xdebug_xml_node* xdebug_get_zval_value_xml_node(char *name, zval *val, xdebug_var_export_options *options);
char* xdebug_get_zval_synopsis(zval *val, int debug_zval, xdebug_var_export_options *options);
+#ifndef PHP_WIN32
+char* xdebug_get_zval_synopsis_ansi(zval *val, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
+#endif
char* xdebug_get_zval_synopsis_fancy(char *name, zval *val, int *len, int debug_zval, xdebug_var_export_options *options TSRMLS_DC);
char* xdebug_show_fname(xdebug_func t, int html, int flags TSRMLS_DC);
Please sign in to comment.
Something went wrong with that request. Please try again.