[xdebug-general] Re: Patch for #416 - Add return value to computer readable trace format

From: Wim Godden <wim[@]godden.net>
Date: Fri, 13 Aug 2010 14:13:37 +0200

Hi,

Quick patch update, since there was a bug in the patch (newline missing
in the computerized return if no return value was present).
Patch is attached.

Kind regards,

Wim Godden
Cu.be Solutions
http://techblog.wimgodden.be

Wim Godden wrote:
> Hi,
>
> Just redid the patch I wrote for Xdebug 2.0 last year. It fixes bug #416,
> adding a return value in computer readable trace format.
>
> Patch is attached.
>
> Kind regards,
>
> Wim Godden
> Cu.be Solutions
> http://techblog.wimgodden.be
>

Index: xdebug.c
===================================================================
--- xdebug.c (revision 3337)
+++ xdebug.c (working copy)
@@ -1313,6 +1313,9 @@
                         fprintf(XG(trace_file), "%s", t);
                         fflush(XG(trace_file));
                         xdfree(t);
+ } else if (XG(trace_format) == 1) {
+ fprintf(XG(trace_file), "%s", "\n");
+ fflush(XG(trace_file));
                 }
         }
 
Index: xdebug_tracing.c
===================================================================
--- xdebug_tracing.c (revision 3337)
+++ xdebug_tracing.c (working copy)
@@ -98,26 +98,34 @@
         xdebug_str str = {0, 0, NULL};
         char *tmp_value;
 
- if (XG(trace_format) != 0) {
- return xdstrdup("");
- }
+ if (XG(trace_format) == 0) {
+ xdebug_str_addl(&str, " ", 20, 0);
+ if (XG(show_mem_delta)) {
+ xdebug_str_addl(&str, " ", 8, 0);
+ }
+ for (j = 0; j < i->level; j++) {
+ xdebug_str_addl(&str, " ", 2, 0);
+ }
+ xdebug_str_addl(&str, " >=> ", 7, 0);
 
- xdebug_str_addl(&str, " ", 20, 0);
- if (XG(show_mem_delta)) {
- xdebug_str_addl(&str, " ", 8, 0);
- }
- for (j = 0; j < i->level; j++) {
- xdebug_str_addl(&str, " ", 2, 0);
- }
- xdebug_str_addl(&str, " >=> ", 7, 0);
+ tmp_value = xdebug_get_zval_value(retval, 0, NULL);
+ if (tmp_value) {
+ xdebug_str_add(&str, tmp_value, 1);
+ }
+ xdebug_str_addl(&str, "\n", 2, 0);
 
- tmp_value = xdebug_get_zval_value(retval, 0, NULL);
- if (tmp_value) {
- xdebug_str_add(&str, tmp_value, 1);
+ return str.d;
+ } else if (XG(trace_format) == 1) {
+ xdebug_str_addl(&str, "\t", 1, 0);
+ tmp_value = xdebug_get_zval_value(retval, 0, NULL);
+ if (!tmp_value) {
+ tmp_value = "";
+ }
+ xdebug_str_add(&str, xdebug_sprintf("%s\n", tmp_value), 1);
+ return str.d;
+ } else {
+ return xdstrdup("");
         }
- xdebug_str_addl(&str, "\n", 2, 0);
-
- return str.d;
 }
 
 static char* return_trace_stack_frame_begin_normal(function_stack_entry* i TSRMLS_DC)
@@ -256,10 +264,11 @@
                 xdebug_str_add(&str, "1\t", 0);
                 xdebug_str_add(&str, xdebug_sprintf("%f\t", xdebug_get_utime() - XG(start_time)), 1);
 #if HAVE_PHP_MEMORY_USAGE
- xdebug_str_add(&str, xdebug_sprintf("%lu\n", XG_MEMORY_USAGE()), 1);
-#else
- xdebug_str_add(&str, "\n", 0);
+ xdebug_str_add(&str, xdebug_sprintf("%lu", XG_MEMORY_USAGE()), 1);
 #endif
+ if (XG(trace_format) != 1) {
+ xdebug_str_add(&str, "\n", 0);
+ }
         }
 
         return str.d;
Received on Fri Aug 13 2010 - 13:13:49 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST