[xdebug-dev] xdebug xdebug/xdebug.c xdebug/tests/trace1.phpt xdebug/tests/trace2.phpt xdebug/tests/trace.phpt - Fixed bug #299: Computerized traces don't have a newline for return entries if

From: Derick Rethans <derick[@]derickrethans.nl>
Date: Tue, 24 Jul 2007 22:06:41 +0200

Date: Tue Jul 24 22:06:41 CEST 2007
User: Derick Rethans
Directory: xdebug

Log Message:
[1.00]
- Fixed bug #299: Computerized traces don't have a newline for return entries if
  memory limit is not enabled.

Modified files:
           xdebug/xdebug.c (version: 1.402)
           xdebug/tests/trace.phpt (version: 1.15)
Added files:
           xdebug/tests/trace1.phpt (new version: 1.1)
           xdebug/tests/trace2.phpt (new version: 1.1)

[FILE: /xdebug/xdebug.c]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.401
retrieving revision 1.402
diff -u -r1.401 -r1.402
--- xdebug/xdebug.c:1.401 Sun Jul 22 19:03:08 2007 GMT
+++ xdebug/xdebug.c Tue Jul 24 18:06:40 2007 GMT
@@ -2071,7 +2071,11 @@
 
                 xdebug_str_add(&str, "0\t", 0);
                 xdebug_str_add(&str, xdebug_sprintf("%f\t", i->time - XG(start_time)), 1);
+#if HAVE_PHP_MEMORY_USAGE
                 xdebug_str_add(&str, xdebug_sprintf("%lu\t", i->memory), 1);
+#else
+ xdebug_str_add(&str, "\t", 0);
+#endif
                 xdebug_str_add(&str, xdebug_sprintf("%s\t", tmp_name), 1);
                 xdebug_str_add(&str, xdebug_sprintf("%d\t", i->user_defined == XDEBUG_EXTERNAL ? 1 : 0), 1);
                 xdfree(tmp_name);
@@ -2087,6 +2091,8 @@
                 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);
 #endif
         }
 
@@ -2838,11 +2844,11 @@
         if (XG(trace_file)) {
                 if (XG(trace_format) == 0 || XG(trace_format) == 1) {
                         u_time = xdebug_get_utime();
- fprintf(XG(trace_file), "%10.4f ", u_time - XG(start_time));
+ fprintf(XG(trace_file), XG(trace_format) == 0 ? "%10.4f " : "\t\t\t%f\t", u_time - XG(start_time));
 #if HAVE_PHP_MEMORY_USAGE
- fprintf(XG(trace_file), "%10u", XG_MEMORY_USAGE());
+ fprintf(XG(trace_file), XG(trace_format) == 0 ? "%10u" : "%lu", XG_MEMORY_USAGE());
 #else
- fprintf(XG(trace_file), "%10u", 0);
+ fprintf(XG(trace_file), XG(trace_format) == 0 ? "%10u" : "", 0);
 #endif
                         fprintf(XG(trace_file), "\n");
                         str_time = xdebug_get_time();

[FILE: /xdebug/tests/trace1.phpt]

--TEST--
Trace test with fibonacci numbers (format=1)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.enable=1
xdebug.auto_trace=0
xdebug.collect_params=3
xdebug.collect_return=0
xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
--FILE--
<?php
        $tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_COMPUTERIZED);
    function fibonacci_cache ($n)
    {
        if (isset ($GLOBALS['fcache'][$n])) {
            return $GLOBALS['fcache'][$n];
        }

        if ($n == 0) {
            return 0;
        } else if ($n == 1) {
            return 1;
        } else if ($n == 2) {
            return 1;
        } else {
            $t = fibonacci_cache($n - 1) + fibonacci_cache($n - 2);
            $GLOBALS['fcache'][$n] = $t;
            return $t;
        }
    }

        fibonacci_cache(50);
        xdebug_stop_trace();
        echo file_get_contents($tf);
        unlink($tf);
?>
--EXPECTF--
Version: 2.%d.%d%s
TRACE START [%d-%d-%d %d:%d:%d]
2 2 1 %f %d
2 3 0 %f %d fibonacci_cache 1 %strace1.php 22
3 4 0 %f %d fibonacci_cache 1 %strace1.php 16
4 5 0 %f %d fibonacci_cache 1 %strace1.php 16
5 6 0 %f %d fibonacci_cache 1 %strace1.php 16
6 7 0 %f %d fibonacci_cache 1 %strace1.php 16
7 8 0 %f %d fibonacci_cache 1 %strace1.php 16
8 9 0 %f %d fibonacci_cache 1 %strace1.php 16
9 10 0 %f %d fibonacci_cache 1 %strace1.php 16
10 11 0 %f %d fibonacci_cache 1 %strace1.php 16
11 12 0 %f %d fibonacci_cache 1 %strace1.php 16
12 13 0 %f %d fibonacci_cache 1 %strace1.php 16
13 14 0 %f %d fibonacci_cache 1 %strace1.php 16
14 15 0 %f %d fibonacci_cache 1 %strace1.php 16
15 16 0 %f %d fibonacci_cache 1 %strace1.php 16
16 17 0 %f %d fibonacci_cache 1 %strace1.php 16
17 18 0 %f %d fibonacci_cache 1 %strace1.php 16
18 19 0 %f %d fibonacci_cache 1 %strace1.php 16
19 20 0 %f %d fibonacci_cache 1 %strace1.php 16
20 21 0 %f %d fibonacci_cache 1 %strace1.php 16
21 22 0 %f %d fibonacci_cache 1 %strace1.php 16
22 23 0 %f %d fibonacci_cache 1 %strace1.php 16
23 24 0 %f %d fibonacci_cache 1 %strace1.php 16
24 25 0 %f %d fibonacci_cache 1 %strace1.php 16
25 26 0 %f %d fibonacci_cache 1 %strace1.php 16
26 27 0 %f %d fibonacci_cache 1 %strace1.php 16
27 28 0 %f %d fibonacci_cache 1 %strace1.php 16
28 29 0 %f %d fibonacci_cache 1 %strace1.php 16
29 30 0 %f %d fibonacci_cache 1 %strace1.php 16
30 31 0 %f %d fibonacci_cache 1 %strace1.php 16
31 32 0 %f %d fibonacci_cache 1 %strace1.php 16
32 33 0 %f %d fibonacci_cache 1 %strace1.php 16
33 34 0 %f %d fibonacci_cache 1 %strace1.php 16
34 35 0 %f %d fibonacci_cache 1 %strace1.php 16
35 36 0 %f %d fibonacci_cache 1 %strace1.php 16
36 37 0 %f %d fibonacci_cache 1 %strace1.php 16
37 38 0 %f %d fibonacci_cache 1 %strace1.php 16
38 39 0 %f %d fibonacci_cache 1 %strace1.php 16
39 40 0 %f %d fibonacci_cache 1 %strace1.php 16
40 41 0 %f %d fibonacci_cache 1 %strace1.php 16
41 42 0 %f %d fibonacci_cache 1 %strace1.php 16
42 43 0 %f %d fibonacci_cache 1 %strace1.php 16
43 44 0 %f %d fibonacci_cache 1 %strace1.php 16
44 45 0 %f %d fibonacci_cache 1 %strace1.php 16
45 46 0 %f %d fibonacci_cache 1 %strace1.php 16
46 47 0 %f %d fibonacci_cache 1 %strace1.php 16
47 48 0 %f %d fibonacci_cache 1 %strace1.php 16
48 49 0 %f %d fibonacci_cache 1 %strace1.php 16
49 50 0 %f %d fibonacci_cache 1 %strace1.php 16
50 51 0 %f %d fibonacci_cache 1 %strace1.php 16
50 51 1 %f %d
50 52 0 %f %d fibonacci_cache 1 %strace1.php 16
50 52 1 %f %d
49 50 1 %f %d
49 53 0 %f %d fibonacci_cache 1 %strace1.php 16
49 53 1 %f %d
48 49 1 %f %d
48 54 0 %f %d fibonacci_cache 1 %strace1.php 16
48 54 1 %f %d
47 48 1 %f %d
47 55 0 %f %d fibonacci_cache 1 %strace1.php 16
47 55 1 %f %d
46 47 1 %f %d
46 56 0 %f %d fibonacci_cache 1 %strace1.php 16
46 56 1 %f %d
45 46 1 %f %d
45 57 0 %f %d fibonacci_cache 1 %strace1.php 16
45 57 1 %f %d
44 45 1 %f %d
44 58 0 %f %d fibonacci_cache 1 %strace1.php 16
44 58 1 %f %d
43 44 1 %f %d
43 59 0 %f %d fibonacci_cache 1 %strace1.php 16
43 59 1 %f %d
42 43 1 %f %d
42 60 0 %f %d fibonacci_cache 1 %strace1.php 16
42 60 1 %f %d
41 42 1 %f %d
41 61 0 %f %d fibonacci_cache 1 %strace1.php 16
41 61 1 %f %d
40 41 1 %f %d
40 62 0 %f %d fibonacci_cache 1 %strace1.php 16
40 62 1 %f %d
39 40 1 %f %d
39 63 0 %f %d fibonacci_cache 1 %strace1.php 16
39 63 1 %f %d
38 39 1 %f %d
38 64 0 %f %d fibonacci_cache 1 %strace1.php 16
38 64 1 %f %d
37 38 1 %f %d
37 65 0 %f %d fibonacci_cache 1 %strace1.php 16
37 65 1 %f %d
36 37 1 %f %d
36 66 0 %f %d fibonacci_cache 1 %strace1.php 16
36 66 1 %f %d
35 36 1 %f %d
35 67 0 %f %d fibonacci_cache 1 %strace1.php 16
35 67 1 %f %d
34 35 1 %f %d
34 68 0 %f %d fibonacci_cache 1 %strace1.php 16
34 68 1 %f %d
33 34 1 %f %d
33 69 0 %f %d fibonacci_cache 1 %strace1.php 16
33 69 1 %f %d
32 33 1 %f %d
32 70 0 %f %d fibonacci_cache 1 %strace1.php 16
32 70 1 %f %d
31 32 1 %f %d
31 71 0 %f %d fibonacci_cache 1 %strace1.php 16
31 71 1 %f %d
30 31 1 %f %d
30 72 0 %f %d fibonacci_cache 1 %strace1.php 16
30 72 1 %f %d
29 30 1 %f %d
29 73 0 %f %d fibonacci_cache 1 %strace1.php 16
29 73 1 %f %d
28 29 1 %f %d
28 74 0 %f %d fibonacci_cache 1 %strace1.php 16
28 74 1 %f %d
27 28 1 %f %d
27 75 0 %f %d fibonacci_cache 1 %strace1.php 16
27 75 1 %f %d
26 27 1 %f %d
26 76 0 %f %d fibonacci_cache 1 %strace1.php 16
26 76 1 %f %d
25 26 1 %f %d
25 77 0 %f %d fibonacci_cache 1 %strace1.php 16
25 77 1 %f %d
24 25 1 %f %d
24 78 0 %f %d fibonacci_cache 1 %strace1.php 16
24 78 1 %f %d
23 24 1 %f %d
23 79 0 %f %d fibonacci_cache 1 %strace1.php 16
23 79 1 %f %d
22 23 1 %f %d
22 80 0 %f %d fibonacci_cache 1 %strace1.php 16
22 80 1 %f %d
21 22 1 %f %d
21 81 0 %f %d fibonacci_cache 1 %strace1.php 16
21 81 1 %f %d
20 21 1 %f %d
20 82 0 %f %d fibonacci_cache 1 %strace1.php 16
20 82 1 %f %d
19 20 1 %f %d
19 83 0 %f %d fibonacci_cache 1 %strace1.php 16
19 83 1 %f %d
18 19 1 %f %d
18 84 0 %f %d fibonacci_cache 1 %strace1.php 16
18 84 1 %f %d
17 18 1 %f %d
17 85 0 %f %d fibonacci_cache 1 %strace1.php 16
17 85 1 %f %d
16 17 1 %f %d
16 86 0 %f %d fibonacci_cache 1 %strace1.php 16
16 86 1 %f %d
15 16 1 %f %d
15 87 0 %f %d fibonacci_cache 1 %strace1.php 16
15 87 1 %f %d
14 15 1 %f %d
14 88 0 %f %d fibonacci_cache 1 %strace1.php 16
14 88 1 %f %d
13 14 1 %f %d
13 89 0 %f %d fibonacci_cache 1 %strace1.php 16
13 89 1 %f %d
12 13 1 %f %d
12 90 0 %f %d fibonacci_cache 1 %strace1.php 16
12 90 1 %f %d
11 12 1 %f %d
11 91 0 %f %d fibonacci_cache 1 %strace1.php 16
11 91 1 %f %d
10 11 1 %f %d
10 92 0 %f %d fibonacci_cache 1 %strace1.php 16
10 92 1 %f %d
9 10 1 %f %d
9 93 0 %f %d fibonacci_cache 1 %strace1.php 16
9 93 1 %f %d
8 9 1 %f %d
8 94 0 %f %d fibonacci_cache 1 %strace1.php 16
8 94 1 %f %d
7 8 1 %f %d
7 95 0 %f %d fibonacci_cache 1 %strace1.php 16
7 95 1 %f %d
6 7 1 %f %d
6 96 0 %f %d fibonacci_cache 1 %strace1.php 16
6 96 1 %f %d
5 6 1 %f %d
5 97 0 %f %d fibonacci_cache 1 %strace1.php 16
5 97 1 %f %d
4 5 1 %f %d
4 98 0 %f %d fibonacci_cache 1 %strace1.php 16
4 98 1 %f %d
3 4 1 %f %d
3 99 0 %f %d fibonacci_cache 1 %strace1.php 16
3 99 1 %f %d
2 3 1 %f %d
2 100 0 %f %d xdebug_stop_trace 0 %strace1.php 23
                        %f %d
TRACE END [%d-%d-%d %d:%d:%d]

[FILE: /xdebug/tests/trace2.phpt]

--TEST--
Trace test with fibonacci numbers (format=2)
--SKIPIF--
<?php if (!extension_loaded("xdebug")) print "skip"; ?>
--INI--
xdebug.enable=1
xdebug.auto_trace=0
xdebug.collect_params=3
xdebug.collect_return=0
xdebug.auto_profile=0
xdebug.profiler_enable=0
xdebug.show_mem_delta=0
xdebug.trace_format=0
--FILE--
<?php
        $tf = xdebug_start_trace('/tmp/'. uniqid('xdt', TRUE), XDEBUG_TRACE_HTML);
    function fibonacci_cache ($n)
    {
        if (isset ($GLOBALS['fcache'][$n])) {
            return $GLOBALS['fcache'][$n];
        }

        if ($n == 0) {
            return 0;
        } else if ($n == 1) {
            return 1;
        } else if ($n == 2) {
            return 1;
        } else {
            $t = fibonacci_cache($n - 1) + fibonacci_cache($n - 2);
            $GLOBALS['fcache'][$n] = $t;
            return $t;
        }
    }

        fibonacci_cache(10);
        xdebug_stop_trace();
        echo file_get_contents($tf);
        unlink($tf);
?>
--EXPECTF--
<table class='xdebug-trace' border='1' cellspacing='0'>
        <tr><th>#</th><th>Time</th><th colspan='2'>Function</th><th>Location</th></tr>
        <tr><td>3</td><td>%f</td><td align='left'>&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:22</td></tr>
        <tr><td>4</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>5</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>6</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>7</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>8</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>9</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>10</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>11</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>12</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>13</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>14</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>15</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>16</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>17</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>18</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>19</td><td>%f</td><td align='left'>&nbsp; &nbsp;&nbsp; &nbsp;-&gt;</td><td>fibonacci_cache()</td><td>%strace2.php:16</td></tr>
        <tr><td>20</td><td>%f</td><td align='left'>&nbsp; &nbsp;-&gt;</td><td>xdebug_stop_trace()</td><td>%strace2.php:23</td></tr>
</table>

[FILE: /xdebug/tests/trace.phpt]

===================================================================
RCS file: cvstemp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- xdebug/tests/trace.phpt:1.14 Sun May 06 12:36:17 2007 GMT
+++ xdebug/tests/trace.phpt Tue Jul 24 18:06:41 2007 GMT
@@ -1,5 +1,5 @@
 --TEST--
-Test with fibonacci numbers
+Trace test with fibonacci numbers (format=0)
 --SKIPIF--
 <?php if (!extension_loaded("xdebug")) print "skip"; ?>
 --INI--
@@ -34,6 +34,7 @@
     }
 
         fibonacci_cache(50);
+ xdebug_stop_trace();
         echo file_get_contents($tf);
         unlink($tf);
 ?>
@@ -136,4 +137,6 @@
 %w%f %w%d -> fibonacci_cache(46) /%s/trace.php:16
 %w%f %w%d -> fibonacci_cache(47) /%s/trace.php:16
 %w%f %w%d -> fibonacci_cache(48) /%s/trace.php:16
-%w%f %w%d -> file_get_contents('/tmp/%s') /%s/trace.php:23
+%w%f %w%d -> xdebug_stop_trace() /%s/trace.php:23
+%w%f %w%d
+TRACE END [%d-%d-%d %d:%d:%d]
Received on Tue Jul 24 2007 - 22:06:47 BST

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST